FeedDetail.js
5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
* @class FeedViewer.FeedDetail
* @extends Ext.panel.Panel
*
* Shows the details of a particular feed
*
* @constructor
* Create a new Feed Detail
* @param {Object} config The config object
*/
Ext.define('FeedViewer.FeedDetail', {
extend: 'Ext.panel.Panel',
alias: 'widget.feeddetail',
border: false,
initComponent: function(){
this.display = Ext.create('widget.feedpost', {});
Ext.apply(this, {
layout: 'border',
items: [this.createGrid(), this.createSouth(), this.createEast()]
});
this.relayEvents(this.display, ['opentab']);
this.relayEvents(this.grid, ['rowdblclick']);
this.callParent(arguments);
},
/**
* Loads a feed.
* @param {String} url
*/
loadFeed: function(url){
this.grid.loadFeed(url);
},
/**
* Creates the feed grid
* @private
* @return {FeedViewer.FeedGrid} feedGrid
*/
createGrid: function(){
this.grid = Ext.create('widget.feedgrid', {
region: 'center',
dockedItems: [this.createTopToolbar()],
flex: 2,
minHeight: 200,
minWidth: 150,
listeners: {
scope: this,
select: this.onSelect
}
});
this.loadFeed(this.url);
return this.grid;
},
/**
* Fires when a grid row is selected
* @private
* @param {FeedViewer.FeedGrid} grid
* @param {Ext.data.Model} rec
*/
onSelect: function(grid, rec) {
this.display.setActive(rec);
},
/**
* Creates top controller toolbar.
* @private
* @return {Ext.toolbar.Toolbar} toolbar
*/
createTopToolbar: function(){
this.toolbar = Ext.create('widget.toolbar', {
cls: 'x-docked-noborder-top',
items: [{
iconCls: 'open-all',
text: 'Open All',
scope: this,
handler: this.onOpenAllClick
}, '-', {
xtype: 'cycle',
text: 'Reading Pane',
prependText: 'Preview: ',
showText: true,
scope: this,
changeHandler: this.readingPaneChange,
menu: {
id: 'reading-menu',
items: [{
text: 'Bottom',
checked: true,
iconCls:'preview-bottom'
}, {
text: 'Right',
iconCls:'preview-right'
}, {
text: 'Hide',
iconCls:'preview-hide'
}]
}
}, {
iconCls: 'summary',
text: 'Summary',
enableToggle: true,
pressed: true,
scope: this,
toggleHandler: this.onSummaryToggle
}]
});
return this.toolbar;
},
/**
* Reacts to the open all being clicked
* @private
*/
onOpenAllClick: function(){
this.fireEvent('openall', this);
},
/**
* Gets a list of titles/urls for each feed.
* @return {Array} The feed details
*/
getFeedData: function(){
return this.grid.store.getRange();
},
/**
* @private
* @param {Ext.button.Button} button The button
* @param {Boolean} pressed Whether the button is pressed
*/
onSummaryToggle: function(btn, pressed) {
this.grid.getComponent('view').getPlugin('preview').toggleExpanded(pressed);
},
/**
* Handle the checked item being changed
* @private
* @param {Ext.menu.CheckItem} item The checked item
*/
readingPaneChange: function(cycle, activeItem){
switch (activeItem.text) {
case 'Bottom':
this.east.hide();
this.south.show();
this.south.add(this.display);
break;
case 'Right':
this.south.hide();
this.east.show();
this.east.add(this.display);
break;
default:
this.south.hide();
this.east.hide();
break;
}
},
/**
* Create the south region container
* @private
* @return {Ext.panel.Panel} south
*/
createSouth: function(){
this.south = Ext.create('Ext.container.Container', {
layout: 'fit',
region: 'south',
split: true,
flex: 2,
minHeight: 150,
items: this.display
});
return this.south;
},
/**
* Create the east region container
* @private
* @return {Ext.panel.Panel} east
*/
createEast: function(){
this.east = Ext.create('Ext.panel.Panel', {
layout: 'fit',
region: 'east',
flex: 1,
split: true,
hidden: true,
minWidth: 150,
border: false
});
return this.east;
}
});