Changeset 6 for pro-bachkim-filespace/violetspace-prototype/assets/js
- Timestamp:
- May 29, 2014 5:50:37 PM (11 years ago)
- Location:
- pro-bachkim-filespace/violetspace-prototype/assets/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-bachkim-filespace/violetspace-prototype/assets/js/filemanager/filemanager.js
r5 r6 19 19 $('#directory-view-container').height(dirTreeHeight); 20 20 $('#directory-content-view-container').height(dirTreeHeight); 21 $('#directory-content-view-container').width('calc(100% - ' + ($('#directory-view-container').width() + 3) + 'px)');21 $('#directory-content-view-container').width('calc(100% - ' + ($('#directory-view-container').width() + 8) + 'px)'); 22 22 var scollWidth = $('#directory-content-view-container').width(); 23 23 … … 49 49 */ 50 50 51 var privateGrid = $('#file-container').violetGrid ({directoryContent:null}); 52 51 53 var privateTree = $('#treeview-container').violetTree({ 52 54 script:'getdata.php', 53 55 expandEasing: 'easeOutBounce', 54 56 collapseEasing: 'easeOutBounce', 55 homeDirNameDisplay: "Thư mục gá»c" 57 homeDirNameDisplay: "Thư mục gá»c", 58 grid: privateGrid 56 59 }); 57 60 -
pro-bachkim-filespace/violetspace-prototype/assets/js/vsfilemanager.js
r5 r6 15 15 if( o.collapseEasing == undefined ) o.collapseEasing = null; 16 16 17 if( o.directoryTreeData == undefined ) o.directoryTreeData = null; 18 if( o.grid == undefined ) o.grid = null; 19 17 20 // PRIVATE methods 18 21 var sendCommand = function (p) { … … 42 45 43 46 var renderTree = function (parseData) { 47 48 o.directoryTreeData = parseData; 49 var directoryData = parseData.DIRECTORIES; 50 44 51 var homeNode = createNode({ 45 52 id:0, … … 48 55 49 56 selectDir($(homeNode).find('> A')); 50 if ( parseData != null) {51 for (var i = 0; i < parseData.length ; i++) {57 if (directoryData != null) { 58 for (var i = 0; i < directoryData.length ; i++) { 52 59 var node = createNode ({ 53 id: parseData[i].id,54 name: parseData[i].name,55 curentNode: $('#' + o.dirIDprefix + parseData[i].parentID).find('> A'),56 hidden: ( parseData[i].parentID > 0) ? true : false60 id: directoryData[i].id, 61 name: directoryData[i].name, 62 curentNode: $('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'), 63 hidden: (directoryData[i].parentID > 0) ? true : false 57 64 }) 58 65 }; … … 71 78 72 79 if (d.curentNode != null) { 73 var strHTML = '<ul class=" jqueryFileTree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>';80 var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; 74 81 75 82 $(d.curentNode).parent().append(strHTML); … … 78 85 79 86 }else if (d.id == 0){ 80 var strHTML = '<ul class=" jqueryFileTree"><li id="' + o.dirIDprefix + d.id + '" class="home"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>';87 var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="home"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; 81 88 $(o.container).append(strHTML); 82 89 } 83 90 84 91 //bind event on new node 85 $('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this) });92 $('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;}); 86 93 $('#' + o.dirIDprefix + d.id).find('a').bind("contextmenu",function(e){ 87 94 e.preventDefault(); … … 126 133 $('.currentDir').removeClass('currentDir'); 127 134 $(c).addClass('currentDir'); 135 sendtoGrid(); 128 136 } 129 137 … … 131 139 alert ('showContextMenu on ' + $(n).text()); 132 140 }; 141 142 var sendtoGrid = function () { 143 o.grid.getData({ 144 directoryTreeData: o.directoryTreeData, 145 curentParent:$(o.container).find('.currentDir').parent().attr('id'), 146 dirIDprefix: o.dirIDprefix 147 }); 148 } 133 149 134 150 loadTree(); … … 205 221 206 222 violetGrid: function (o) { 223 if( !o ) var o = {}; 207 224 if( o.container == undefined ) o.container = $(this); 208 225 if( o.defaultViewMode == undefined ) o.defaultViewMode = 'thumbnail';//or 'list' 209 210 if( o.directoryContent == undefined ) o.directoryContent = null; 211 226 if( o.directoryTreeData == undefined ) o.directoryTreeData = null; 227 if( o.dirIDprefix == undefined ) o.dirIDprefix = null; 228 229 var createNode = function (d) { 230 if( !d ) var d = {}; 231 if( d.id == undefined ) d.id = null; 232 if( d.name == undefined ) d.name = null; 233 if( d.minetype == undefined ) d.minetype = 'directory'; 234 if( d.parentID == undefined ) d.parentID = null; 235 if( d.clickEvent == undefined ) d.clickEvent = null; 236 if( d.customEvent == undefined ) d.customEvent = null; 237 238 var strHTML = '<div class="vscell" rel="id:' + d.id + '">'; 239 strHTML += '<div class="selector unselected">'; 240 strHTML += '<div class="icon-' + d.minetype + '"></div>'; 241 strHTML += '</div>'; 242 strHTML += '<div class="file-name unselected">' + d.name + '</div>'; 243 strHTML += '</div>'; 244 245 $(o.container).append(strHTML); 246 247 $('div[rel="id:'+ d.id +'"]').bind('click',function(e){itemClick(this)}); 248 } 249 250 var itemClick = function (i) { 251 $(i).parent().find('.selector').removeClass('selected'); 252 $(i).parent().find('.selector').addClass('unselected'); 253 $(i).parent().find('.file-name').removeClass('selected'); 254 $(i).parent().find('.file-name').addClass('unselected'); 255 256 $(i).find('.file-name').removeClass('unselected'); 257 $(i).find('.file-name').addClass('selected'); 258 $(i).find('.selector').removeClass('unselected'); 259 $(i).find('.selector').addClass('selected'); 260 } 261 262 var renderGrid = function (o) { 263 $(o.container).find ('.vscell').remove(); 264 var childDir = o.directoryTreeData.DIRECTORIES; 265 var childFile = o.directoryTreeData.FILES; 266 var curentDirID = o.curentParent.substring(o.dirIDprefix.length, o.curentParent.length); 267 268 for (var i = 0 ; i < childDir.length; i++) { 269 if (childDir[i].parentID != curentDirID) continue; 270 createNode ({ 271 id: childDir[i].id, 272 name: childDir[i].name, 273 parentID: curentDirID, 274 }); 275 } 276 277 for (var i = 0 ; i < childFile.length; i++) { 278 if (childFile[i].parentID != curentDirID) continue; 279 createNode ({ 280 id: childFile[i].id, 281 name: childFile[i].name, 282 parentID: curentDirID, 283 minetype: childFile[i].minetype, 284 }); 285 } 286 } 287 288 this.getData = function (data) { 289 o.directoryTreeData = data.directoryTreeData; 290 o.curentParent = data.curentParent; 291 o.dirIDprefix = data.dirIDprefix 292 renderGrid(o); 293 } 294 295 this.initialize = function() { 296 return this; 297 }; 298 299 return this.initialize(); 212 300 } 213 301 });
Note: See TracChangeset
for help on using the changeset viewer.