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
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 MainPanel.superclass.constructor.call(this, {
\r
108 enableTabScroll: true,
\r
109 plugins: new Ext.ux.TabCloseMenu(),
\r
113 title:'Loading...',
\r
114 hideMode:'offsets',
\r
117 id:'bottom-preview',
\r
119 items:this.preview,
\r
125 id:'right-preview',
\r
136 this.gsm = this.grid.getSelectionModel();
\r
138 this.gsm.on('rowselect', function(sm, index, record){
\r
139 FeedViewer.getTemplate().overwrite(this.preview.body, record.data);
\r
140 var items = this.preview.topToolbar.items;
\r
141 items.get('tab').enable();
\r
142 items.get('win').enable();
\r
143 }, this, {buffer:250});
\r
145 this.grid.store.on('beforeload', this.preview.clear, this.preview);
\r
146 this.grid.store.on('load', this.gsm.selectFirstRow, this.gsm);
\r
148 this.grid.on('rowdblclick', this.openTab, this);
\r
151 Ext.extend(MainPanel, Ext.TabPanel, {
\r
153 loadFeed : function(feed){
\r
154 this.grid.loadFeed(feed.url);
\r
155 Ext.getCmp('main-view').setTitle(feed.text);
\r
158 movePreview : function(m, pressed){
\r
159 if(!m){ // cycle if not a menu item click
\r
160 var items = Ext.menu.MenuMgr.get('reading-menu').items.items;
\r
161 var b = items[0], r = items[1], h = items[2];
\r
163 r.setChecked(true);
\r
164 }else if(r.checked){
\r
165 h.setChecked(true);
\r
166 }else if(h.checked){
\r
167 b.setChecked(true);
\r
172 var preview = this.preview;
\r
173 var right = Ext.getCmp('right-preview');
\r
174 var bot = Ext.getCmp('bottom-preview');
\r
175 var btn = this.grid.getTopToolbar().items.get(2);
\r
181 bot.ownerCt.doLayout();
\r
182 btn.setIconClass('preview-bottom');
\r
186 right.add(preview);
\r
188 right.ownerCt.doLayout();
\r
189 btn.setIconClass('preview-right');
\r
192 preview.ownerCt.hide();
\r
193 preview.ownerCt.ownerCt.doLayout();
\r
194 btn.setIconClass('preview-hide');
\r
200 openTab : function(record){
\r
201 record = (record && record.data) ? record : this.gsm.getSelected();
\r
202 var d = record.data;
\r
203 var id = !d.link ? Ext.id() : d.link.replace(/[^A-Z0-9-_]/gi, '');
\r
205 if(!(tab = this.getItem(id))){
\r
206 tab = new Ext.Panel({
\r
208 cls:'preview single-preview',
\r
211 html: FeedViewer.getTemplate().apply(d),
\r
213 listeners: FeedViewer.LinkInterceptor,
\r
218 text: 'Go to Post',
\r
219 iconCls: 'new-win',
\r
220 handler : function(){
\r
221 window.open(d.link);
\r
227 this.setActiveTab(tab);
\r
230 openAll : function(){
\r
231 this.beginUpdate();
\r
232 this.grid.store.data.each(this.openTab, this);
\r
237 Ext.reg('appmainpanel', MainPanel);