Changeset 16
- Timestamp:
- Jun 26, 2014 5:37:23 PM (11 years ago)
- Location:
- pro-bachkim-filespace/sourcecode
- Files:
-
- 10 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-bachkim-filespace/sourcecode/application/modules/ajax/controllers/privatecontent.php
r15 r16 63 63 echo json_encode($aryChild); 64 64 } 65 66 public function rename() { 67 $id = $this->input->post('id',TRUE); 68 $newName = $this->input->post('newname',TRUE); 69 $objectType = $this->input->post('objtype',TRUE); 70 71 $aryData = array(); 72 $aryData['RESULT'] = $this->objDirectory->rename($id, $newName, $objectType);; 73 $aryData['UPDATED'] = array('id' => $id, 'name' => $newName, 'type' => $objectType); 74 echo json_encode($aryData); 75 } 65 76 66 77 } -
pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php
r12 r16 154 154 if (file_exists($file) && count($aryDataSet) > 0) { 155 155 $h = fopen ($file, $flag); 156 foreach ($aryDataSet as $key => $ line) {156 foreach ($aryDataSet as $key => $aryTmp) { 157 157 $line = implode(',',$aryTmp); 158 fwrite($ line."\n", $h);158 fwrite($h, $line."\n"); 159 159 } 160 160 fclose ($h); … … 176 176 } 177 177 178 public function rename ($id, $newName, $type = 'directory') { 179 180 if (!$newName || !$id) return FALSE; 181 $aryObj = $type == 'directory' ? $this->getAllDirectory() : $this->getAllFile(); 182 $dbFile = $type == 'directory' ? $dbFile = 'directory.db' : $dbFile = 'file.db'; 183 184 if (count($aryObj) > 0) { 185 foreach ($aryObj as $key => $obj) { 186 if ($obj['id'] == $id) break; 187 } 188 189 $aryObj[$key]['name'] = $newName; 190 191 return $this->writeDB($dbFile, $aryObj); 192 } 193 194 return FALSE; 195 } 196 178 197 } -
pro-bachkim-filespace/sourcecode/application/modules/filemanager/views/main.php
r10 r16 25 25 <button id="btnDel" class="btn btn-success" title="Xóa"><i class="icon-eraser"></i></button> 26 26 <button id="btnCopy" class="btn btn-success" title="Sao chép"><i class="icon-copy"></i></button> 27 <button id="btnCut" class="btn btn-success" title="Cắt"><i class="icon-cut"></i></button>28 <button id="btnPaste" class="btn btn-success" title="Dán"><i class="icon-paste"></i></button>27 <button id="btnCut" class="btn btn-success" title="Cắt"><i class="icon-cut"></i></button> 28 <button id="btnPaste" class="btn btn-success" title="Dán"><i class="icon-paste"></i></button> 29 29 </div> 30 30 <div class="btn-group"> -
pro-bachkim-filespace/sourcecode/application/views/layout/contextmenu.php
r10 r16 1 <div id="context-menu"> 2 <div></div> 3 </div> 1 <ul id="treeMenu" class="contextMenu"> 2 <li class="share"><a href="#share">Chia sẻ</a></li> 3 <li class="copy separator"><a href="#copy">Sao chép Äến ...</a></li> 4 <li class="cut"><a href="#cut">Di chuyá»n Äến...</a></li> 5 <li class="delete"><a href="#delete">Xóa</a></li> 6 <li class="rename separator"><a href="#rename">Äá»i tên</a></li> 7 </ul> 8 9 <ul id="gridMenu" class="contextMenu"> 10 <li class="open"><a href="#open">Má»</a></li> 11 <li class="preview"><a href="#preview">Xem trưá»c</a></li> 12 <li class="share separator"><a href="#share">Chia sẻ</a></li> 13 <li class="copy separator"><a href="#copy">Sao chép Äến ...</a></li> 14 <li class="cut"><a href="#cut">Di chuyá»n Äến...</a></li> 15 <li class="delete"><a href="#delete">Xóa</a></li> 16 <li class="rename separator"><a href="#rename">Äá»i tên</a></li> 17 </ul> -
pro-bachkim-filespace/sourcecode/application/views/layout/footer.php
r15 r16 1 <ul id="treeMenu" class="contextMenu"> 2 <li class="share"><a href="#share">Chia sẻ</a></li> 3 <li class="cut separator"><a href="#cut">Cắt</a></li> 4 <li class="copy"><a href="#copy">Sao chép</a></li> 5 <li class="paste"><a href="#paste">Dán</a></li> 6 <li class="delete"><a href="#delete">Xóa</a></li> 7 <li class="rename separator"><a href="#rename">Äá»i tên</a></li> 8 </ul> 9 10 <ul id="gridMenu" class="contextMenu"> 11 <li class="open"><a href="#open">Má»</a></li> 12 <li class="preview"><a href="#preview">Xem trưá»c</a></li> 13 <li class="share separator"><a href="#share">Chia sẻ</a></li> 14 <li class="cut separator"><a href="#cut">Cắt</a></li> 15 <li class="copy"><a href="#copy">Sao chép</a></li> 16 <li class="paste"><a href="#paste">Dán</a></li> 17 <li class="delete"><a href="#delete">Xóa</a></li> 18 <li class="rename separator"><a href="#rename">Äá»i tên</a></li> 19 </ul> 20 1 <?php 2 $this->load->view('layout/contextmenu'); 3 $this->load->view('layout/modalform'); 4 ?> 21 5 <script type="text/javascript"> 22 6 window.jQuery || document.write("<script src='assets/js/jquery/jquery-1.11.1.min.js'>"+"<"+"/script>"); … … 26 10 if("ontouchend" in document) document.write("<script src='assets/js/jquery/jquery.mobile.custom.min.js'>"+"<"+"/script>"); 27 11 </script> 12 28 13 <script src="assets/js/bootstrap/bootstrap.min.js"></script> 14 <script src="assets/js/bootstrap/bootbox.min.js"></script> 29 15 <script src="assets/js/jquery/jquery-ui-1.10.4.min.js"></script> 30 16 <script src="assets/js/jquery/jquery.contextMenu.js"></script> 31 <script src="assets/js/jquery/jquery.easing.1.3 "></script>17 <script src="assets/js/jquery/jquery.easing.1.3.js"></script> 32 18 <script src="assets/js/vsgrid.js"></script> 33 19 <script src="assets/js/vstree.js"></script> -
pro-bachkim-filespace/sourcecode/assets/css/space/style.css
r15 r16 2 2 @import "../bootstrap/bootstrap.min.css"; 3 3 @import "../jquery/jquery-ui-1.10.4.min.css"; 4 /* @import "../jquery/jquery.contextMenu.css"; */5 4 @import "../jquery/jquery.contextmenu_new.css"; 6 5 @import "../font-awesome.min.css"; … … 118 117 background: url("../../images/resize.png") no-repeat scroll center center #F5F5F5; 119 118 border-left: 1px solid #E5E5E5; 120 border-right: 1px solid #E5E5E5; 119 border-right: 1px solid #E5E5E5;1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 121 120 width: 5px; 122 121 } … … 133 132 border-radius: 0 !important; 134 133 } 135 -
pro-bachkim-filespace/sourcecode/assets/css/space/vsgrid.css
r15 r16 30 30 /*background: #BDF;*/ 31 31 background: #5eaee5; 32 } 33 34 UL.vstree LI INPUT.rename { 35 width:120px; 36 height: 20px; 37 border: 1px #5eaee5 solid; 38 padding: 0px; 39 text-overflow: initial; 40 font-family: Verdana, sans-serif; 41 font-size: 12px; 32 42 } 33 43 -
pro-bachkim-filespace/sourcecode/assets/js/vsgrid.js
r15 r16 8 8 if( o.directoryTreeData == undefined ) o.directoryTreeData = null; 9 9 if( o.dirIDprefix == undefined ) o.dirIDprefix = null; 10 if( o.host == undefined ) o.host = 'http://localhost/'; 11 12 if( o.sharemodal == undefined ) o.sharemodal = $("#box-shareto"); 13 if( o.copymodal == undefined ) o.copymodal = $("#box-copyto"); 14 if( o.movemodal == undefined ) o.movemodal = $("#box-moveto"); 15 16 var currentObj = {}; 10 17 11 18 var createNode = function (d) { … … 33 40 $(o.container).append(strHTML); 34 41 35 $('div[rel="id:'+ d.id +'"]').bind('click',function(e){itemClick(this)}); 42 $('div[rel="id:'+ d.id +'"]').bind('click',function(e){itemClick(this)}); 43 36 44 $('div[rel="id:'+ d.id +'"]').contextMenu({ 37 45 menu: 'gridMenu', 38 46 disabledItems: disabledItemsList 39 47 }, function(action, el, pos) { 40 48 itemClick(el); 41 49 switch(action) { 42 50 case 'rename': 43 itemClick(el);44 51 rename(el); 52 break; 53 case 'share': 54 showShareModal(currentObj); 55 break; 56 case 'copy': 57 showCopyModal(); 58 break; 59 case 'cut': 60 showMoveModal(); 45 61 break; 46 62 default: … … 52 68 53 69 var keyboardRename = function () { 54 $(document). keypress(function(e) {70 $(document).bind('keydown','keypress', function(e) { 55 71 var selectedItem = $('.selector.selected').parent(); 72 56 73 switch( e.keyCode ) { 57 74 case 113: 58 75 rename(selectedItem); 59 76 break; 60 case 32:77 case 27: 61 78 cancelRename(selectedItem); 62 79 break; … … 64 81 break; 65 82 } 66 return false; 67 }); 83 }); 84 } 85 86 var showShareModal = function (obj) { 87 if (obj.type == undefined || obj.type == null) obj.type = 'directory'; 88 $(o.sharemodal).modal('show'); 89 $(o.sharemodal).find('INPUT#txtSelectedObj').val(obj.name); 90 $(o.sharemodal).find('.modal-header').text('Chia sẻ ' + (obj.type == 'directory'?'thư mục':'file') + ' [' + obj.name + ']'); 91 } 92 93 var showCopyModal = function () { 94 $(o.copymodal).modal('show'); 95 /*$(o.copymodal).find('INPUT#txtSelectedObj').val(currentObj.name); 96 $(o.copymodal).find('.modal-header').text('Chia sẻ ' + (currentObj.type == 'directory'?'thư mục':'file') + ' [' + currentObj.name + ']');*/ 97 } 98 99 var showMoveModal = function () { 100 $(o.movemodal).modal('show'); 68 101 } 69 102 … … 78 111 $(i).find('.selector').removeClass('unselected'); 79 112 $(i).find('.selector').addClass('selected'); 113 114 if ($(i).find('.file-name').text() != '') 115 currentObj.name = $(i).find('.file-name').text(); 116 117 currentObj.id = $(i).attr('rel').substring(3); 118 currentObj.type = $(i).find('>div>div').hasClass('icon-directory') ? 'directory':'file'; 119 console.log(currentObj.type); 80 120 } 81 121 … … 95 135 }); 96 136 } 97 137 98 138 for (var i = 0 ; i < childFile.length; i++) { 99 139 if (childFile[i].parentID != curentDirID) continue; … … 105 145 }); 106 146 } 147 148 keyboardRename(); 107 149 } 108 150 109 151 var rename = function (e) { 110 152 var nameObj = $(e).find('.file-name'); 111 var oldName = $(nameObj).text();112 153 var editor = document.createElement ('INPUT'); 113 154 editor.type = 'text'; 114 155 editor.className = 'rename'; 115 editor.value = oldName;116 156 117 157 $(nameObj).text(''); 118 158 $(nameObj).append(editor); 159 160 $(editor).attr('value', currentObj.name); 119 161 editor.focus(); 120 162 $(editor).select(); 163 $(editor).bind('focusout',function (e) { 164 cancelRename($(this).parent().parent()); 165 }); 166 167 $(editor).bind('keypress',function (e) { 168 var keycode = (e.keyCode ? e.keyCode : e.which); 169 if(keycode == '13'){ 170 completeRename($(this).parent()); 171 } 172 else { 173 174 } 175 e.stopPropagation(); 176 }); 121 177 } 122 178 123 179 var cancelRename = function (e) { 124 var oldName = $(e).find('INPUT.rename').attr('value');125 180 $(e).find('INPUT.rename').remove(); 126 $(e).find('.file-name').text(oldName); 127 181 $(e).find('.file-name').text(currentObj.name); 182 } 183 184 var completeRename = function (e) { 185 186 var postdata = {id:currentObj.id, 187 objtype:currentObj.type, 188 newname:$(e).find('INPUT.rename').val()} 189 sendCommand({ 190 script:'ajax/privatecontent/rename', 191 postdata:postdata, 192 callbackSuccess: function (parsedData) { 193 if (parsedData.RESULT == true) { 194 currentObj.name = parsedData.UPDATED.name; 195 $(e).find('INPUT.rename').remove(); 196 $(e).text(currentObj.name); 197 }else return false; 198 } 199 }); 200 } 201 202 var sendCommand = function (p) { 203 if( p.postdata == undefined ) p.postdata = null; 204 if( p.script == undefined ) p.script = o.script; 205 if( p.callbackSuccess == undefined ) p.callbackSuccess = null; 206 if( p.callbackDone == undefined ) p.callbackDone = null; 207 if( p.callbackFail == undefined ) p.callbackFail = null; 208 if( p.callbackAlways == undefined ) p.callbackAlways = null; 209 210 if (p.script != null) { 211 $.post(o.host + p.script, p.postdata, function (data){ 212 if (data) { 213 parseData = $.parseJSON(data); 214 } 215 216 if (p.callbackSuccess != null) { 217 p.callbackSuccess(parseData); 218 } 219 220 }).done(function() {if (p.callbackDone != null)p.callbackDone(this);}).fail(function() {if (p.callbackFail != null)p.callbackFail(this);}).always(function() {if (p.callbackAlways != null)p.callbackAlways(this);}); 221 } 128 222 } 129 223 … … 133 227 o.dirIDprefix = data.dirIDprefix 134 228 renderGrid(o); 135 keyboardRename(); 229 } 230 231 this.showModal = function (act, obj) { 232 switch( act ) { 233 case 'copy': 234 break; 235 case 'move': 236 break; 237 case 'share': 238 showShareModal(obj); 239 break; 240 default: 241 break; 242 } 136 243 } 137 244 -
pro-bachkim-filespace/sourcecode/assets/js/vstree.js
r15 r16 19 19 if( o.grid == undefined ) o.grid = null; 20 20 21 var currentObj = {}; 22 21 23 // PRIVATE methods 22 24 var sendCommand = function (p) { … … 47 49 48 50 var renderTree = function (parseData) { 49 50 51 o.directoryTreeData = parseData; 51 52 var directoryData = parseData.DIRECTORIES; … … 80 81 if( d.addToJSONData == undefined ) d.addToJSONData = false; 81 82 83 var disabledItemsList = null; 84 if (d.name == o.homeDirNameDisplay) 85 disabledItemsList = ['cut','delete']; 86 82 87 if (d.curentNode != null) { 83 88 var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>'; … … 107 112 108 113 $('#' + o.dirIDprefix + d.id).find('a').contextMenu({ 109 menu: 'treeMenu' 114 menu: 'treeMenu', 115 disabledItems: disabledItemsList 110 116 }, function(action, el, pos) { 111 alert( 112 'Action: ' + action + '\n\n' + 113 'Element text: ' + $(el).text() + '\n\n' + 114 'X: ' + pos.x + ' Y: ' + pos.y + ' (relative to element)\n\n' + 115 'X: ' + pos.docX + ' Y: ' + pos.docY+ ' (relative to document)' 116 ); 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 } 117 128 }); 118 129 … … 154 165 $('.currentDir').removeClass('currentDir'); 155 166 $(c).addClass('currentDir'); 167 168 var cid = $(c).parent().attr('id'); 169 var pid = cid.substring(o.dirIDprefix.length, cid.length); 170 171 currentObj.id = pid; 172 currentObj.name = $(c).attr('rel'); 173 174 keyboardRename (); 175 156 176 sendtoGrid(); 157 177 } … … 165 185 } 166 186 187 var rename = function (o) { 188 var editor = document.createElement ('INPUT'); 189 editor.type = 'text'; 190 editor.className = 'rename'; 191 192 $(o).text(''); 193 $(o).append(editor); 194 195 $(editor).attr('value', currentObj.name); 196 editor.focus(); 197 $(editor).select(); 198 199 $(editor).bind('focusout',function (e) { 200 cancelRename($(o)); 201 }); 202 203 $(editor).bind('keypress',function (e) { 204 var keycode = (e.keyCode ? e.keyCode : e.which); 205 if(keycode == '13'){ 206 completeRename($(o)); 207 } 208 else { 209 210 } 211 e.stopPropagation(); 212 }); 213 } 214 215 var cancelRename = function (o) { 216 $(o).find('>INPUT').remove(); 217 $(o).text(currentObj.name); 218 } 219 220 var completeRename = function (o) { 221 var postdata = {id:currentObj.id, 222 objtype:'directory', 223 newname:$(o).find('INPUT.rename').val()} 224 225 sendCommand({ 226 script:'ajax/privatecontent/rename', 227 postdata:postdata, 228 callbackSuccess: function (parsedData) { 229 if (parsedData.RESULT == true) { 230 currentObj.name = parsedData.UPDATED.name; 231 $(o).find('INPUT.rename').remove(); 232 $(o).text(currentObj.name); 233 }else return false; 234 } 235 }); 236 } 237 238 var keyboardRename = function () { 239 $(document).bind('keydown','keypress', function(e) { 240 var selectedItem = $('.currentDir'); 241 242 switch( e.keyCode ) { 243 case 113: 244 rename(selectedItem); 245 break; 246 case 27: 247 cancelRename(selectedItem); 248 break; 249 default: 250 break; 251 } 252 }); 253 } 254 167 255 loadTree(); 168 256 // END - PRIVATE methods
Note: See TracChangeset
for help on using the changeset viewer.