3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
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.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class FeedViewer.FeedWindow
17 * @extends Ext.window.Window
19 * Shows a dialog for creating and validating a new feed.
22 * Create a new Feed Window
23 * @param {Object} config The config object
26 Ext.define('FeedViewer.FeedWindow', {
27 extend: 'Ext.window.Window',
29 alias: 'widget.feedwindow',
34 ['http://rss.cnn.com/rss/edition.rss', 'CNN Top Stories'],
35 ['http://sports.espn.go.com/espn/rss/news', 'ESPN Top News'],
36 ['http://news.google.com/news?ned=us&topic=t&output=rss', 'Sci/Tech - Google News'],
37 ['http://rss.news.yahoo.com/rss/software', 'Yahoo Software News']
40 initComponent: function(){
44 * @param {FeedViewer.FeedWindow} this
45 * @param {String} title
47 * @param {String} description
52 this.form = Ext.create('widget.form', {
53 bodyPadding: '12 10 10',
59 fieldLabel: 'Enter the URL of the feed to add',
63 store: this.defaultFeeds,
64 getInnerTpl: function(){
65 return '<div class="feed-picker-url">{field1}</div><div class="feed-picker-title">{field2}</div>';
79 handler: this.onAddClick
87 this.callParent(arguments);
91 * React to the add button being clicked.
94 onAddClick: function(){
95 var url = this.form.getComponent('feed').getValue();
96 this.form.setLoading({
97 msg: 'Validating feed...'
100 url: 'feed-proxy.php',
104 success: this.validateFeed,
105 failure: this.markInvalid,
111 * React to the feed validation passing
113 * @param {Object} response The response object
115 validateFeed: function(response){
116 this.form.setLoading(false);
118 var dq = Ext.DomQuery,
119 url = this.form.getComponent('feed').getValue(),
125 xml = response.responseXML;
126 channel = xml.getElementsByTagName('channel')[0];
128 title = dq.selectValue('title', channel, url);
129 this.fireEvent('feedvalid', this, title, url);
140 * React to the feed validation failing
143 markInvalid: function(){
144 this.form.setLoading(false);
145 this.form.getComponent('feed').markInvalid('The URL specified is not a valid RSS2 feed.');