]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('FV.view.article.Grid', {\r |
2 | extend: 'Ext.grid.Panel',\r | |
3 | alias: 'widget.articlegrid',\r | |
4 | \r | |
5 | cls: 'feed-grid',\r | |
6 | disabled: true,\r | |
7 | \r | |
8 | requires: ['Ext.ux.PreviewPlugin', 'Ext.toolbar.Toolbar'],\r | |
9 | \r | |
10 | border: false,\r | |
11 | \r | |
12 | initComponent: function() {\r | |
13 | Ext.apply(this, {\r | |
14 | store: 'Articles',\r | |
15 | \r | |
16 | viewConfig: {\r | |
17 | plugins: [{\r | |
18 | pluginId: 'preview',\r | |
19 | ptype: 'preview',\r | |
20 | bodyField: 'description',\r | |
21 | previewExpanded: true\r | |
22 | }]\r | |
23 | },\r | |
24 | \r | |
25 | columns: [{\r | |
26 | text: 'Title',\r | |
27 | dataIndex: 'title',\r | |
28 | flex: 1,\r | |
29 | renderer: this.formatTitle\r | |
30 | }, {\r | |
31 | text: 'Author',\r | |
32 | dataIndex: 'author',\r | |
33 | hidden: true,\r | |
34 | width: 200\r | |
35 | }, {\r | |
36 | text: 'Date',\r | |
37 | dataIndex: 'pubDate',\r | |
38 | renderer: this.formatDate,\r | |
39 | width: 200\r | |
40 | }],\r | |
41 | dockedItems:[{\r | |
42 | xtype: 'toolbar',\r | |
43 | dock: 'top',\r | |
44 | items: [{\r | |
45 | iconCls: 'open-all',\r | |
46 | text: 'Open All',\r | |
47 | action: 'openall'\r | |
48 | }]\r | |
49 | }]\r | |
50 | });\r | |
51 | \r | |
52 | this.callParent(arguments);\r | |
53 | },\r | |
54 | \r | |
55 | /**\r | |
56 | * Title renderer\r | |
57 | * @private\r | |
58 | */\r | |
59 | formatTitle: function(value, p, record) {\r | |
60 | return Ext.String.format('<div class="topic"><b>{0}</b><span class="author">{1}</span></div>', value, record.get('author') || "Unknown");\r | |
61 | },\r | |
62 | \r | |
63 | /**\r | |
64 | * Date renderer\r | |
65 | * @private\r | |
66 | */\r | |
67 | formatDate: function(date) {\r | |
68 | if (!date) {\r | |
69 | return '';\r | |
70 | }\r | |
71 | \r | |
72 | var now = new Date(),\r | |
73 | d = Ext.Date.clearTime(now, true),\r | |
74 | notime = Ext.Date.clearTime(date, true).getTime();\r | |
75 | \r | |
76 | if (notime === d.getTime()) {\r | |
77 | return 'Today ' + Ext.Date.format(date, 'g:i a');\r | |
78 | }\r | |
79 | \r | |
80 | d = Ext.Date.add(d, 'd', -6);\r | |
81 | if (d.getTime() <= notime) {\r | |
82 | return Ext.Date.format(date, 'D g:i a');\r | |
83 | }\r | |
84 | return Ext.Date.format(date, 'Y/m/d g:i a');\r | |
85 | }\r | |
86 | });\r |