You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
7.9 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. MainPanel = function(){
  16. this.preview = new Ext.Panel({
  17. id: 'preview',
  18. region: 'south',
  19. cls:'preview',
  20. autoScroll: true,
  21. listeners: FeedViewer.LinkInterceptor,
  22. enableTabbing: true,
  23. tbar: [{
  24. id:'tab',
  25. text: 'View in New Tab',
  26. iconCls: 'new-tab',
  27. disabled:true,
  28. handler : this.openTab,
  29. scope: this
  30. },
  31. '-',
  32. {
  33. id:'win',
  34. text: 'Go to Post',
  35. iconCls: 'new-win',
  36. disabled:true,
  37. scope: this,
  38. handler : function(){
  39. window.open(this.gsm.getSelected().data.link);
  40. }
  41. }],
  42. clear: function(){
  43. this.body.update('');
  44. var items = this.topToolbar.items;
  45. items.get('tab').disable();
  46. items.get('win').disable();
  47. }
  48. });
  49. this.grid = new FeedGrid(this, {
  50. tbar:[{
  51. text:'Open All',
  52. tooltip: {title:'Open All',text:'Opens all item in tabs'},
  53. iconCls: 'tabs',
  54. handler: this.openAll,
  55. scope:this
  56. },
  57. '-',
  58. {
  59. split:true,
  60. text:'Reading Pane',
  61. tooltip: {title:'Reading Pane',text:'Show, move or hide the Reading Pane'},
  62. iconCls: 'preview-bottom',
  63. handler: this.movePreview.createDelegate(this, []),
  64. menu:{
  65. id:'reading-menu',
  66. cls:'reading-menu',
  67. width:100,
  68. items: [{
  69. text:'Bottom',
  70. checked:true,
  71. group:'rp-group',
  72. checkHandler:this.movePreview,
  73. scope:this,
  74. iconCls:'preview-bottom'
  75. },{
  76. text:'Right',
  77. checked:false,
  78. group:'rp-group',
  79. checkHandler:this.movePreview,
  80. scope:this,
  81. iconCls:'preview-right'
  82. },{
  83. text:'Hide',
  84. checked:false,
  85. group:'rp-group',
  86. checkHandler:this.movePreview,
  87. scope:this,
  88. iconCls:'preview-hide'
  89. }]
  90. }
  91. },
  92. '-',
  93. {
  94. pressed: true,
  95. enableToggle:true,
  96. text:'Summary',
  97. tooltip: {title:'Post Summary',text:'View a short summary of each item in the list'},
  98. iconCls: 'summary',
  99. scope:this,
  100. toggleHandler: function(btn, pressed){
  101. this.grid.togglePreview(pressed);
  102. }
  103. }]
  104. });
  105. this.grid.on('afterrender', function() {
  106. //var fe = Ext.aria.FocusMgr.getByContainer(this.grid.body);
  107. //fe.on('enter', this.openTab, this);
  108. }, this);
  109. MainPanel.superclass.constructor.call(this, {
  110. id:'main-tabs',
  111. activeTab:0,
  112. region:'center',
  113. margins:'0 5 5 0',
  114. resizeTabs:true,
  115. tabWidth:150,
  116. minTabWidth: 120,
  117. enableTabScroll: true,
  118. plugins: new Ext.ux.TabCloseMenu(),
  119. items: {
  120. id:'main-view',
  121. layout:'border',
  122. title:'Loading...',
  123. hideMode:'offsets',
  124. items:[
  125. this.grid, {
  126. id:'bottom-preview',
  127. layout:'fit',
  128. items:this.preview,
  129. height: 250,
  130. split: true,
  131. border:false,
  132. region:'south'
  133. }, {
  134. id:'right-preview',
  135. layout:'fit',
  136. border:false,
  137. region:'east',
  138. width:350,
  139. split: true,
  140. hidden:true
  141. }]
  142. }
  143. });
  144. this.gsm = this.grid.getSelectionModel();
  145. this.gsm.on('rowselect', function(sm, index, record){
  146. FeedViewer.getTemplate().overwrite(this.preview.body, record.data);
  147. var items = this.preview.topToolbar.items;
  148. items.get('tab').enable();
  149. items.get('win').enable();
  150. }, this, {buffer:250});
  151. this.grid.store.on('beforeload', this.preview.clear, this.preview);
  152. this.grid.store.on('load', this.gsm.selectFirstRow, this.gsm);
  153. this.grid.on('rowdblclick', this.openTab, this);
  154. };
  155. Ext.extend(MainPanel, Ext.TabPanel, {
  156. loadFeed : function(feed){
  157. this.grid.loadFeed(feed.url);
  158. Ext.getCmp('main-view').setTitle(feed.text);
  159. },
  160. movePreview : function(m, pressed){
  161. if(!m){ // cycle if not a menu item click
  162. var readMenu = Ext.menu.MenuMgr.get('reading-menu');
  163. readMenu.render();
  164. var items = readMenu.items.items;
  165. var b = items[0], r = items[1], h = items[2];
  166. if(b.checked){
  167. r.setChecked(true);
  168. }else if(r.checked){
  169. h.setChecked(true);
  170. }else if(h.checked){
  171. b.setChecked(true);
  172. }
  173. return;
  174. }
  175. if(pressed){
  176. var preview = this.preview;
  177. var right = Ext.getCmp('right-preview');
  178. var bot = Ext.getCmp('bottom-preview');
  179. var btn = this.grid.getTopToolbar().items.get(2);
  180. switch(m.text){
  181. case 'Bottom':
  182. right.hide();
  183. bot.add(preview);
  184. bot.show();
  185. bot.ownerCt.doLayout();
  186. btn.setIconClass('preview-bottom');
  187. break;
  188. case 'Right':
  189. bot.hide();
  190. right.add(preview);
  191. right.show();
  192. right.ownerCt.doLayout();
  193. btn.setIconClass('preview-right');
  194. break;
  195. case 'Hide':
  196. preview.ownerCt.hide();
  197. preview.ownerCt.ownerCt.doLayout();
  198. btn.setIconClass('preview-hide');
  199. break;
  200. }
  201. }
  202. },
  203. openTab : function(record){
  204. record = (record && record.data) ? record : this.gsm.getSelected();
  205. var d = record.data;
  206. var id = !d.link ? Ext.id() : d.link.replace(/[^A-Z0-9-_]/gi, '');
  207. var tab;
  208. if(!(tab = this.getItem(id))){
  209. tab = new Ext.Panel({
  210. id: id,
  211. cls:'preview single-preview',
  212. title: d.title,
  213. tabTip: d.title,
  214. html: FeedViewer.getTemplate().apply(d),
  215. enableTabbing: true,
  216. closable:true,
  217. listeners: FeedViewer.LinkInterceptor,
  218. autoScroll:true,
  219. border:true,
  220. tbar: [{
  221. text: 'Go to Post',
  222. iconCls: 'new-win',
  223. handler : function(){
  224. window.open(d.link);
  225. }
  226. }]
  227. });
  228. this.add(tab);
  229. }
  230. this.setActiveTab(tab);
  231. tab.enter();
  232. },
  233. openAll : function(){
  234. this.beginUpdate();
  235. this.grid.store.data.each(this.openTab, this);
  236. this.endUpdate();
  237. }
  238. });
  239. Ext.reg('appmainpanel', MainPanel);