Changeset 17 for pro-bachkim-filespace/sourcecode/assets/js/vstree.js
- Timestamp:
- Jul 1, 2014 9:23:18 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-bachkim-filespace/sourcecode/assets/js/vstree.js
r16 r17 8 8 if( o.host == undefined ) o.host = 'http://localhost/'; 9 9 if( o.script == undefined ) o.script = 'ajax/privatecontent/getcontent'; 10 if( o.container == undefined ) o.container = $(this);10 if( o.container == undefined ) o.container = null; 11 11 if( o.dirIDprefix == undefined ) o.dirIDprefix = 'vsdir_'; 12 12 … … 18 18 if( o.directoryTreeData == undefined ) o.directoryTreeData = null; 19 19 if( o.grid == undefined ) o.grid = null; 20 if( o.contextmenuON == undefined ) o.contextmenuON = true; 20 21 21 22 var currentObj = {}; 23 if ( currentObj.type == undefined ) currentObj.type = 'directory'; 22 24 23 25 // PRIVATE methods … … 49 51 50 52 var renderTree = function (parseData) { 53 $(o.container).find ('.vstree').remove(); 54 51 55 o.directoryTreeData = parseData; 52 56 var directoryData = parseData.DIRECTORIES; … … 56 60 name:o.homeDirNameDisplay, 57 61 }); 58 62 59 63 selectDir($(homeNode).find('> A')); 60 64 if (directoryData != null) { … … 63 67 id: directoryData[i].id, 64 68 name: directoryData[i].name, 65 cur entNode: $('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'),69 currentNode: $(o.container).find('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'), 66 70 hidden: (directoryData[i].parentID > 0) ? true : false 67 71 }) … … 75 79 if( d.id == undefined ) d.id = null; 76 80 if( d.name == undefined ) d.name = null; 77 if( d.cur entNode == undefined ) d.curentNode = null;81 if( d.currentNode == undefined ) d.currentNode = null; 78 82 if( d.hidden == undefined ) d.hidden = true; 79 83 if( d.clickEvent == undefined ) d.clickEvent = openDir; … … 85 89 disabledItemsList = ['cut','delete']; 86 90 87 if (d.cur entNode != null) {91 if (d.currentNode != null) { 88 92 var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; 89 93 90 $(d.cur entNode).parent().append(strHTML);94 $(d.currentNode).parent().append(strHTML); 91 95 if (d.hidden == true) 92 $( '#' + o.dirIDprefix + d.id).parent().css('display','none');96 $(o.container).find('#' + o.dirIDprefix + d.id).parent().css('display','none'); 93 97 94 98 }else if (d.id == 0){ … … 103 107 newdir.id = d.id; 104 108 newdir.name = d.name; 105 newdir.parentID = $( d.curentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.curentNode).parent().attr('id').length);109 newdir.parentID = $(o.container).find(d.currentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.currentNode).parent().attr('id').length); 106 110 o.directoryTreeData.DIRECTORIES.push(newdir); 107 111 sendtoGrid(); … … 109 113 110 114 //bind event on new node 111 $('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;}); 112 113 $('#' + o.dirIDprefix + d.id).find('a').contextMenu({ 114 menu: 'treeMenu', 115 disabledItems: disabledItemsList 116 }, function(action, el, pos) { 117 selectDir(el); 118 switch(action) { 119 case 'rename': 120 rename(el); 121 break; 122 case 'share': 123 o.grid.showModal(action, currentObj); 124 break; 125 default: 126 break; 127 } 128 }); 115 $(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;}); 116 117 if (o.contextmenuON) { 118 $(o.container).find('#' + o.dirIDprefix + d.id).find('a').contextMenu({ 119 menu: 'treeMenu', 120 disabledItems: disabledItemsList 121 }, function(action, el, pos) { 122 selectDir(el); 123 switch(action) { 124 case 'rename': 125 rename(el); 126 break; 127 case 'share': 128 case 'copy': 129 case 'cut': 130 o.grid.showModal(currentObj, action); 131 break; 132 default: 133 break; 134 } 135 }); 136 } 129 137 130 138 if (d.customEvent != null) 131 $( '#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)});132 133 return $( '#' + o.dirIDprefix + d.id);139 $(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)}); 140 141 return $(o.container).find('#' + o.dirIDprefix + d.id); 134 142 } 135 143 //END - Create a node of Tree … … 178 186 179 187 var sendtoGrid = function () { 188 if (o.grid == null) return false; 189 180 190 o.grid.getData({ 181 191 directoryTreeData: o.directoryTreeData, … … 327 337 return this; 328 338 }; 339 340 this.getSelectedObj = function () { 341 return currentObj; 342 } 329 343 330 344 return this.initialize();
Note: See TracChangeset
for help on using the changeset viewer.