Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / examples / feed-viewer / FeedPanel.js
index 588a623..8832bbe 100644 (file)
 /*!
 /*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
  */
  */
-FeedPanel = function() {\r
-    FeedPanel.superclass.constructor.call(this, {\r
-        id:'feed-tree',\r
-        region:'west',\r
-        title:'Feeds',\r
-        split:true,\r
-        width: 225,\r
-        minSize: 175,\r
-        maxSize: 400,\r
-        collapsible: true,\r
-        margins:'0 0 5 5',\r
-        cmargins:'0 5 5 5',\r
-        rootVisible:false,\r
-        lines:false,\r
-        autoScroll:true,\r
-        root: new Ext.tree.TreeNode('My Feeds'),\r
-        collapseFirst:false,\r
-        tbar: [{\r
-            iconCls:'add-feed',\r
-            text:'Add Feed',\r
-            handler: this.showWindow,\r
-            scope: this\r
-        },{\r
-            id:'delete',\r
-            iconCls:'delete-icon',\r
-            text:'Remove',\r
-            handler: function(){\r
-                var s = this.getSelectionModel().getSelectedNode();\r
-                if(s){\r
-                    this.removeFeed(s.attributes.url);\r
-                }\r
-            },\r
-            scope: this\r
-        }]\r
-    });\r
-\r
-    this.feeds = this.root.appendChild(\r
-        new Ext.tree.TreeNode({\r
-            text:'My Feeds',\r
-            cls:'feeds-node',\r
-            expanded:true\r
-        })\r
-    );\r
-\r
-    this.getSelectionModel().on({\r
-        'beforeselect' : function(sm, node){\r
-             return node.isLeaf();\r
-        },\r
-        'selectionchange' : function(sm, node){\r
-            if(node){\r
-                this.fireEvent('feedselect', node.attributes);\r
-            }\r
-            this.getTopToolbar().items.get('delete').setDisabled(!node);\r
-        },\r
-        scope:this\r
-    });\r
-\r
-    this.addEvents({feedselect:true});\r
-\r
-    this.on('contextmenu', this.onContextMenu, this);\r
-};\r
-\r
-Ext.extend(FeedPanel, Ext.tree.TreePanel, {\r
-\r
-    onContextMenu : function(node, e){\r
-        if(!this.menu){ // create context menu on first right click\r
-            this.menu = new Ext.menu.Menu({\r
-                id:'feeds-ctx',\r
-                items: [{\r
-                    id:'load',\r
-                    iconCls:'load-icon',\r
-                    text:'Load Feed',\r
-                    scope: this,\r
-                    handler:function(){\r
-                        this.ctxNode.select();\r
-                    }\r
-                },{\r
-                    text:'Remove',\r
-                    iconCls:'delete-icon',\r
-                    scope: this,\r
-                    handler:function(){\r
-                        this.ctxNode.ui.removeClass('x-node-ctx');\r
-                        this.removeFeed(this.ctxNode.attributes.url);\r
-                        this.ctxNode = null;\r
-                    }\r
-                },'-',{\r
-                    iconCls:'add-feed',\r
-                    text:'Add Feed',\r
-                    handler: this.showWindow,\r
-                    scope: this\r
-                }]\r
-            });\r
-            this.menu.on('hide', this.onContextHide, this);\r
-        }\r
-        if(this.ctxNode){\r
-            this.ctxNode.ui.removeClass('x-node-ctx');\r
-            this.ctxNode = null;\r
-        }\r
-        if(node.isLeaf()){\r
-            this.ctxNode = node;\r
-            this.ctxNode.ui.addClass('x-node-ctx');\r
-            this.menu.items.get('load').setDisabled(node.isSelected());\r
-            this.menu.showAt(e.getXY());\r
-        }\r
-    },\r
-\r
-    onContextHide : function(){\r
-        if(this.ctxNode){\r
-            this.ctxNode.ui.removeClass('x-node-ctx');\r
-            this.ctxNode = null;\r
-        }\r
-    },\r
-\r
-    showWindow : function(btn){\r
-        if(!this.win){\r
-            this.win = new FeedWindow();\r
-            this.win.on('validfeed', this.addFeed, this);\r
-        }\r
-        this.win.show(btn);\r
-    },\r
-\r
-    selectFeed: function(url){\r
-        this.getNodeById(url).select();\r
-    },\r
-\r
-    removeFeed: function(url){\r
-        var node = this.getNodeById(url);\r
-        if(node){\r
-            node.unselect();\r
-            Ext.fly(node.ui.elNode).ghost('l', {\r
-                callback: node.remove, scope: node, duration: .4\r
-            });\r
-        }\r
-    },\r
-\r
-    addFeed : function(attrs, inactive, preventAnim){\r
-        var exists = this.getNodeById(attrs.url);\r
-        if(exists){\r
-            if(!inactive){\r
-                exists.select();\r
-                exists.ui.highlight();\r
-            }\r
-            return;\r
-        }\r
-        Ext.apply(attrs, {\r
-            iconCls: 'feed-icon',\r
-            leaf:true,\r
-            cls:'feed',\r
-            id: attrs.url\r
-        });\r
-        var node = new Ext.tree.TreeNode(attrs);\r
-        this.feeds.appendChild(node);\r
-        if(!inactive){\r
-            if(!preventAnim){\r
-                Ext.fly(node.ui.elNode).slideIn('l', {\r
-                    callback: node.select, scope: node, duration: .4\r
-                });\r
-            }else{\r
-                node.select();\r
-            }\r
-        }\r
-        return node;\r
-    },\r
-\r
-    // prevent the default context menu when you miss the node\r
-    afterRender : function(){\r
-        FeedPanel.superclass.afterRender.call(this);\r
-        this.el.on('contextmenu', function(e){\r
-            e.preventDefault();\r
-        });\r
-    }\r
-});\r
-\r
+FeedPanel = function() {
+    FeedPanel.superclass.constructor.call(this, {
+        id:'feed-tree',
+        region:'west',
+        title:'Feeds',
+        split:true,
+        width: 225,
+        minSize: 175,
+        maxSize: 400,
+        collapsible: true,
+        margins:'0 0 5 5',
+        cmargins:'0 5 5 5',
+        rootVisible:false,
+        lines:false,
+        autoScroll:true,
+        root: new Ext.tree.TreeNode('My Feeds'),
+        collapseFirst:false,
+        tbar: [{
+            iconCls:'add-feed',
+            text:'Add Feed',
+            handler: this.showWindow,
+            scope: this
+        },{
+            id:'delete',
+            iconCls:'delete-icon',
+            text:'Remove',
+            handler: function(){
+                var s = this.getSelectionModel().getSelectedNode();
+                if(s){
+                    this.removeFeed(s.attributes.url);
+                }
+            },
+            scope: this
+        }]
+    });
+
+    this.feeds = this.root.appendChild(
+        new Ext.tree.TreeNode({
+            text:'My Feeds',
+            cls:'feeds-node',
+            expanded:true
+        })
+    );
+
+    this.getSelectionModel().on({
+        'beforeselect' : function(sm, node){
+             return node.isLeaf();
+        },
+        'selectionchange' : function(sm, node){
+            if(node){
+                this.fireEvent('feedselect', node.attributes);
+            }
+            this.getTopToolbar().items.get('delete').setDisabled(!node);
+        },
+        scope:this
+    });
+
+    this.addEvents({feedselect:true});
+
+    this.on('contextmenu', this.onContextMenu, this);
+};
+
+Ext.extend(FeedPanel, Ext.tree.TreePanel, {
+
+    onContextMenu : function(node, e){
+        if(!this.menu){ // create context menu on first right click
+            this.menu = new Ext.menu.Menu({
+                id:'feeds-ctx',
+                items: [{
+                    id:'load',
+                    iconCls:'load-icon',
+                    text:'Load Feed',
+                    scope: this,
+                    handler:function(){
+                        this.ctxNode.select();
+                    }
+                },{
+                    text:'Remove',
+                    iconCls:'delete-icon',
+                    scope: this,
+                    handler:function(){
+                        this.ctxNode.ui.removeClass('x-node-ctx');
+                        this.removeFeed(this.ctxNode.attributes.url);
+                        this.ctxNode = null;
+                    }
+                },'-',{
+                    iconCls:'add-feed',
+                    text:'Add Feed',
+                    handler: this.showWindow,
+                    scope: this
+                }]
+            });
+            this.menu.on('hide', this.onContextHide, this);
+        }
+        if(this.ctxNode){
+            this.ctxNode.ui.removeClass('x-node-ctx');
+            this.ctxNode = null;
+        }
+        if(node.isLeaf()){
+            this.ctxNode = node;
+            this.ctxNode.ui.addClass('x-node-ctx');
+            this.menu.items.get('load').setDisabled(node.isSelected());
+            this.menu.showAt(e.getXY());
+        }
+    },
+
+    onContextHide : function(){
+        if(this.ctxNode){
+            this.ctxNode.ui.removeClass('x-node-ctx');
+            this.ctxNode = null;
+        }
+    },
+
+    showWindow : function(btn){
+        if(!this.win){
+            this.win = new FeedWindow();
+            this.win.on('validfeed', this.addFeed, this);
+        }
+        this.win.show(btn);
+    },
+
+    selectFeed: function(url){
+        this.getNodeById(url).select();
+    },
+
+    removeFeed: function(url){
+        var node = this.getNodeById(url);
+        if(node){
+            node.unselect();
+            Ext.fly(node.ui.elNode).ghost('l', {
+                callback: node.remove, scope: node, duration: .4
+            });
+        }
+    },
+
+    addFeed : function(attrs, inactive, preventAnim){
+        var exists = this.getNodeById(attrs.url);
+        if(exists){
+            if(!inactive){
+                exists.select();
+                exists.ui.highlight();
+            }
+            return;
+        }
+        Ext.apply(attrs, {
+            iconCls: 'feed-icon',
+            leaf:true,
+            cls:'feed',
+            id: attrs.url
+        });
+        var node = new Ext.tree.TreeNode(attrs);
+        this.feeds.appendChild(node);
+        if(!inactive){
+            if(!preventAnim){
+                Ext.fly(node.ui.elNode).slideIn('l', {
+                    callback: node.select, scope: node, duration: .4
+                });
+            }else{
+                node.select();
+            }
+        }
+        return node;
+    },
+
+    // prevent the default context menu when you miss the node
+    afterRender : function(){
+        FeedPanel.superclass.afterRender.call(this);
+        this.el.on('contextmenu', function(e){
+            e.preventDefault();
+        });
+    }
+});
+
 Ext.reg('appfeedpanel', FeedPanel); 
\ No newline at end of file
 Ext.reg('appfeedpanel', FeedPanel); 
\ No newline at end of file