2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 FeedGrid = function(viewer, config) {
\r
10 this.viewer = viewer;
\r
11 Ext.apply(this, config);
\r
13 this.store = new Ext.data.Store({
\r
14 proxy: new Ext.data.HttpProxy({
\r
15 url: 'feed-proxy.php'
\r
18 reader: new Ext.data.XmlReader(
\r
20 ['title', 'author', {name:'pubDate', type:'date'}, 'link', 'description', 'content']
\r
23 this.store.setDefaultSort('pubDate', "DESC");
\r
31 renderer: this.formatTitle
\r
34 dataIndex: 'author',
\r
41 dataIndex: 'pubDate',
\r
43 renderer: this.formatDate,
\r
47 FeedGrid.superclass.constructor.call(this, {
\r
50 loadMask: {msg:'Loading Feed...'},
\r
52 sm: new Ext.grid.RowSelectionModel({
\r
60 getRowClass : this.applyRowClass
\r
64 this.on('rowcontextmenu', this.onContextClick, this);
\r
67 Ext.extend(FeedGrid, Ext.grid.GridPanel, {
\r
69 onContextClick : function(grid, index, e){
\r
70 if(!this.menu){ // create context menu on first right click
\r
71 this.menu = new Ext.menu.Menu({
\r
74 text: 'View in new tab',
\r
77 handler: function(){
\r
78 this.viewer.openTab(this.ctxRecord);
\r
84 handler: function(){
\r
85 window.open(this.ctxRecord.data.link);
\r
88 iconCls: 'refresh-icon',
\r
91 handler: function(){
\r
93 this.store.reload();
\r
97 this.menu.on('hide', this.onContextHide, this);
\r
101 Ext.fly(this.ctxRow).removeClass('x-node-ctx');
\r
102 this.ctxRow = null;
\r
104 this.ctxRow = this.view.getRow(index);
\r
105 this.ctxRecord = this.store.getAt(index);
\r
106 Ext.fly(this.ctxRow).addClass('x-node-ctx');
\r
107 this.menu.showAt(e.getXY());
\r
110 onContextHide : function(){
\r
112 Ext.fly(this.ctxRow).removeClass('x-node-ctx');
\r
113 this.ctxRow = null;
\r
117 loadFeed : function(url) {
\r
118 this.store.baseParams = {
\r
124 togglePreview : function(show){
\r
125 this.view.showPreview = show;
\r
126 this.view.refresh();
\r
129 // within this function "this" is actually the GridView
\r
130 applyRowClass: function(record, rowIndex, p, ds) {
\r
131 if (this.showPreview) {
\r
132 var xf = Ext.util.Format;
\r
133 p.body = '<p>' + xf.ellipsis(xf.stripTags(record.data.description), 200) + '</p>';
\r
134 return 'x-grid3-row-expanded';
\r
136 return 'x-grid3-row-collapsed';
\r
139 formatDate : function(date) {
\r
143 var now = new Date();
\r
144 var d = now.clearTime(true);
\r
145 var notime = date.clearTime(true).getTime();
\r
146 if (notime == d.getTime()) {
\r
147 return 'Today ' + date.dateFormat('g:i a');
\r
149 d = d.add('d', -6);
\r
150 if (d.getTime() <= notime) {
\r
151 return date.dateFormat('D g:i a');
\r
153 return date.dateFormat('n/j g:i a');
\r
156 formatTitle: function(value, p, record) {
\r
157 return String.format(
\r
158 '<div class="topic"><b>{0}</b><span class="author">{1}</span></div>',
\r
159 value, record.data.author, record.id, record.data.forumid
\r