Ignore:
Timestamp:
Jul 1, 2014 9:23:18 AM (11 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-bachkim-filespace/sourcecode/assets/js/vstree.js

    r16 r17  
    88                        if( o.host == undefined ) o.host = 'http://localhost/';
    99                        if( o.script == undefined ) o.script = 'ajax/privatecontent/getcontent';
    10                         if( o.container == undefined ) o.container = $(this);
     10                        if( o.container == undefined ) o.container = null;
    1111                        if( o.dirIDprefix == undefined ) o.dirIDprefix = 'vsdir_';
    1212
     
    1818                        if( o.directoryTreeData == undefined ) o.directoryTreeData = null;
    1919                        if( o.grid == undefined ) o.grid = null;
     20                        if( o.contextmenuON == undefined ) o.contextmenuON = true;
    2021                       
    2122                        var currentObj = {};
     23                        if ( currentObj.type == undefined ) currentObj.type = 'directory';
    2224                       
    2325                        // PRIVATE methods
     
    4951
    5052                        var renderTree = function  (parseData) {
     53                                $(o.container).find ('.vstree').remove();
     54                               
    5155                                o.directoryTreeData = parseData;                               
    5256                                var directoryData = parseData.DIRECTORIES;
     
    5660                                        name:o.homeDirNameDisplay,
    5761                                });
    58 
     62                               
    5963                                selectDir($(homeNode).find('> A'));
    6064                                if (directoryData != null) {
     
    6367                                                        id: directoryData[i].id,
    6468                                                        name: directoryData[i].name,
    65                                                         curentNode: $('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'),
     69                                                        currentNode: $(o.container).find('#' + o.dirIDprefix + directoryData[i].parentID).find('> A'),
    6670                                                        hidden: (directoryData[i].parentID > 0) ? true : false
    6771                                                })
     
    7579                                if( d.id == undefined ) d.id = null;
    7680                                if( d.name == undefined ) d.name = null;
    77                                 if( d.curentNode == undefined ) d.curentNode = null;
     81                                if( d.currentNode == undefined ) d.currentNode = null;
    7882                                if( d.hidden == undefined ) d.hidden = true;
    7983                                if( d.clickEvent == undefined ) d.clickEvent = openDir;
     
    8589                                        disabledItemsList = ['cut','delete'];
    8690                               
    87                                 if (d.curentNode != null) {
     91                                if (d.currentNode != null) {
    8892                                        var strHTML = '<ul class="vstree"><li id="' + o.dirIDprefix + d.id + '" class="directory collapsed"><a href="#" rel="' + d.name + '">' + d.name + '</a></li></ul>';
    8993
    90                                         $(d.curentNode).parent().append(strHTML);
     94                                        $(d.currentNode).parent().append(strHTML);
    9195                                        if (d.hidden == true)
    92                                                 $('#' + o.dirIDprefix + d.id).parent().css('display','none');
     96                                                $(o.container).find('#' + o.dirIDprefix + d.id).parent().css('display','none');
    9397                                       
    9498                                }else if (d.id == 0){
     
    103107                                        newdir.id = d.id;
    104108                                        newdir.name = d.name;
    105                                         newdir.parentID = $(d.curentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.curentNode).parent().attr('id').length);
     109                                        newdir.parentID = $(o.container).find(d.currentNode).parent().attr('id').substring(o.dirIDprefix.length, $(d.currentNode).parent().attr('id').length);
    106110                                        o.directoryTreeData.DIRECTORIES.push(newdir);
    107111                                        sendtoGrid();
     
    109113                               
    110114                                //bind event on new node
    111                                 $('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;});
    112                                
    113                                 $('#' + o.dirIDprefix + d.id).find('a').contextMenu({
    114                                         menu: 'treeMenu',
    115                                         disabledItems: disabledItemsList
    116                                 }, function(action, el, pos) {
    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                                         }
    128                                 });
     115                                $(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind("click", function(e){d.clickEvent(this);return false;});
     116                               
     117                                if (o.contextmenuON) {
     118                                        $(o.container).find('#' + o.dirIDprefix + d.id).find('a').contextMenu({
     119                                                menu: 'treeMenu',
     120                                                disabledItems: disabledItemsList
     121                                        }, function(action, el, pos) {
     122                                                selectDir(el);
     123                                                switch(action) {
     124                                                        case 'rename':
     125                                                                rename(el);
     126                                                                break;
     127                                                        case 'share':
     128                                                        case 'copy':
     129                                                        case 'cut':
     130                                                                o.grid.showModal(currentObj, action);
     131                                                                break;
     132                                                        default:
     133                                                                break;
     134                                                }
     135                                        });
     136                                }
    129137                               
    130138                                if (d.customEvent != null)
    131                                         $('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)});
    132 
    133                                 return $('#' + o.dirIDprefix + d.id);
     139                                        $(o.container).find('#' + o.dirIDprefix + d.id).find('a').bind(d.customEvent.eventName, function(e){d.customEvent.eventTrigger(this)});
     140
     141                                return $(o.container).find('#' + o.dirIDprefix + d.id);
    134142                        }
    135143                        //END - Create a node of Tree
     
    178186
    179187                        var sendtoGrid = function () {
     188                                if (o.grid == null) return false;
     189                               
    180190                                o.grid.getData({
    181191                                                                directoryTreeData: o.directoryTreeData,
     
    327337                        return this;
    328338                };
     339               
     340                this.getSelectedObj = function () {
     341                        return currentObj;
     342                }
    329343
    330344                        return this.initialize();
Note: See TracChangeset for help on using the changeset viewer.