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.

242 lines
8.2 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. Ext.onReady(function(){
  8. // This is a shared function that simulates a load action on a StatusBar.
  9. // It is reused by most of the example panels.
  10. var loadFn = function(btn, statusBar){
  11. btn = Ext.getCmp(btn);
  12. statusBar = Ext.getCmp(statusBar);
  13. btn.disable();
  14. statusBar.showBusy();
  15. (function(){
  16. statusBar.clearStatus({useDefaults:true});
  17. btn.enable();
  18. }).defer(2000);
  19. };
  20. /*
  21. * ================ Basic StatusBar example =======================
  22. */
  23. new Ext.Panel({
  24. title: 'Basic StatusBar',
  25. renderTo: 'basic',
  26. width: 550,
  27. height: 100,
  28. bodyStyle: 'padding:10px;',
  29. items:[{
  30. xtype: 'button',
  31. id: 'basic-button',
  32. text: 'Do Loading',
  33. handler: loadFn.createCallback('basic-button', 'basic-statusbar')
  34. }],
  35. bbar: new Ext.ux.StatusBar({
  36. id: 'basic-statusbar',
  37. // defaults to use when the status is cleared:
  38. defaultText: 'Default status text',
  39. //defaultIconCls: 'default-icon',
  40. // values to set initially:
  41. text: 'Ready',
  42. iconCls: 'x-status-valid',
  43. // any standard Toolbar items:
  44. items: [
  45. {
  46. text: 'Show Warning & Clear',
  47. handler: function (){
  48. var sb = Ext.getCmp('basic-statusbar');
  49. sb.setStatus({
  50. text: 'Oops!',
  51. iconCls: 'x-status-error',
  52. clear: true // auto-clear after a set interval
  53. });
  54. }
  55. },
  56. {
  57. text: 'Show Busy',
  58. handler: function (){
  59. var sb = Ext.getCmp('basic-statusbar');
  60. // Set the status bar to show that something is processing:
  61. sb.showBusy();
  62. }
  63. },
  64. {
  65. text: 'Clear status',
  66. handler: function (){
  67. var sb = Ext.getCmp('basic-statusbar');
  68. // once completed
  69. sb.clearStatus();
  70. }
  71. },
  72. '-',
  73. 'Plain Text'
  74. ]
  75. })
  76. });
  77. /*
  78. * ================ Right-aligned StatusBar example =======================
  79. */
  80. new Ext.Panel({
  81. title: 'Right-aligned StatusBar',
  82. renderTo: 'right-aligned',
  83. width: 550,
  84. height: 100,
  85. bodyStyle: 'padding:10px;',
  86. items:[{
  87. xtype: 'button',
  88. id: 'right-button',
  89. text: 'Do Loading',
  90. handler: loadFn.createCallback('right-button', 'right-statusbar')
  91. }],
  92. bbar: new Ext.ux.StatusBar({
  93. defaultText: 'Default status',
  94. id: 'right-statusbar',
  95. statusAlign: 'right', // the magic config
  96. items: [{
  97. text: 'A Button'
  98. }, '-', 'Plain Text', ' ', ' ']
  99. })
  100. });
  101. /*
  102. * ================ StatusBar Window example =======================
  103. */
  104. var win = new Ext.Window({
  105. title: 'StatusBar Window',
  106. width: 400,
  107. minWidth: 350,
  108. height: 150,
  109. modal: true,
  110. closeAction: 'hide',
  111. bodyStyle: 'padding:10px;',
  112. items:[{
  113. xtype: 'button',
  114. id: 'win-button',
  115. text: 'Do Loading',
  116. handler: loadFn.createCallback('win-button', 'win-statusbar')
  117. }],
  118. bbar: new Ext.ux.StatusBar({
  119. id: 'win-statusbar',
  120. defaultText: 'Ready',
  121. items: [{
  122. text: 'A Button'
  123. }, '-',
  124. new Date().format('n/d/Y'), ' ', ' ', '-', {
  125. xtype:'tbsplit',
  126. text:'Status Menu',
  127. menuAlign: 'br-tr?',
  128. menu: new Ext.menu.Menu({
  129. items: [{text: 'Item 1'}, {text: 'Item 2'}]
  130. })
  131. }]
  132. })
  133. });
  134. new Ext.Button({
  135. text: 'Show Window',
  136. renderTo: 'window',
  137. handler: function(){
  138. win.show();
  139. }
  140. });
  141. /*
  142. * ================ Ext Word Processor example =======================
  143. *
  144. * The StatusBar used in this example is completely standard. What is
  145. * customized are the styles and event handling to make the example a
  146. * lot more dynamic and application-oriented.
  147. *
  148. */
  149. // Create these explicitly so we can manipulate them later
  150. var wordCount = new Ext.Toolbar.TextItem('Words: 0');
  151. var charCount = new Ext.Toolbar.TextItem('Chars: 0');
  152. var clock = new Ext.Toolbar.TextItem('');
  153. new Ext.Panel({
  154. title: 'Ext Word Processor',
  155. renderTo: 'word-proc',
  156. width: 500,
  157. autoHeight: true,
  158. bodyStyle: 'padding:5px;',
  159. layout: 'fit',
  160. bbar: new Ext.ux.StatusBar({
  161. id: 'word-status',
  162. // These are just the standard toolbar TextItems we created above. They get
  163. // custom classes below in the render handler which is what gives them their
  164. // customized inset appearance.
  165. items: [wordCount, ' ', charCount, ' ', clock, ' ']
  166. }),
  167. items: {
  168. xtype: 'textarea',
  169. id: 'word-textarea',
  170. enableKeyEvents: true,
  171. grow: true,
  172. growMin: 100,
  173. growMax: 200,
  174. listeners: {
  175. // After each keypress update the word and character count text items
  176. 'keypress': {
  177. fn: function(t){
  178. var v = t.getValue(),
  179. wc = 0, cc = v.length ? v.length : 0;
  180. if(cc > 0){
  181. wc = v.match(/\b/g);
  182. wc = wc ? wc.length / 2 : 0;
  183. }
  184. Ext.fly(wordCount.getEl()).update('Words: '+wc);
  185. Ext.fly(charCount.getEl()).update('Chars: '+cc);
  186. },
  187. buffer: 1 // buffer to allow the value to update first
  188. }
  189. }
  190. },
  191. listeners: {
  192. render: {
  193. fn: function(){
  194. // Add a class to the parent TD of each text item so we can give them some custom inset box
  195. // styling. Also, since we are using a greedy spacer, we have to add a block level element
  196. // into each text TD in order to give them a fixed width (TextItems are spans). Insert a
  197. // spacer div into each TD using createChild() so that we can give it a width in CSS.
  198. Ext.fly(wordCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  199. Ext.fly(charCount.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  200. Ext.fly(clock.getEl().parent()).addClass('x-status-text-panel').createChild({cls:'spacer'});
  201. // Kick off the clock timer that updates the clock el every second:
  202. Ext.TaskMgr.start({
  203. run: function(){
  204. Ext.fly(clock.getEl()).update(new Date().format('g:i:s A'));
  205. },
  206. interval: 1000
  207. });
  208. },
  209. delay: 100
  210. }
  211. }
  212. });
  213. // This sets up a fake auto-save function. It monitors keyboard activity and after no typing
  214. // has occurred for 1.5 seconds, it updates the status message to indicate that it's saving.
  215. // After a fake delay so that you can see the save activity it will update again to indicate
  216. // that the action succeeded.
  217. Ext.fly('word-textarea').on('keypress', function(){
  218. var sb = Ext.getCmp('word-status');
  219. sb.showBusy('Saving draft...');
  220. (function(){
  221. sb.setStatus({
  222. iconCls: 'x-status-saved',
  223. text: 'Draft auto-saved at ' + new Date().format('g:i:s A')
  224. });
  225. }).defer(4000);
  226. }, this, {buffer:1500});
  227. });