當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。