Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / app / feed-viewer / app / view / article / Preview.js
diff --git a/examples/app/feed-viewer/app/view/article/Preview.js b/examples/app/feed-viewer/app/view/article/Preview.js
new file mode 100644 (file)
index 0000000..fcd5733
--- /dev/null
@@ -0,0 +1,53 @@
+Ext.define('FV.view.article.Preview', {
+       extend: 'Ext.panel.Panel',
+       alias: 'widget.articlepreview',
+
+    requires: ['Ext.toolbar.Toolbar'],
+
+       cls: 'preview',
+       autoScroll: true,
+       border: false,
+       
+       initComponent: function() {
+               Ext.apply(this, {
+                       tpl: new Ext.XTemplate(
+                           '<div class="post-data">',
+                               '<span class="post-date">{pubDate:this.formatDate}</span>',
+                               '<h3 class="post-title">{title}</h3>',
+                               '<h4 class="post-author">by {author:this.defaultValue}</h4>',
+                           '</div>',
+                           '<div class="post-body">{content:this.getBody}</div>', {
+
+                               getBody: function(value, all) {
+                                       return Ext.util.Format.stripScripts(value);
+                               },
+
+                               defaultValue: function(v) {
+                                       return v ? v : 'Unknown';
+                               },
+
+                               formatDate: function(value) {
+                                       if (!value) {
+                                               return '';
+                                       }
+                                       return Ext.Date.format(value, 'M j, Y, g:i a');
+                               }
+                       }),
+
+                       dockedItems: [{
+                               dock: 'top',
+                               xtype: 'toolbar',
+                               border: false,
+                               items: [{
+                                       text: 'View in new tab',
+                                       action: 'viewintab'
+                               }, {
+                                       text: 'Go to post',
+                                       action: 'gotopost'
+                               }]
+                       }]
+               });
+
+               this.callParent(arguments);
+       }
+});