2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 FeedPanel = function() {
\r
10 FeedPanel.superclass.constructor.call(this, {
\r
24 root: new Ext.tree.TreeNode('Feed Viewer'),
\r
25 collapseFirst:false,
\r
30 handler: this.showWindow,
\r
34 iconCls:'delete-icon',
\r
36 handler: function(){
\r
37 var s = this.getSelectionModel().getSelectedNode();
\r
39 this.removeFeed(s.attributes.url);
\r
46 this.feeds = this.root.appendChild(
\r
47 new Ext.tree.TreeNode({
\r
54 this.getSelectionModel().on({
\r
55 'beforeselect' : function(sm, node){
\r
56 return node.isLeaf();
\r
58 'selectionchange' : function(sm, node){
\r
60 this.fireEvent('feedselect', node.attributes);
\r
62 this.getTopToolbar().items.get('delete').setDisabled(!node);
\r
67 this.addEvents({feedselect:true});
\r
69 this.on('contextmenu', this.onContextMenu, this);
\r
72 Ext.extend(FeedPanel, Ext.tree.TreePanel, {
\r
74 onContextMenu : function(node, e){
\r
75 if(!this.menu){ // create context menu on first right click
\r
76 this.menu = new Ext.menu.Menu({
\r
80 iconCls:'load-icon',
\r
84 this.ctxNode.select();
\r
88 iconCls:'delete-icon',
\r
91 this.ctxNode.ui.removeClass('x-node-ctx');
\r
92 this.removeFeed(this.ctxNode.attributes.url);
\r
93 this.ctxNode = null;
\r
98 handler: this.showWindow,
\r
102 this.menu.on('hide', this.onContextHide, this);
\r
105 this.ctxNode.ui.removeClass('x-node-ctx');
\r
106 this.ctxNode = null;
\r
109 this.ctxNode = node;
\r
110 this.ctxNode.ui.addClass('x-node-ctx');
\r
111 this.menu.items.get('load').setDisabled(node.isSelected());
\r
112 this.menu.showAt(e.getXY());
\r
116 onContextHide : function(){
\r
118 this.ctxNode.ui.removeClass('x-node-ctx');
\r
119 this.ctxNode = null;
\r
123 showWindow : function(btn){
\r
125 this.win = new FeedWindow();
\r
126 this.win.on('validfeed', this.addFeed, this);
\r
128 this.win.show(btn);
\r
131 selectFeed: function(url){
\r
132 this.getNodeById(url).select();
\r
135 removeFeed: function(url){
\r
136 var node = this.getNodeById(url);
\r
139 Ext.fly(node.ui.elNode).ghost('l', {
\r
140 callback: node.remove, scope: node, duration: .4
\r
145 addFeed : function(attrs, inactive, preventAnim){
\r
146 var exists = this.getNodeById(attrs.url);
\r
150 exists.ui.highlight();
\r
155 iconCls: 'feed-icon',
\r
160 var node = new Ext.tree.TreeNode(attrs);
\r
161 this.feeds.appendChild(node);
\r
164 Ext.fly(node.ui.elNode).slideIn('l', {
\r
165 callback: node.select, scope: node, duration: .4
\r
174 // prevent the default context menu when you miss the node
\r
175 afterRender : function(){
\r
176 FeedPanel.superclass.afterRender.call(this);
\r
177 this.el.on('contextmenu', function(e){
\r
178 e.preventDefault();
\r