FeedViewer.js
2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* @class FeedViewer.FeedViewer
* @extends Ext.container.Viewport
*
* The main FeedViewer application
*
* @constructor
* Create a new Feed Viewer app
* @param {Object} config The config object
*/
Ext.define('FeedViewer.App', {
extend: 'Ext.container.Viewport',
initComponent: function(){
Ext.define('Feed', {
extend: 'Ext.data.Model',
fields: ['title', 'url']
});
Ext.define('FeedItem', {
extend: 'Ext.data.Model',
fields: ['title', 'author', {
name: 'pubDate',
type: 'date'
}, 'link', 'description', 'content']
});
Ext.apply(this, {
layout: {
type: 'border',
padding: 5
},
items: [this.createFeedPanel(), this.createFeedInfo()]
});
this.callParent(arguments);
},
/**
* Create the list of fields to be shown on the left
* @private
* @return {FeedViewer.FeedPanel} feedPanel
*/
createFeedPanel: function(){
this.feedPanel = Ext.create('widget.feedpanel', {
region: 'west',
collapsible: true,
width: 225,
floatable: false,
split: true,
minWidth: 175,
feeds: [{
title: 'Sencha Blog',
url: 'http://feeds.feedburner.com/extblog'
}, {
title: 'Sencha Forums',
url: 'http://sencha.com/forum/external.php?type=RSS2'
}, {
title: 'Ajaxian',
url: 'http://feeds.feedburner.com/ajaxian'
}],
listeners: {
scope: this,
feedselect: this.onFeedSelect
}
});
return this.feedPanel;
},
/**
* Create the feed info container
* @private
* @return {FeedViewer.FeedInfo} feedInfo
*/
createFeedInfo: function(){
this.feedInfo = Ext.create('widget.feedinfo', {
region: 'center',
minWidth: 300
});
return this.feedInfo;
},
/**
* Reacts to a feed being selected
* @private
*/
onFeedSelect: function(feed, title, url){
this.feedInfo.addFeed(title, url);
}
});