Web Interface For Lite Argus Control modules
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.

244 lines
7.3 KiB

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