Pman.Tab.FtpTree.js
authorAlan Knowles <alan@akbkhome.com>
Mon, 12 Apr 2010 09:47:01 +0000 (17:47 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 12 Apr 2010 09:47:01 +0000 (17:47 +0800)
Pman.Tab.FtpTree.js [new file with mode: 0644]

diff --git a/Pman.Tab.FtpTree.js b/Pman.Tab.FtpTree.js
new file mode 100644 (file)
index 0000000..0c79a8a
--- /dev/null
@@ -0,0 +1,286 @@
+//<script type="text/javascript">
+
+Pman.on('beforeload', function()
+{
+    
+    // always loaded by clipping tree
+  
+    
+    Pman.register({
+        modKey : '001-pman-tab-ftptree',
+        module : Pman.Tab.FtpTree,
+        region : 'west',
+        parent : Pman.Tab.FtpTab,
+        name : "Ftp Folders"
+    });
+    
+        
+});
+
+Pman.Tab.FtpTree = {
+    grid : false,
+    panel : false,
+    add : function(parentLayout, region) 
+    {
+         
+        // there is no way this should be called twice!!?!?
+        //if (this.panel) {
+        //    parentLayout.getRegion(region).showPanel(this.panel);
+        //    return;
+        //}
+     
+        
+        this.innerLayout = new Ext.BorderLayout(
+            parentLayout.getEl().createChild({tag:'div'}),
+            {
+               
+                center: {
+                    autoScroll:false,
+                    hideTabs: true
+                }
+            }
+        );
+
+
+
+        this.tab = parentLayout.add(region,  new Ext.NestedLayoutPanel(
+            this.innerLayout, {title: "Ftp Folders", background : true}));
+        
+        var _this = this;
+        this.tab.on('activate', function() {
+            _this.delayedCreate();
+            //_this.paging.onClick('refresh');
+        });
+    },
+    delayedCreate : function()
+    {
+        if (this.grid) {
+            return;
+        }
+        this.innerLayout.beginUpdate();
+        
+        var _this = this;
+        
+        
+        var treePanelEl = this.innerLayout.getEl().createChild({tag:'div'});
+        var tb = new Roo.Toolbar(treePanelEl.createChild({tag:'div'}), [ 
+            
+        
+        
+        ]);
+        var treeEl = treePanelEl.createChild({tag:'div'});
+        
+        this.panel  = this.innerLayout.add('center',  new Roo.ContentPanel(treePanelEl, {
+               
+            fitToFrame: true,
+            fitContainer: true ,
+            autoScroll:false,
+            //autoCreate:true,
+            toolbar: tb, //,
+            //resizeEl:treeEl,
+            listeners : {
+                resize : function (cp, w, h) {
+                    _this.tree.innerCt.setWidth(w);
+                    _this.tree.innerCt.setHeight(h);
+                    _this.tree.innerCt.setStyle('overflow-y', 'auto');
+                }
+            }
+        }));
+
+        
+
+        
+        this.tree = new Roo.tree.TreePanel(treeEl , 
+            {
+                loader: new Roo.tree.TreeLoader({
+                    dataUrl: baseURL + '/Ftp/List.php',
+                    requestMethod: 'GET',
+                    root: 'data',
+                    queryParam : 'name',
+                    baseParams : {
+                        start: 0,
+                        limit : 9999,
+                        person_id : Pman.Login.authUser.id
+                    },
+                    listeners : {
+                        beforeload : function(tl, n) {
+                            //tl.baseParams.is_search = n.attributes.is_search;
+                        }
+                    }
+                    
+                    //,
+                    //uiProviders: {
+                    //    default: Roo.tree.ColumnNodeUI
+                    //}
+                  
+                }),
+                renderer : function (ats) {
+                    return String.format('{0}', ats.name);
+                    
+                },
+                /*
+                rendererTip : function (ats) {
+                    return String.format('{0}', ats.description || ats.name);
+                    
+                },
+                */
+               //dataUrl:'get-nodes.php',
+                
+                // listeners :{
+                //        loadexception : Pman.loadException
+                //    }
+            
+            
+                containerScroll: true,
+            
+                    
+               /* width: 550,
+                height: 300,
+                */
+                rootVisible : false,
+                    
+                 
+                
+                loadMask: true,
+                listeners : {
+                     
+                    rowdblclick : function(g, ri, e) {
+                        //var s = g.getDataSource().getAt(ri).data;
+                      
+                       // _dialog.show(s, refreshPager); 
+                    } 
+
+                }
+                
+                
+            
+        });
+       
+        this.tree.getSelectionModel().on('selectionchange', function(sm, n) {
+           // load file list...
+            Pman.Tab.FtpFiles.reload();
+            
+            
+        });
+
+        // let's make some standard top level ones..
+        var root = new Roo.tree.AsyncTreeNode({
+            //text: 'Saved Searches',
+            name : "/",
+            draggable:false,
+            id: '/'
+        });
+          
+        this.tree.setRootNode(root);
+
+        // render the tree
+        this.tree.render();
+        root.expand();
+
+         
+        var _dialog = Pman.Dialog.ClippingTree;
+        
+        tb.add(
+            {
+               // xtype : 'Menu',
+              //  xns : Roo.menu,
+                text: "Manage Folders",
+                cls: 'x-btn-text-icon',
+                icon: Ext.rootURL + 'images/default/tree/leaf.gif',
+                menu : {
+                    items : [
+                        
+                        {
+                            text: "Add Folder",
+                            cls: 'x-btn-text-icon',
+                            icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
+                            handler : function(){
+                                 
+                            }
+                        }, 
+                        {
+                            text: "Rename Folder",
+                            cls: 'x-btn-text-icon',
+                            icon: Ext.rootURL + 'images/default/tree/leaf.gif',
+                            
+                            handler : function(){
+                            
+                            }
+                        },  
+                        {
+                            text: "Delete Folder" ,
+                            cls: 'x-btn-text-icon',
+                            icon: rootURL + '/Pman/templates/images/trash.gif',
+                            handler : function(){
+                                 
+                                
+                                 
+                            }
+                        }, '-',  
+                        {
+                            text: "Reload Tree" ,
+                            cls: 'x-btn-text-icon',
+                            icon: rootURL + '/Pman/templates/images/view-refresh.gif',
+                            handler : function(){
+                                _this.reloadTree();
+                                
+                            }
+                        }  
+                    ]
+                }
+            }
+        );
+     
+        
+        //this.toolbar = tb;
+        // add stuff to toolbar?
+        this.innerLayout.endUpdate();
+        
+        
+        
+    },
+    deleteNode : function(node)
+    {
+         /*
+        Pman.request({
+            url: baseURL + '/Roo/ClippingTree',
+            method : 'GET',
+            params : {
+                _delete : node.id
+                
+            },
+            success : function(data) {
+                node.parentNode.removeChild(node);
+                
+            },
+            failure : function ()
+            {
+                // do nothing!!!
+                
+            }
+        });
+        */
+    },
+    reloadTree: function()
+    {
+        /*this.tree.root.eachChild(function(n) {
+            n.collapse(false,false);
+            n.leaf = false;
+            while(n.firstChild){
+                n.removeChild(n.firstChild);
+            }
+            n.childrenRendered = false;
+            n.loaded = false;
+            n.leaf = false;
+            n.ui.updateExpandIcon();
+            
+            //n.reload();
+        });
+        */
+    }
+    
+    
+    
+};
+