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.

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