Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / key-feed-viewer / viewer / FeedViewer.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 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.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @class FeedViewer.FeedViewer
17  * @extends Ext.container.Viewport
18  *
19  * The main FeedViewer application
20  * 
21  * @constructor
22  * Create a new Feed Viewer app
23  * @param {Object} config The config object
24  */
25 Ext.define('FeedViewer.App', {
26     extend: 'Ext.container.Viewport',
27
28     initComponent: function(){
29
30         Ext.define('Feed', {
31             extend: 'Ext.data.Model',
32             fields: ['title', 'url']
33         });
34
35         Ext.define('FeedItem', {
36             extend: 'Ext.data.Model',
37             fields: ['title', 'author', {
38                 name: 'pubDate',
39                 type: 'date'
40             }, 'link', 'description', 'content']
41         });
42
43         Ext.apply(this, {
44             layout: 'border',
45             padding: 5,
46             items: [this.createFeedPanel(), this.createFeedInfo()]
47         });
48         this.callParent(arguments);
49     },
50
51     /**
52      * Create the list of fields to be shown on the left
53      * @private
54      * @return {FeedViewer.FeedPanel} feedPanel
55      */
56     createFeedPanel: function(){
57         this.feedPanel = Ext.create('widget.feedpanel', {
58             region: 'west',
59             collapsible: true,
60             width: 225,
61             floatable: false,
62             split: true,
63             minWidth: 175,
64             feeds: [{
65                 title: 'Sencha Blog',
66                 url: 'http://feeds.feedburner.com/extblog'
67             }, {
68                 title: 'Sencha Forums',
69                 url: 'http://sencha.com/forum/external.php?type=RSS2'
70             }, {
71                 title: 'Ajaxian',
72                 url: 'http://feeds.feedburner.com/ajaxian'
73             }],
74             listeners: {
75                 scope: this,
76                 feedselect: this.onFeedSelect
77             }
78         });
79         return this.feedPanel;
80     },
81     
82     /**
83      * Create the feed info container
84      * @private
85      * @return {FeedViewer.FeedInfo} feedInfo
86      */
87     createFeedInfo: function(){
88         this.feedInfo = Ext.create('widget.feedinfo', {
89             region: 'center',
90             minWidth: 300
91         });
92         return this.feedInfo;
93     },
94     
95     /**
96      * Reacts to a feed being selected
97      * @private
98      */
99     onFeedSelect: function(feed, title, url){
100         this.feedInfo.addFeed(title, url);
101     }
102 });
103