2 * @class FeedViewer.FeedWindow
3 * @extends Ext.window.Window
5 * Shows a dialog for creating and validating a new feed.
8 * Create a new Feed Window
9 * @param {Object} config The config object
12 Ext.define('FeedViewer.FeedWindow', {
13 extend: 'Ext.window.Window',
15 alias: 'widget.feedwindow',
20 ['http://rss.cnn.com/rss/edition.rss', 'CNN Top Stories'],
21 ['http://sports.espn.go.com/espn/rss/news', 'ESPN Top News'],
22 ['http://news.google.com/news?ned=us&topic=t&output=rss', 'Sci/Tech - Google News'],
23 ['http://rss.news.yahoo.com/rss/software', 'Yahoo Software News']
26 initComponent: function(){
30 * @param {FeedViewer.FeedWindow} this
31 * @param {String} title
33 * @param {String} description
38 this.form = Ext.create('widget.form', {
39 bodyPadding: '12 10 10',
45 fieldLabel: 'Enter the URL of the feed to add',
49 store: this.defaultFeeds,
50 getInnerTpl: function(){
51 return '<div class="feed-picker-url">{field1}</div><div class="feed-picker-title">{field2}</div>';
65 handler: this.onAddClick
73 this.callParent(arguments);
77 * React to the add button being clicked.
80 onAddClick: function(){
81 var url = this.form.getComponent('feed').getValue();
82 this.form.setLoading({
83 msg: 'Validating feed...'
86 url: 'feed-proxy.php',
90 success: this.validateFeed,
91 failure: this.markInvalid,
97 * React to the feed validation passing
99 * @param {Object} response The response object
101 validateFeed: function(response){
102 this.form.setLoading(false);
104 var dq = Ext.DomQuery,
105 url = this.form.getComponent('feed').getValue(),
111 xml = response.responseXML;
112 channel = xml.getElementsByTagName('channel')[0];
114 title = dq.selectValue('title', channel, url);
115 this.fireEvent('feedvalid', this, title, url);
126 * React to the feed validation failing
129 markInvalid: function(){
130 this.form.setLoading(false);
131 this.form.getComponent('feed').markInvalid('The URL specified is not a valid RSS2 feed.');