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.FeedPost
17 * @extends Ext.panel.Panel
19 * Shows the detail of a feed post
22 * Create a new Feed Post
23 * @param {Object} config The config object
25 Ext.define('FeedViewer.FeedPost', {
27 extend: 'Ext.panel.Panel',
28 alias: 'widget.feedpost',
33 initComponent: function(){
35 dockedItems: [this.createToolbar()],
36 tpl: Ext.create('Ext.XTemplate',
37 '<div class="post-data">',
38 '<span class="post-date">{pubDate:this.formatDate}</span>',
39 '<h3 class="post-title">{title}</h3>',
40 '<h4 class="post-author">by {author:this.defaultValue}</h4>',
42 '<div class="post-body">{content:this.getBody}</div>',
44 getBody: function(value, all){
45 return Ext.util.Format.stripScripts(value);
48 defaultValue: function(v){
49 return v ? v : 'Unknown';
52 formatDate: function(value){
56 return Ext.Date.format(value, 'M j, Y, g:i a');
61 this.callParent(arguments);
66 * @param {Ext.data.Model} rec The record
68 setActive: function(rec) {
70 this.update(rec.data);
74 * Create the top toolbar
76 * @return {Ext.toolbar.Toolbar} toolbar
78 createToolbar: function(){
84 handler: this.openTab,
85 text: 'View in new tab',
90 config.cls = 'x-docked-noborder-top';
94 handler: this.goToPost,
99 return Ext.create('widget.toolbar', config);
103 * Navigate to the active post in a new window
106 goToPost: function(){
107 window.open(this.active.get('link'));
111 * Open the post in a new tab
115 this.fireEvent('opentab', this, this.active);