|
| 1 | +var disableElementSize=true; |
| 2 | + |
| 3 | +$(document).ready(function() { |
| 4 | + |
| 5 | + //init tree |
| 6 | + $('img.tabsLoading').hide() |
| 7 | + |
| 8 | + |
| 9 | + $("#browseTable").treeTable(); |
| 10 | + $("img.tableLoading").hide(); |
| 11 | + $("table#browseTable").show(); |
| 12 | + |
| 13 | + initDragAndDrop(); |
| 14 | + |
| 15 | + }); |
| 16 | + |
| 17 | + |
| 18 | + //dependance: common/browser.js |
| 19 | + var ajaxSelectRequest=''; |
| 20 | + function callbackSelect(node) |
| 21 | + { |
| 22 | + $('div.genericAction').hide(); |
| 23 | + $('div.genericCommunities').hide(); |
| 24 | + $('div.genericStats').hide(); |
| 25 | + $('div.viewInfo').show(); |
| 26 | + $('div.viewAction').show() |
| 27 | + genericCallbackSelect(node); |
| 28 | + } |
| 29 | + |
| 30 | + function callbackDblClick(node) |
| 31 | + { |
| 32 | + } |
| 33 | + |
| 34 | + function callbackCheckboxes(node) |
| 35 | + { |
| 36 | + genericCallbackCheckboxes(node); |
| 37 | + } |
| 38 | + |
| 39 | + function callbackCreateElement(node) |
| 40 | + { |
| 41 | + initDragAndDrop(); |
| 42 | + } |
| 43 | + |
| 44 | +function initDragAndDrop() |
| 45 | +{ |
| 46 | + $("#browseTable .file, #browseTable .folder:not(.notdraggable)").draggable({ |
| 47 | + helper: "clone", |
| 48 | + opacity: .75, |
| 49 | + refreshPositions: true, // Performance? |
| 50 | + revert: "invalid", |
| 51 | + revertDuration: 300, |
| 52 | + scroll: true |
| 53 | + }); |
| 54 | + |
| 55 | + // Configure droppable rows |
| 56 | + $("#browseTable .folder").each(function() { |
| 57 | + $(this).parents("tr").droppable({ |
| 58 | + accept: ".file, .folder", |
| 59 | + drop: function(e, ui) { |
| 60 | + // Call jQuery treeTable plugin to move the branch |
| 61 | + var elements=''; |
| 62 | + if($(ui.draggable).parents("tr").attr('type')=='folder') |
| 63 | + { |
| 64 | + elements=$(ui.draggable).parents("tr").attr('element')+';'; |
| 65 | + } |
| 66 | + else |
| 67 | + { |
| 68 | + elements=';'+$(ui.draggable).parents("tr").attr('element'); |
| 69 | + } |
| 70 | + var from; |
| 71 | + var classNames=$(ui.draggable).parents("tr").attr('class').split(' '); |
| 72 | + for(key in classNames) { |
| 73 | + if(classNames[key].match('child-of-')) { |
| 74 | + from= $("#" + classNames[key].substring(9)).attr('element'); |
| 75 | + } |
| 76 | + } |
| 77 | + var destination_obj=this; |
| 78 | + $.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:from,ajax:true}, |
| 79 | + function(data) { |
| 80 | + |
| 81 | + jsonResponse = jQuery.parseJSON(data); |
| 82 | + if(jsonResponse==null) |
| 83 | + { |
| 84 | + createNotive('Error',4000); |
| 85 | + return; |
| 86 | + } |
| 87 | + if(jsonResponse[0]) |
| 88 | + { |
| 89 | + createNotive(jsonResponse[1],1500); |
| 90 | + $($(ui.draggable).parents("tr")).appendBranchTo(destination_obj); |
| 91 | + $(destination_obj).reload(); |
| 92 | + } |
| 93 | + else |
| 94 | + { |
| 95 | + createNotive(jsonResponse[1],4000); |
| 96 | + } |
| 97 | + }); |
| 98 | + |
| 99 | + }, |
| 100 | + hoverClass: "accept", |
| 101 | + over: function(e, ui) { |
| 102 | + // Make the droppable branch expand when a draggable node is moved over it. |
| 103 | + if(this.id != $(ui.draggable.parents("tr")[0]).id && !$(this).is(".expanded")) { |
| 104 | + $(this).expand(); |
| 105 | + } |
| 106 | + } |
| 107 | + }); |
| 108 | + }); |
| 109 | +} |
0 commit comments