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.

256 lines
8.1 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. Ext.define('MainPanel', {
  16. extend: 'Ext.TabPanel',
  17. xtype: 'appmainpanel',
  18. constructor: function() {
  19. var me = this;
  20. me.preview = new Ext.Panel({
  21. id: 'preview',
  22. region: 'south',
  23. cls:'preview',
  24. autoScroll: true,
  25. listeners: FeedViewer.LinkInterceptor,
  26. tbar: [{
  27. id:'tab',
  28. text: 'View in New Tab',
  29. iconCls: 'new-tab',
  30. disabled:true,
  31. handler : me.openTab,
  32. scope: me
  33. },
  34. '-',
  35. {
  36. id:'win',
  37. text: 'Go to Post',
  38. iconCls: 'new-win',
  39. disabled:true,
  40. scope: me,
  41. handler : function(){
  42. window.open(me.gsm.getSelected().data.link);
  43. }
  44. }],
  45. clear: function(){
  46. this.body.update('');
  47. var items = this.topToolbar.items;
  48. items.get('tab').disable();
  49. items.get('win').disable();
  50. }
  51. });
  52. me.grid = Ext.create({
  53. viewer: me,
  54. xtype: 'appfeedgrid',
  55. tbar:[{
  56. text:'Open All',
  57. tooltip: {title:'Open All',text:'Opens all item in tabs'},
  58. iconCls: 'tabs',
  59. handler: me.openAll,
  60. scope:me
  61. },
  62. '-',
  63. {
  64. split:true,
  65. text:'Reading Pane',
  66. tooltip: {title:'Reading Pane',text:'Show, move or hide the Reading Pane'},
  67. iconCls: 'preview-bottom',
  68. handler: me.movePreview.createDelegate(me, []),
  69. menu:{
  70. id:'reading-menu',
  71. cls:'reading-menu',
  72. width:100,
  73. items: [{
  74. text:'Bottom',
  75. checked:true,
  76. group:'rp-group',
  77. checkHandler:me.movePreview,
  78. scope:me,
  79. iconCls:'preview-bottom'
  80. },{
  81. text:'Right',
  82. checked:false,
  83. group:'rp-group',
  84. checkHandler:me.movePreview,
  85. scope:me,
  86. iconCls:'preview-right'
  87. },{
  88. text:'Hide',
  89. checked:false,
  90. group:'rp-group',
  91. checkHandler:me.movePreview,
  92. scope:me,
  93. iconCls:'preview-hide'
  94. }]
  95. }
  96. },
  97. '-',
  98. {
  99. pressed: true,
  100. enableToggle:true,
  101. text:'Summary',
  102. tooltip: {title:'Post Summary',text:'View a short summary of each item in the list'},
  103. iconCls: 'summary',
  104. scope:me,
  105. toggleHandler: function(btn, pressed){
  106. this.grid.togglePreview(pressed);
  107. }
  108. }]
  109. });
  110. me.callParent([{
  111. id:'main-tabs',
  112. activeTab:0,
  113. region:'center',
  114. margins:'0 5 5 0',
  115. resizeTabs:true,
  116. tabWidth:150,
  117. minTabWidth: 120,
  118. enableTabScroll: true,
  119. plugins: new Ext.ux.TabCloseMenu(),
  120. items: {
  121. id:'main-view',
  122. layout:'border',
  123. title:'Loading...',
  124. hideMode:'offsets',
  125. items:[
  126. me.grid, {
  127. id:'bottom-preview',
  128. layout:'fit',
  129. items:me.preview,
  130. height: 250,
  131. split: true,
  132. border:false,
  133. region:'south'
  134. }, {
  135. id:'right-preview',
  136. layout:'fit',
  137. border:false,
  138. region:'east',
  139. width:350,
  140. split: true,
  141. hidden:true
  142. }]
  143. }
  144. }]);
  145. me.gsm = me.grid.getSelectionModel();
  146. me.gsm.on('rowselect', function(sm, index, record){
  147. FeedViewer.getTemplate().overwrite(me.preview.body, record.data);
  148. var items = me.preview.topToolbar.items;
  149. items.get('tab').enable();
  150. items.get('win').enable();
  151. }, me, {buffer:250});
  152. me.grid.store.on('beforeload', me.preview.clear, me.preview);
  153. me.grid.store.on('load', me.gsm.selectFirstRow, me.gsm);
  154. me.grid.on('rowdblclick', me.openTab, me);
  155. },
  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 items = Ext.menu.MenuMgr.get('reading-menu').items.items;
  163. var b = items[0], r = items[1], h = items[2];
  164. if(b.checked){
  165. r.setChecked(true);
  166. }else if(r.checked){
  167. h.setChecked(true);
  168. }else if(h.checked){
  169. b.setChecked(true);
  170. }
  171. return;
  172. }
  173. if(pressed){
  174. var preview = this.preview;
  175. var right = Ext.getCmp('right-preview');
  176. var bot = Ext.getCmp('bottom-preview');
  177. var btn = this.grid.getTopToolbar().items.get(2);
  178. switch(m.text){
  179. case 'Bottom':
  180. right.hide();
  181. bot.add(preview);
  182. bot.show();
  183. bot.ownerCt.doLayout();
  184. btn.setIconClass('preview-bottom');
  185. break;
  186. case 'Right':
  187. bot.hide();
  188. right.add(preview);
  189. right.show();
  190. right.ownerCt.doLayout();
  191. btn.setIconClass('preview-right');
  192. break;
  193. case 'Hide':
  194. preview.ownerCt.hide();
  195. preview.ownerCt.ownerCt.doLayout();
  196. btn.setIconClass('preview-hide');
  197. break;
  198. }
  199. }
  200. },
  201. openTab : function(record){
  202. record = (record && record.data) ? record : this.gsm.getSelected();
  203. var d = record.data;
  204. var id = !d.link ? Ext.id() : d.link.replace(/[^A-Z0-9-_]/gi, '');
  205. var tab;
  206. if(!(tab = this.getItem(id))){
  207. tab = new Ext.Panel({
  208. id: id,
  209. cls:'preview single-preview',
  210. title: d.title,
  211. tabTip: d.title,
  212. html: FeedViewer.getTemplate().apply(d),
  213. closable:true,
  214. listeners: FeedViewer.LinkInterceptor,
  215. autoScroll:true,
  216. border:true,
  217. tbar: [{
  218. text: 'Go to Post',
  219. iconCls: 'new-win',
  220. handler : function(){
  221. window.open(d.link);
  222. }
  223. }]
  224. });
  225. this.add(tab);
  226. }
  227. this.setActiveTab(tab);
  228. },
  229. openAll : function(){
  230. this.beginUpdate();
  231. this.grid.store.data.each(this.openTab, this);
  232. this.endUpdate();
  233. }
  234. });