Changeset 4 for pro-bachkim-filespace
- Timestamp:
- May 26, 2014 6:12:35 PM (11 years ago)
- Location:
- pro-bachkim-filespace/violetspace-prototype
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-bachkim-filespace/violetspace-prototype/assets/css/jquery/jqueryFileTree.css
r1 r4 31 31 32 32 /* Core Styles */ 33 .jqueryFileTree LI.home { background: url(../../images/filetree/home.png) left top no-repeat; 33 .jqueryFileTree LI.home { background: url(../../images/filetree/home.png) left top no-repeat;} 34 34 .jqueryFileTree LI.directory { background: url(../../images/filetree/directory.png) left top no-repeat; } 35 35 .jqueryFileTree LI.expanded { background: url(../../images/filetree/folder_open.png) left top no-repeat; } -
pro-bachkim-filespace/violetspace-prototype/assets/js/filemanager/filemanager.js
r1 r4 59 59 60 60 $('#btnNewFolder').click (function(){ 61 //privateTree.expandAll(); 62 //alert(privateTree.getCurrentDir()); 61 var curDir = privateTree.getCurrentDir(); 62 privateTree.createDir(curDir); 63 }); 64 65 $('#btnDel').click (function() { 66 var curDir = privateTree.getCurrentDir(); 67 privateTree.deleteDir(curDir); 63 68 }); 64 69 -
pro-bachkim-filespace/violetspace-prototype/assets/js/vsfilemanager.js
r1 r4 3 3 $.extend($.fn, { 4 4 violetTree: function(o) { 5 var loadedNode = null;6 7 5 if( !o ) var o = {}; 8 6 if( o.user == undefined ) o.user = null; … … 19 17 if( o.collapseEasing == undefined ) o.collapseEasing = null; 20 18 21 $(this).each( function() { 22 function loadTree() { 23 if (o.dataSource == 'AJAX') { 24 $.post(o.script, 25 function(data){ 26 if (!data) return; 27 var parsedData = $.parseJSON(data); 28 o.data = parsedData; 29 renderTree (); 30 } 31 ) 32 .done(function() { 33 //alert( "second success" ); 19 // PRIVATE methods 20 var loadTree = function () { 21 if (o.dataSource == 'AJAX') { 22 $.post(o.script, 23 function(data){ 24 if (!data) return; 25 var parsedData = $.parseJSON(data); 26 o.data = parsedData; 27 renderTree (); 28 } 29 ).done(function() {}).fail(function() {}).always(function() {}); 30 } 31 }; 32 33 var renderTree = function () { 34 var homeNode = createNode({ 35 id:0, 36 name:o.homeDirNameDisplay, 37 }); 38 39 selectDir($(homeNode).find('> A')); 40 41 if (o.data != null) { 42 for (var i = 0; i < o.data.length ; i++) { 43 var node = createNode ({ 44 id: o.data[i].id, 45 name: o.data[i].name, 46 curentNode: $('#' + o.dirIDprefix + o.data[i].parentID).find('> A'), 47 hidden: (o.data[i].parentID > 0) ? true : false 34 48 }) 35 .fail(function() { 36 //alert( "error" ); 37 }) 38 .always(function() { 39 //alert( "finished" ); 40 }); 41 } 42 }; 49 }; 50 } 51 }; 43 52 44 function renderTree () { 45 $(o.container).click(function(){return false;}).mousedown(function(){return false;}); 46 $(o.container).bind("contextmenu",function(e){e.preventDefault();}); 53 //Create a node of Tree 54 var createNode = function (d) { 55 if( !d ) var d = {}; 56 if( d.id == undefined ) d.id = null; 57 if( d.name == undefined ) d.name = null; 58 if( d.curentNode == undefined ) d.curentNode = null; 59 if( d.hidden == undefined ) d.hidden = true; 60 if( d.clickEvent == undefined ) d.clickEvent = openDir; 61 if( d.customEvent == undefined ) d.customEvent = null; //customEvent.eventName, customEvent.eventTrigger 62 63 if (d.curentNode != null) { 64 var strHTML = '<ul class="jqueryFileTree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; 47 65 48 //Home directory 49 strHTML = '<ul class="jqueryFileTree"><li id="' + o.dirIDprefix + 0 + '" class="home"><a href="#" rel="spacehome">' + o.homeDirNameDisplay + '</a></li></ul>'; 66 $(d.curentNode).parent().append(strHTML); 67 if (d.hidden == true) 68 $('#' + o.dirIDprefix + d.id).parent().css('display','none'); 69 70 }else if (d.id == 0){ 71 var strHTML = '<ul class="jqueryFileTree"><li id="' + o.dirIDprefix + d.id + '" class="home"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; 50 72 $(o.container).append(strHTML); 51 $('#' + o.dirIDprefix + 0).find('a').click(function(){return false;}).mousedown(function(){return false;});52 $('#' + o.dirIDprefix + 0).find('a').bind("contextmenu",function(e){53 e.preventDefault();54 showContextMenu (this);55 });56 57 if (o.data != null) {58 for (var i = 0; i < o.data.length ; i++) {59 strHTML = '<ul class="jqueryFileTree"><li id="' + o.dirIDprefix + o.data[i].id + '" class="directory collapsed"><a href="#" rel="' + o.data[i].name + '">' + o.data[i].name + '</a></li></ul>';60 61 if (o.data[i].parentID > 0){62 $('#' + o.dirIDprefix + o.data[i].parentID).append(strHTML);63 $('#' + o.dirIDprefix + o.data[i].id).parent().css('display','none');64 }65 else {66 67 $('#' + o.dirIDprefix + 0).append(strHTML);68 }69 70 $('#' + o.dirIDprefix + o.data[i].id).find('a').click(function(){openDir(this);return false;}).mousedown(function(){return false;});71 $('#' + o.dirIDprefix + o.data[i].id).find('a').bind("contextmenu",function(e){72 e.preventDefault();73 showContextMenu (this);74 });75 };76 }77 };78 79 function openDir (o) {80 if( $(o).parent().hasClass('collapsed') ) {81 $(o).parent().find('> UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });82 $(o).parent().removeClass('collapsed').addClass('expanded');83 }84 else if( $(o).parent().hasClass('expanded') ) {85 $(o).parent().find('> UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });86 $(o).parent().removeClass('expanded').addClass('collapsed');87 }88 selectDir(o);89 73 } 90 74 91 function selectDir(o) { 92 $('.currentDir').removeClass('currentDir'); 93 $(o).addClass('currentDir'); 75 //bind event on new node 76 $('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this)}); 77 $('#' + o.dirIDprefix + d.id).find('a').bind("contextmenu",function(e){ 78 e.preventDefault(); 79 showContextMenu (this); 80 }); 81 82 if (d.customEvent != null) 83 $('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)}); 84 85 return $('#' + o.dirIDprefix + d.id); 86 } 87 //END - Create a node of Tree 88 89 var deleteNode = function (n) { 90 if (!$(n).parent().hasClass('home')) 91 $(n).remove(); 92 } 93 94 var isHome = function (n) { 95 return $(n).parent().hasClass('home'); 96 } 97 98 var countNodeChild = function (n) { 99 var parent = $(n).parent(); 100 return $(parent).find('UL').size(); 101 } 102 103 var openDir = function (o) { 104 if( $(o).parent().hasClass('collapsed') ) { 105 $(o).parent().find('> UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing }); 106 $(o).parent().removeClass('collapsed').addClass('expanded'); 94 107 } 108 else if( $(o).parent().hasClass('expanded') ) { 109 $(o).parent().find('> UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); 110 $(o).parent().removeClass('expanded').addClass('collapsed'); 111 } 112 selectDir(o); 113 } 95 114 96 function showContextMenu (n) { 97 alert ('showContextMenu on ' + $(n).text()); 98 }; 115 var selectDir = function (c) { 116 $('.currentDir').removeClass('currentDir'); 117 $(c).addClass('currentDir'); 118 } 99 119 120 var showContextMenu = function (n) { 121 alert ('showContextMenu on ' + $(n).text()); 122 }; 100 123 124 loadTree(); 125 // END - PRIVATE methods 101 126 102 loadTree();103 });104 127 105 128 this.expandAll = function() { … … 107 130 }; 108 131 109 this.getCurrentDir = function() {132 this.getCurrentDirName = function() { 110 133 return $(o.container).find('.currentDir').attr('rel'); 111 134 }; 112 135 113 this.createDir = function() { 114 /** 115 * 1. Send request create directory to server 116 * 2. Get ID of new directory from server 117 * 3. Create node of tree 118 */ 136 this.getCurrentDir = function() { 137 return $(o.container).find('.currentDir'); 138 }; 119 139 140 this.createDir = function(c) { 120 141 121 $.post(o.script,{action:"create_dir",parentID:pid}, function (data) { 142 var cid = $(c).parent().attr('id'); 143 var pid = cid.substring(o.dirIDprefix.length, cid.length); 122 144 145 var dirName = prompt("Please enter new directory name", ""); 146 147 $.post(o.script,{action:"create_dir",parentID:pid,name:dirName}, function (data) { 148 if (!data) return; 149 var parsedData = $.parseJSON(data); 150 151 createNode({ 152 id: parsedData.id, 153 name: parsedData.name, 154 curentNode: c, 155 hidden: false, 156 //customEvent: {eventName: "click", eventTrigger: function(o){alert('This click!')}} 123 157 }); 158 }); 159 } 160 161 this.deleteDir = function (c) { 162 var childExisted = (countNodeChild(c) > 0) ? true:false; 163 var confirmDel = false; 164 var confirmChild = true; 165 166 if (isHome(c)) return; 167 168 confirmDel = confirm('Are you sure you want to delete this Directory?'); 169 170 if (childExisted > 0 && confirmDel) 171 confirmChild = confirm('This node has childs, you still want to delete it?'); 172 173 if (confirmDel && confirmChild) deleteNode(c); 174 124 175 } 125 176 … … 130 181 return this.initialize(); 131 182 }, 132 133 134 /*violetGrid: function(o, h) {135 136 }*/137 183 }); 138 184 -
pro-bachkim-filespace/violetspace-prototype/getdata.php
r1 r4 22 22 ); 23 23 24 if (count($_POST) == 0) { 24 if (isset($_POST['action'])) { 25 if ($_POST['action'] == 'create_dir') { 26 $newID = 9; 27 $aryNewDir = array('id' => $newID, 'name' => $_POST['name'], 'parentID' => $_POST['parentID']); 28 echo json_encode($aryNewDir); 29 } 30 } 31 else { 25 32 echo json_encode($aryDir); 26 33 } -
pro-bachkim-filespace/violetspace-prototype/index.html
r1 r4 36 36 <div class="btn-group"> 37 37 <button id="btnNewFolder" class="btn btn-success" title="Tạo thư mục má»i"><i class="icon-folder-close"></i></button> 38 <button id="btnDel" class="btn btn-success" title="Xóa"><i class="icon-eraser"></i></button> 38 39 <button class="btn btn-success" title="Sao chép"><i class="icon-copy"></i></button> 39 40 <button class="btn btn-success" title="Cắt"><i class="icon-cut"></i></button>
Note: See TracChangeset
for help on using the changeset viewer.