3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 FeedGrid = function(viewer, config) {
9 Ext.apply(this, config);
11 this.store = new Ext.data.Store({
12 proxy: new Ext.data.HttpProxy({
16 reader: new Ext.data.XmlReader(
18 ['title', 'author', {name:'pubDate', type:'date'}, 'link', 'description', 'content']
21 this.store.setDefaultSort('pubDate', "DESC");
29 renderer: this.formatTitle
41 renderer: this.formatDate,
45 FeedGrid.superclass.constructor.call(this, {
48 loadMask: {msg:'Loading Feed...'},
50 sm: new Ext.grid.RowSelectionModel({
58 getRowClass : this.applyRowClass
62 this.on('rowcontextmenu', this.onContextClick, this);
65 Ext.extend(FeedGrid, Ext.grid.GridPanel, {
67 onContextClick : function(grid, index, e){
68 if(!this.menu){ // create context menu on first right click
69 this.menu = new Ext.menu.Menu({
72 text: 'View in new tab',
76 this.viewer.openTab(this.ctxRecord);
83 window.open(this.ctxRecord.data.link);
86 iconCls: 'refresh-icon',
95 this.menu.on('hide', this.onContextHide, this);
99 Ext.fly(this.ctxRow).removeClass('x-node-ctx');
102 this.ctxRow = this.view.getRow(index);
103 this.ctxRecord = this.store.getAt(index);
104 Ext.fly(this.ctxRow).addClass('x-node-ctx');
105 this.menu.showAt(e.getXY());
108 onContextHide : function(){
110 Ext.fly(this.ctxRow).removeClass('x-node-ctx');
115 loadFeed : function(url) {
116 this.store.baseParams = {
122 togglePreview : function(show){
123 this.view.showPreview = show;
127 // within this function "this" is actually the GridView
128 applyRowClass: function(record, rowIndex, p, ds) {
129 if (this.showPreview) {
130 var xf = Ext.util.Format;
131 p.body = '<p>' + xf.ellipsis(xf.stripTags(record.data.description), 200) + '</p>';
132 return 'x-grid3-row-expanded';
134 return 'x-grid3-row-collapsed';
137 formatDate : function(date) {
141 var now = new Date();
142 var d = now.clearTime(true);
143 var notime = date.clearTime(true).getTime();
144 if (notime == d.getTime()) {
145 return 'Today ' + date.dateFormat('g:i a');
148 if (d.getTime() <= notime) {
149 return date.dateFormat('D g:i a');
151 return date.dateFormat('n/j g:i a');
154 formatTitle: function(value, p, record) {
155 return String.format(
156 '<div class="topic"><b>{0}</b><span class="author">{1}</span></div>',
157 value, record.data.author, record.id, record.data.forumid
162 Ext.reg('appfeedgrid', FeedGrid);