Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / FeedWindow.html
diff --git a/docs/source/FeedWindow.html b/docs/source/FeedWindow.html
new file mode 100644 (file)
index 0000000..8b50be5
--- /dev/null
@@ -0,0 +1,131 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">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.onAdd,\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
+    onAdd: 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
+});</pre>    \r
+</body>\r
+</html>
\ No newline at end of file