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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
/*
This file is part of Ext JS 3.4
Copyright (c) 2011-2013 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.
Build date: 2013-04-03 15:07:25
*/
Ext.define('FeedWindow', {
extend: 'Ext.Window',
constructor: function() {
this.feedUrl = new Ext.form.ComboBox({
id: 'feed-url',
fieldLabel: 'Enter the URL of the feed to add',
emptyText: 'http://example.com/blog/feed',
width: 450,
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
triggerAction: 'all',
displayField: 'url',
mode: 'local',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
},
tpl: new Ext.XTemplate(
'<tpl for="."><div class="x-combo-list-item">',
'<em>{url}</em><strong>{text}</strong>',
'<div class="x-clear"></div>',
'</div></tpl>'),
store: new Ext.data.ArrayStore({
fields: ['url', 'text'],
data : this.defaultFeeds
})
});
this.form = new Ext.FormPanel({
labelAlign:'top',
items:this.feedUrl,
border: false,
bodyStyle:'background:transparent;padding:10px;'
});
this.callParent([{
title: 'Add Feed',
iconCls: 'feed-icon',
id: 'add-feed-win',
autoHeight: true,
width: 500,
resizable: false,
plain:true,
modal: true,
y: 100,
autoScroll: true,
closeAction: 'hide',
buttons:[{
text: 'Add Feed!',
handler: this.onFeedAdd,
scope: this
},{
text: 'Cancel',
handler: this.hide.createDelegate(this, [])
}],
items: this.form
}]);
this.addEvents({add:true});
},
defaultFeeds : [
['http://www.divergingpath.com/rss.cfm?mode=full', 'Aaron Conran\'s Blog'],
['http://feeds.yuiblog.com/YahooUserInterfaceBlog', 'Yahoo! UI Blog'],
['http://feeds.feedburner.com/jquery/', 'jQuery Blog'],
['http://sports.yahoo.com/nba/rss.xml', 'NBA News'],
['http://feeds.dzone.com/dzone/frontpage', 'DZone.com']
],
show : function(){
if(this.rendered){
this.feedUrl.setValue('');
}
FeedWindow.superclass.show.apply(this, arguments);
},
onFeedAdd: function() {
this.el.mask('Validating Feed...', 'x-mask-loading');
var url = this.feedUrl.getValue();
Ext.Ajax.request({
url: 'feed-proxy.php',
params: {feed: url},
success: this.validateFeed,
failure: this.markInvalid,
scope: this,
feedUrl: url
});
},
markInvalid : function(){
this.feedUrl.markInvalid('The URL specified is not a valid RSS2 feed.');
this.el.unmask();
},
validateFeed : function(response, options){
var dq = Ext.DomQuery;
var url = options.feedUrl;
try{
var xml = response.responseXML;
var channel = xml.getElementsByTagName('channel')[0];
if(channel){
var text = dq.selectValue('title', channel, url);
var description = dq.selectValue('description', channel, 'No description available.');
this.el.unmask();
this.hide();
return this.fireEvent('validfeed', {
url: url,
text: text,
description: description
});
}
}catch(e){
}
this.markInvalid();
}
});
|