X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..refs/heads/master:/examples/key-feed-viewer/viewer/FeedInfo.js diff --git a/examples/key-feed-viewer/viewer/FeedInfo.js b/examples/key-feed-viewer/viewer/FeedInfo.js new file mode 100644 index 00000000..8ece72e8 --- /dev/null +++ b/examples/key-feed-viewer/viewer/FeedInfo.js @@ -0,0 +1,108 @@ +/* + +This file is part of Ext JS 4 + +Copyright (c) 2011 Sencha Inc + +Contact: http://www.sencha.com/contact + +GNU General Public License Usage +This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. + +*/ +/** + * @class FeedViewer.FeedInfo + * @extends Ext.tab.Panel + * + * A container class for showing a series of feed details + * + * @constructor + * Create a new Feed Info + * @param {Object} config The config object + */ +Ext.define('FeedViewer.FeedInfo', { + + extend: 'Ext.tab.Panel', + alias: 'widget.feedinfo', + + maxTabWidth: 230, + border: false, + + initComponent: function() { + this.tabBar = { + border: true + }; + + this.callParent(); + }, + + /** + * Add a new feed + * @param {String} title The title of the feed + * @param {String} url The url of the feed + */ + addFeed: function(title, url){ + var active = this.items.first(); + if (!active) { + active = this.add({ + xtype: 'feeddetail', + title: title, + url: url, + closable: false, + listeners: { + scope: this, + opentab: this.onTabOpen, + openall: this.onOpenAll, + rowdblclick: this.onRowDblClick + } + }); + } else { + active.loadFeed(url); + active.tab.setText(title); + } + this.setActiveTab(active); + }, + + /** + * Listens for a new tab request + * @private + * @param {FeedViewer.FeedPost} The post + * @param {Ext.data.Model} model The model + */ + onTabOpen: function(post, rec){ + var item = this.add({ + inTab: true, + xtype: 'feedpost', + title: rec.get('title'), + closable: true, + data: rec.data, + active: rec + }); + item.tab.setClosable(true); + this.setActiveTab(item); + }, + + /** + * Listens for a row dblclick + * @private + * @param {FeedViewer.Detail} detail The detail + * @param {Ext.data.Model} model The model + */ + onRowDblClick: function(info, rec){ + this.onTabOpen(null, rec); + }, + + /** + * Listens for the open all click + * @private + * @param {FeedViewer.FeedDetail} + */ + onOpenAll: function(detail){ + var items = detail.getFeedData(); + Ext.each(items, function(rec){ + this.onTabOpen(null, rec); + }, this); + } +});