Changeset 16 for pro-bachkim-filespace


Ignore:
Timestamp:
Jun 26, 2014 5:37:23 PM (11 years ago)
Author:
dungnv
Message:
 
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  
    6363                echo json_encode($aryChild);
    6464        }
     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        }
    6576
    6677}
  • pro-bachkim-filespace/sourcecode/application/modules/ajax/models/directory_model.php

    r12 r16  
    154154                if (file_exists($file) && count($aryDataSet) > 0) {
    155155                        $h = fopen ($file, $flag);
    156                         foreach ($aryDataSet as $key => $line) {
     156                        foreach ($aryDataSet as $key => $aryTmp) {
    157157                                $line = implode(',',$aryTmp);
    158                                 fwrite($line."\n", $h);
     158                                fwrite($h, $line."\n");
    159159                        }
    160160                        fclose ($h);
     
    176176        }
    177177       
     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       
    178197}
  • pro-bachkim-filespace/sourcecode/application/modules/filemanager/views/main.php

    r10 r16  
    2525                                <button id="btnDel" class="btn btn-success" title="Xóa"><i class="icon-eraser"></i></button>
    2626                                <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>
    2929                        </div>
    3030                        <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?>
    215<script type="text/javascript">
    226        window.jQuery || document.write("<script src='assets/js/jquery/jquery-1.11.1.min.js'>"+"<"+"/script>");
     
    2610        if("ontouchend" in document) document.write("<script src='assets/js/jquery/jquery.mobile.custom.min.js'>"+"<"+"/script>");
    2711</script>
     12
    2813<script src="assets/js/bootstrap/bootstrap.min.js"></script>
     14<script src="assets/js/bootstrap/bootbox.min.js"></script>
    2915<script src="assets/js/jquery/jquery-ui-1.10.4.min.js"></script>
    3016<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>
    3218<script src="assets/js/vsgrid.js"></script>
    3319<script src="assets/js/vstree.js"></script>
  • pro-bachkim-filespace/sourcecode/assets/css/space/style.css

    r15 r16  
    22@import "../bootstrap/bootstrap.min.css";
    33@import "../jquery/jquery-ui-1.10.4.min.css";
    4 /* @import "../jquery/jquery.contextMenu.css"; */
    54@import "../jquery/jquery.contextmenu_new.css";
    65@import "../font-awesome.min.css";
     
    118117   background: url("../../images/resize.png") no-repeat scroll center center #F5F5F5;
    119118   border-left: 1px solid #E5E5E5;
    120    border-right: 1px solid #E5E5E5;
     119   border-right: 1px solid #E5E5E5;1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    121120   width: 5px;
    122121}
     
    133132        border-radius: 0 !important;
    134133}
    135 
  • pro-bachkim-filespace/sourcecode/assets/css/space/vsgrid.css

    r15 r16  
    3030        /*background: #BDF;*/
    3131        background: #5eaee5;
     32}
     33
     34UL.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;
    3242}
    3343
  • pro-bachkim-filespace/sourcecode/assets/js/vsgrid.js

    r15 r16  
    88                        if( o.directoryTreeData == undefined ) o.directoryTreeData = null;
    99                        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 = {};
    1017                       
    1118                        var createNode = function (d) {
     
    3340                                $(o.container).append(strHTML);
    3441
    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                               
    3644                                $('div[rel="id:'+ d.id +'"]').contextMenu({
    3745                                        menu: 'gridMenu',
    3846                                        disabledItems: disabledItemsList
    3947                                }, function(action, el, pos) {
    40                                
     48                                        itemClick(el);
    4149                                        switch(action) {
    4250                                                case 'rename':
    43                                                         itemClick(el);
    4451                                                        rename(el);
     52                                                        break;
     53                                                case 'share':
     54                                                        showShareModal(currentObj);
     55                                                        break;
     56                                                case 'copy':
     57                                                        showCopyModal();
     58                                                        break;
     59                                                case 'cut':
     60                                                        showMoveModal();
    4561                                                        break;
    4662                                                default:
     
    5268                       
    5369                        var keyboardRename = function () {
    54                                 $(document).keypress( function(e) {
     70                                $(document).bind('keydown','keypress', function(e) {
    5571                                        var selectedItem = $('.selector.selected').parent();
     72                                       
    5673                                        switch( e.keyCode ) {
    5774                                                case 113:
    5875                                                        rename(selectedItem);
    5976                                                        break;
    60                                                 case 32:
     77                                                case 27:
    6178                                                        cancelRename(selectedItem);
    6279                                                        break;
     
    6481                                                        break;
    6582                                        }
    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');
    68101                        }
    69102
     
    78111                                $(i).find('.selector').removeClass('unselected');
    79112                                $(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);
    80120                        }
    81121
     
    95135                                        });
    96136                                }
    97 
     137                               
    98138                                for (var i = 0 ; i < childFile.length; i++) {
    99139                                        if (childFile[i].parentID != curentDirID) continue;
     
    105145                                        });
    106146                                }
     147                               
     148                                keyboardRename();
    107149                        }
    108150                       
    109151                        var rename = function (e) {
    110152                                var nameObj = $(e).find('.file-name');
    111                                 var oldName = $(nameObj).text();
    112153                                var editor = document.createElement ('INPUT');
    113154                                editor.type = 'text';
    114155                                editor.className = 'rename';
    115                                 editor.value = oldName;
    116156                               
    117157                                $(nameObj).text('');
    118158                                $(nameObj).append(editor);
     159                               
     160                                $(editor).attr('value', currentObj.name); 
    119161                                editor.focus();
    120162                                $(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                                });
    121177                        }
    122178                       
    123179                        var cancelRename = function (e) {
    124                                 var oldName = $(e).find('INPUT.rename').attr('value');
    125180                                $(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                                }
    128222                        }
    129223
     
    133227                                o.dirIDprefix = data.dirIDprefix
    134228                                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                                }
    136243                        }
    137244
  • pro-bachkim-filespace/sourcecode/assets/js/vstree.js

    r15 r16  
    1919                        if( o.grid == undefined ) o.grid = null;
    2020                       
     21                        var currentObj = {};
     22                       
    2123                        // PRIVATE methods
    2224                        var sendCommand = function (p) {
     
    4749
    4850                        var renderTree = function  (parseData) {
    49 
    5051                                o.directoryTreeData = parseData;                               
    5152                                var directoryData = parseData.DIRECTORIES;
     
    8081                                if( d.addToJSONData == undefined ) d.addToJSONData = false;
    8182                               
     83                                var disabledItemsList = null;
     84                                if (d.name == o.homeDirNameDisplay)
     85                                        disabledItemsList = ['cut','delete'];
     86                               
    8287                                if (d.curentNode != null) {
    8388                                        var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>';
     
    107112                               
    108113                                $('#' + o.dirIDprefix + d.id).find('a').contextMenu({
    109                                         menu: 'treeMenu'
     114                                        menu: 'treeMenu',
     115                                        disabledItems: disabledItemsList
    110116                                }, 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                                        }
    117128                                });
    118129                               
     
    154165                                $('.currentDir').removeClass('currentDir');
    155166                                $(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                               
    156176                                sendtoGrid();
    157177                        }
     
    165185                        }
    166186
     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                       
    167255                        loadTree();
    168256                        // END - PRIVATE methods
Note: See TracChangeset for help on using the changeset viewer.