3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 MainPanel = function(){
8 this.preview = new Ext.Panel({
13 listeners: FeedViewer.LinkInterceptor,
17 text: 'View in New Tab',
20 handler : this.openTab,
31 window.open(this.gsm.getSelected().data.link);
37 var items = this.topToolbar.items;
38 items.get('tab').disable();
39 items.get('win').disable();
43 this.grid = new FeedGrid(this, {
46 tooltip: {title:'Open All',text:'Opens all item in tabs'},
48 handler: this.openAll,
55 tooltip: {title:'Reading Pane',text:'Show, move or hide the Reading Pane'},
56 iconCls: 'preview-bottom',
57 handler: this.movePreview.createDelegate(this, []),
66 checkHandler:this.movePreview,
68 iconCls:'preview-bottom'
73 checkHandler:this.movePreview,
75 iconCls:'preview-right'
80 checkHandler:this.movePreview,
82 iconCls:'preview-hide'
91 tooltip: {title:'Post Summary',text:'View a short summary of each item in the list'},
94 toggleHandler: function(btn, pressed){
95 this.grid.togglePreview(pressed);
100 MainPanel.superclass.constructor.call(this, {
108 enableTabScroll: true,
109 plugins: new Ext.ux.TabCloseMenu(),
136 this.gsm = this.grid.getSelectionModel();
138 this.gsm.on('rowselect', function(sm, index, record){
139 FeedViewer.getTemplate().overwrite(this.preview.body, record.data);
140 var items = this.preview.topToolbar.items;
141 items.get('tab').enable();
142 items.get('win').enable();
143 }, this, {buffer:250});
145 this.grid.store.on('beforeload', this.preview.clear, this.preview);
146 this.grid.store.on('load', this.gsm.selectFirstRow, this.gsm);
148 this.grid.on('rowdblclick', this.openTab, this);
151 Ext.extend(MainPanel, Ext.TabPanel, {
153 loadFeed : function(feed){
154 this.grid.loadFeed(feed.url);
155 Ext.getCmp('main-view').setTitle(feed.text);
158 movePreview : function(m, pressed){
159 if(!m){ // cycle if not a menu item click
160 var items = Ext.menu.MenuMgr.get('reading-menu').items.items;
161 var b = items[0], r = items[1], h = items[2];
172 var preview = this.preview;
173 var right = Ext.getCmp('right-preview');
174 var bot = Ext.getCmp('bottom-preview');
175 var btn = this.grid.getTopToolbar().items.get(2);
181 bot.ownerCt.doLayout();
182 btn.setIconClass('preview-bottom');
188 right.ownerCt.doLayout();
189 btn.setIconClass('preview-right');
192 preview.ownerCt.hide();
193 preview.ownerCt.ownerCt.doLayout();
194 btn.setIconClass('preview-hide');
200 openTab : function(record){
201 record = (record && record.data) ? record : this.gsm.getSelected();
203 var id = !d.link ? Ext.id() : d.link.replace(/[^A-Z0-9-_]/gi, '');
205 if(!(tab = this.getItem(id))){
206 tab = new Ext.Panel({
208 cls:'preview single-preview',
211 html: FeedViewer.getTemplate().apply(d),
213 listeners: FeedViewer.LinkInterceptor,
220 handler : function(){
227 this.setActiveTab(tab);
230 openAll : function(){
232 this.grid.store.data.each(this.openTab, this);
237 Ext.reg('appmainpanel', MainPanel);