本文整理汇总了TypeScript中common.Common.getElementsByClassName方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Common.getElementsByClassName方法的具体用法?TypeScript Common.getElementsByClassName怎么用?TypeScript Common.getElementsByClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.getElementsByClassName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateNodesAsDraggable
function updateNodesAsDraggable(nodeElement) {
var childNodes = Common.getElementsByClassName(nodeElement, 'fancytree-node');
for(var i = 0; i < childNodes.length; i++) {
let childNode = childNodes[i];
if(childNode){
childNode.setAttribute("draggable", "true");
$(childNode).on('dragstart',function(event){
var dataTransfer = event.target.dataTransfer || event.originalEvent.dataTransfer
var target = event.target || event.currentTarger;
var titleNodes = Common.getElementsByClassName(childNode, 'fancytree-title');
if(titleNodes && titleNodes.length > 0) {
var titleNode = titleNodes[0];
dataTransfer.setData("resource", JSON.stringify({
resource: titleNode.getAttribute("title"),
folder: isTreeNodeFolder(target) // this does not work
}));
}
})
}
}
}
示例2: isTreeNodeFolder
$(childNode).on('dragstart',function(event){
var dataTransfer = event.target.dataTransfer || event.originalEvent.dataTransfer
var target = event.target || event.currentTarger;
var titleNodes = Common.getElementsByClassName(childNode, 'fancytree-title');
if(titleNodes && titleNodes.length > 0) {
var titleNode = titleNodes[0];
dataTransfer.setData("resource", JSON.stringify({
resource: titleNode.getAttribute("title"),
folder: isTreeNodeFolder(target) // this does not work
}));
}
})
示例3: addDragAndDropHandlers
function addDragAndDropHandlers(id) {
var explorerTree = document.getElementById(id);
var folders = Common.getElementsByClassName(explorerTree, 'fancytree-folder');
for(var i = 0; i < folders.length; i++) {
let child = folders[i];
$(child).on("dragenter", function(event) {
$(child).find('.fancytree-title').addClass("treeFolderDragOver");
}).on("dragleave", function(event) {
$(child).find('.fancytree-title').removeClass("treeFolderDragOver");
}).on("drop", function (event) {
var folderElement = $(child).find('.fancytree-title');
var dataTransfer = event.target.dataTransfer || event.originalEvent.dataTransfer;
var target = event.target || event.currentTarger;
var dataPath = dataTransfer.getData("resource");
var folderPath = $(folderElement).attr("title");
$(folderElement).removeClass("treeFolderDragOver");
event.stopPropagation();
event.preventDefault();
var toPath: FilePath = createResourcePath(folderPath);
var toChildren: any = findAllChildrenOf(explorerTree, toPath);
var toNode: FileNode = new FileNode(toPath, toChildren);
if(dataPath) {
var fromBlob = JSON.parse(dataPath);
var fromPath: FilePath = createResourcePath(fromBlob.resource);
var fromChildren: any = findAllChildrenOf(explorerTree, fromPath);
var fromNode: FileNode = new FileNode(fromPath, fromChildren);
handleNodeDroppedOverFolder(event, fromNode, toNode);
}else {
handleFileDroppedOverFolder(event, toNode);
}
}).on('dragover',function(event){
event.preventDefault();
});
updateNodesAsDraggable(explorerTree);
}
}