-/*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.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
-Ext.reg('appfeedpanel', FeedPanel);
\ No newline at end of file