Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / examples / key-feed-viewer / FeedWindow.js
index a253eab..bd294de 100644 (file)
 /*!
 /*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
  */
  */
-FeedWindow = function() {\r
-    this.feedUrl = new Ext.form.ComboBox({\r
-        id: 'feed-url',\r
-        fieldLabel: 'Enter the URL of the feed to add',\r
-        emptyText: 'http://example.com/blog/feed',\r
-        width: 450,\r
-        validationEvent: false,\r
-        validateOnBlur: false,\r
-        msgTarget: 'under',\r
-        triggerAction: 'all',\r
-        displayField: 'url',\r
-        mode: 'local',\r
-\r
-        listeners:{\r
-            valid: this.syncShadow,\r
-            invalid: this.syncShadow,\r
-            scope: this\r
-        },\r
-        tpl: new Ext.XTemplate(\r
-                '<tpl for="."><div class="x-combo-list-item">',\r
-                '<em>{url}</em><strong>{text}</strong>',\r
-                '<div class="x-clear"></div>',\r
-                '</div></tpl>'),\r
-        store: new Ext.data.ArrayStore({\r
-            fields: ['url', 'text'],\r
-            data : this.defaultFeeds\r
-        })\r
-    });\r
-\r
-    this.form = new Ext.FormPanel({\r
-        labelAlign:'top',\r
-        items:this.feedUrl,\r
-        border: false,\r
-        bodyStyle:'background:transparent;padding:10px;'\r
-    });\r
-\r
-    FeedWindow.superclass.constructor.call(this, {\r
-        title: 'Add Feed',\r
-        iconCls: 'feed-icon',\r
-        id: 'add-feed-win',\r
-        autoHeight: true,\r
-        width: 500,\r
-        resizable: false,\r
-        plain:true,\r
-        modal: true,\r
-        y: 100,\r
-        autoScroll: true,\r
-        closeAction: 'hide',\r
-\r
-        buttons:[{\r
-            text: 'Add Feed!',\r
-            handler: this.onFeedAdd,\r
-            scope: this\r
-        },{\r
-            text: 'Cancel',\r
-            handler: this.hide.createDelegate(this, [])\r
-        }],\r
-\r
-        items: this.form\r
-    });\r
-\r
-    this.addEvents({add:true});\r
-}\r
-\r
-Ext.extend(FeedWindow, Ext.Window, {\r
-    defaultFeeds : [\r
-        ['http://www.divergingpath.com/rss.cfm?mode=full', 'Aaron Conran\'s Blog'],\r
-        ['http://feeds.yuiblog.com/YahooUserInterfaceBlog',  'Yahoo! UI Blog'],\r
-        ['http://feeds.feedburner.com/jquery/', 'jQuery Blog'],\r
-        ['http://sports.yahoo.com/nba/rss.xml', 'NBA News'],\r
-        ['http://feeds.dzone.com/dzone/frontpage', 'DZone.com']\r
-    ],\r
-\r
-    show : function(){\r
-        if(this.rendered){\r
-            this.feedUrl.setValue('');\r
-        }\r
-        FeedWindow.superclass.show.apply(this, arguments);\r
-    },\r
-\r
-    onFeedAdd: function() {\r
-        this.el.mask('Validating Feed...', 'x-mask-loading');\r
-        var url = this.feedUrl.getValue();\r
-        Ext.Ajax.request({\r
-            url: 'feed-proxy.php',\r
-            params: {feed: url},\r
-            success: this.validateFeed,\r
-            failure: this.markInvalid,\r
-            scope: this,\r
-            feedUrl: url\r
-        });\r
-    },\r
-\r
-    markInvalid : function(){\r
-        this.feedUrl.markInvalid('The URL specified is not a valid RSS2 feed.');\r
-        this.el.unmask();\r
-    },\r
-\r
-    validateFeed : function(response, options){\r
-        var dq = Ext.DomQuery;\r
-        var url = options.feedUrl;\r
-\r
-        try{\r
-            var xml = response.responseXML;\r
-            var channel = xml.getElementsByTagName('channel')[0];\r
-            if(channel){\r
-                var text = dq.selectValue('title', channel, url);\r
-                var description = dq.selectValue('description', channel, 'No description available.');\r
-                this.el.unmask();\r
-                this.hide();\r
-\r
-                return this.fireEvent('validfeed', {\r
-                    url: url,\r
-                    text: text,\r
-                    description: description\r
-                });\r
-            }\r
-        }catch(e){\r
-        }\r
-        this.markInvalid();\r
-    }\r
-});\r
+FeedWindow = 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;'
+    });
+
+    FeedWindow.superclass.constructor.call(this, {
+        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});
+}
+
+Ext.extend(FeedWindow, Ext.Window, {
+    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();
+    }
+});