当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Common.getElementsByClassName方法代码示例

本文整理汇总了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
                }));
             }
          })
       }
    }  
 }
开发者ID:snapscript,项目名称:snap-develop,代码行数:25,代码来源:tree.ts

示例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
       }));
    }
 })
开发者ID:snapscript,项目名称:snap-develop,代码行数:14,代码来源:tree.ts

示例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);
      }  
   }
开发者ID:snapscript,项目名称:snap-develop,代码行数:42,代码来源:tree.ts


注:本文中的common.Common.getElementsByClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。