3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
7 MainPanel = function(){
\r
8 this.preview = new Ext.Panel({
\r
13 listeners: FeedViewer.LinkInterceptor,
\r
14 enableTabbing: true,
\r
17 text: 'View in New Tab',
\r
20 handler : this.openTab,
\r
30 handler : function(){
\r
31 window.open(this.gsm.getSelected().data.link);
\r
36 this.body.update('');
\r
37 var items = this.topToolbar.items;
\r
38 items.get('tab').disable();
\r
39 items.get('win').disable();
\r
43 this.grid = new FeedGrid(this, {
\r
46 tooltip: {title:'Open All',text:'Opens all item in tabs'},
\r
48 handler: this.openAll,
\r
54 text:'Reading Pane',
\r
55 tooltip: {title:'Reading Pane',text:'Show, move or hide the Reading Pane'},
\r
56 iconCls: 'preview-bottom',
\r
57 handler: this.movePreview.createDelegate(this, []),
\r
66 checkHandler:this.movePreview,
\r
68 iconCls:'preview-bottom'
\r
73 checkHandler:this.movePreview,
\r
75 iconCls:'preview-right'
\r
80 checkHandler:this.movePreview,
\r
82 iconCls:'preview-hide'
\r
91 tooltip: {title:'Post Summary',text:'View a short summary of each item in the list'},
\r
94 toggleHandler: function(btn, pressed){
\r
95 this.grid.togglePreview(pressed);
\r
100 this.grid.on('afterrender', function() {
\r
101 //var fe = Ext.aria.FocusMgr.getByContainer(this.grid.body);
\r
102 //fe.on('enter', this.openTab, this);
\r
105 MainPanel.superclass.constructor.call(this, {
\r
113 enableTabScroll: true,
\r
114 plugins: new Ext.ux.TabCloseMenu(),
\r
118 title:'Loading...',
\r
119 hideMode:'offsets',
\r
122 id:'bottom-preview',
\r
124 items:this.preview,
\r
130 id:'right-preview',
\r
141 this.gsm = this.grid.getSelectionModel();
\r
143 this.gsm.on('rowselect', function(sm, index, record){
\r
144 FeedViewer.getTemplate().overwrite(this.preview.body, record.data);
\r
145 var items = this.preview.topToolbar.items;
\r
146 items.get('tab').enable();
\r
147 items.get('win').enable();
\r
148 }, this, {buffer:250});
\r
150 this.grid.store.on('beforeload', this.preview.clear, this.preview);
\r
151 this.grid.store.on('load', this.gsm.selectFirstRow, this.gsm);
\r
153 this.grid.on('rowdblclick', this.openTab, this);
\r
156 Ext.extend(MainPanel, Ext.TabPanel, {
\r
158 loadFeed : function(feed){
\r
159 this.grid.loadFeed(feed.url);
\r
160 Ext.getCmp('main-view').setTitle(feed.text);
\r
163 movePreview : function(m, pressed){
\r
164 if(!m){ // cycle if not a menu item click
\r
165 var readMenu = Ext.menu.MenuMgr.get('reading-menu');
\r
167 var items = readMenu.items.items;
\r
168 var b = items[0], r = items[1], h = items[2];
\r
170 r.setChecked(true);
\r
171 }else if(r.checked){
\r
172 h.setChecked(true);
\r
173 }else if(h.checked){
\r
174 b.setChecked(true);
\r
179 var preview = this.preview;
\r
180 var right = Ext.getCmp('right-preview');
\r
181 var bot = Ext.getCmp('bottom-preview');
\r
182 var btn = this.grid.getTopToolbar().items.get(2);
\r
188 bot.ownerCt.doLayout();
\r
189 btn.setIconClass('preview-bottom');
\r
193 right.add(preview);
\r
195 right.ownerCt.doLayout();
\r
196 btn.setIconClass('preview-right');
\r
199 preview.ownerCt.hide();
\r
200 preview.ownerCt.ownerCt.doLayout();
\r
201 btn.setIconClass('preview-hide');
\r
207 openTab : function(record){
\r
208 record = (record && record.data) ? record : this.gsm.getSelected();
\r
209 var d = record.data;
\r
210 var id = !d.link ? Ext.id() : d.link.replace(/[^A-Z0-9-_]/gi, '');
\r
212 if(!(tab = this.getItem(id))){
\r
213 tab = new Ext.Panel({
\r
215 cls:'preview single-preview',
\r
218 html: FeedViewer.getTemplate().apply(d),
\r
219 enableTabbing: true,
\r
221 listeners: FeedViewer.LinkInterceptor,
\r
225 text: 'Go to Post',
\r
226 iconCls: 'new-win',
\r
227 handler : function(){
\r
228 window.open(d.link);
\r
234 this.setActiveTab(tab);
\r
238 openAll : function(){
\r
239 this.beginUpdate();
\r
240 this.grid.store.data.each(this.openTab, this);
\r
245 Ext.reg('appmainpanel', MainPanel);