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.

428 lines
16 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.ux.StatusBar"></div>/**
  16. * @class Ext.ux.StatusBar
  17. * <p>Basic status bar component that can be used as the bottom toolbar of any {@link Ext.Panel}. In addition to
  18. * supporting the standard {@link Ext.Toolbar} interface for adding buttons, menus and other items, the StatusBar
  19. * provides a greedy status element that can be aligned to either side and has convenient methods for setting the
  20. * status text and icon. You can also indicate that something is processing using the {@link #showBusy} method.</p>
  21. * <pre><code>
  22. new Ext.Panel({
  23. title: 'StatusBar',
  24. // etc.
  25. bbar: new Ext.ux.StatusBar({
  26. id: 'my-status',
  27. // defaults to use when the status is cleared:
  28. defaultText: 'Default status text',
  29. defaultIconCls: 'default-icon',
  30. // values to set initially:
  31. text: 'Ready',
  32. iconCls: 'ready-icon',
  33. // any standard Toolbar items:
  34. items: [{
  35. text: 'A Button'
  36. }, '-', 'Plain Text']
  37. })
  38. });
  39. // Update the status bar later in code:
  40. var sb = Ext.getCmp('my-status');
  41. sb.setStatus({
  42. text: 'OK',
  43. iconCls: 'ok-icon',
  44. clear: true // auto-clear after a set interval
  45. });
  46. // Set the status bar to show that something is processing:
  47. sb.showBusy();
  48. // processing....
  49. sb.clearStatus(); // once completeed
  50. </code></pre>
  51. * @extends Ext.Toolbar
  52. * @constructor
  53. * Creates a new StatusBar
  54. * @param {Object/Array} config A config object
  55. */
  56. Ext.ux.StatusBar = Ext.extend(Ext.Toolbar, {
  57. <div id="cfg-Ext.ux.StatusBar-statusAlign"></div>/**
  58. * @cfg {String} statusAlign
  59. * The alignment of the status element within the overall StatusBar layout. When the StatusBar is rendered,
  60. * it creates an internal div containing the status text and icon. Any additional Toolbar items added in the
  61. * StatusBar's {@link #items} config, or added via {@link #add} or any of the supported add* methods, will be
  62. * rendered, in added order, to the opposite side. The status element is greedy, so it will automatically
  63. * expand to take up all sapce left over by any other items. Example usage:
  64. * <pre><code>
  65. // Create a left-aligned status bar containing a button,
  66. // separator and text item that will be right-aligned (default):
  67. new Ext.Panel({
  68. title: 'StatusBar',
  69. // etc.
  70. bbar: new Ext.ux.StatusBar({
  71. defaultText: 'Default status text',
  72. id: 'status-id',
  73. items: [{
  74. text: 'A Button'
  75. }, '-', 'Plain Text']
  76. })
  77. });
  78. // By adding the statusAlign config, this will create the
  79. // exact same toolbar, except the status and toolbar item
  80. // layout will be reversed from the previous example:
  81. new Ext.Panel({
  82. title: 'StatusBar',
  83. // etc.
  84. bbar: new Ext.ux.StatusBar({
  85. defaultText: 'Default status text',
  86. id: 'status-id',
  87. statusAlign: 'right',
  88. items: [{
  89. text: 'A Button'
  90. }, '-', 'Plain Text']
  91. })
  92. });
  93. </code></pre>
  94. */
  95. <div id="cfg-Ext.ux.StatusBar-defaultText"></div>/**
  96. * @cfg {String} defaultText
  97. * The default {@link #text} value. This will be used anytime the status bar is cleared with the
  98. * <tt>useDefaults:true</tt> option (defaults to '').
  99. */
  100. <div id="cfg-Ext.ux.StatusBar-defaultIconCls"></div>/**
  101. * @cfg {String} defaultIconCls
  102. * The default {@link #iconCls} value (see the iconCls docs for additional details about customizing the icon).
  103. * This will be used anytime the status bar is cleared with the <tt>useDefaults:true</tt> option (defaults to '').
  104. */
  105. <div id="cfg-Ext.ux.StatusBar-text"></div>/**
  106. * @cfg {String} text
  107. * A string that will be <b>initially</b> set as the status message. This string
  108. * will be set as innerHTML (html tags are accepted) for the toolbar item.
  109. * If not specified, the value set for <code>{@link #defaultText}</code>
  110. * will be used.
  111. */
  112. <div id="cfg-Ext.ux.StatusBar-iconCls"></div>/**
  113. * @cfg {String} iconCls
  114. * A CSS class that will be <b>initially</b> set as the status bar icon and is
  115. * expected to provide a background image (defaults to '').
  116. * Example usage:<pre><code>
  117. // Example CSS rule:
  118. .x-statusbar .x-status-custom {
  119. padding-left: 25px;
  120. background: transparent url(images/custom-icon.gif) no-repeat 3px 2px;
  121. }
  122. // Setting a default icon:
  123. var sb = new Ext.ux.StatusBar({
  124. defaultIconCls: 'x-status-custom'
  125. });
  126. // Changing the icon:
  127. sb.setStatus({
  128. text: 'New status',
  129. iconCls: 'x-status-custom'
  130. });
  131. </code></pre>
  132. */
  133. <div id="cfg-Ext.ux.StatusBar-cls"></div>/**
  134. * @cfg {String} cls
  135. * The base class applied to the containing element for this component on render (defaults to 'x-statusbar')
  136. */
  137. cls : 'x-statusbar',
  138. <div id="cfg-Ext.ux.StatusBar-busyIconCls"></div>/**
  139. * @cfg {String} busyIconCls
  140. * The default <code>{@link #iconCls}</code> applied when calling
  141. * <code>{@link #showBusy}</code> (defaults to <tt>'x-status-busy'</tt>).
  142. * It can be overridden at any time by passing the <code>iconCls</code>
  143. * argument into <code>{@link #showBusy}</code>.
  144. */
  145. busyIconCls : 'x-status-busy',
  146. <div id="cfg-Ext.ux.StatusBar-busyText"></div>/**
  147. * @cfg {String} busyText
  148. * The default <code>{@link #text}</code> applied when calling
  149. * <code>{@link #showBusy}</code> (defaults to <tt>'Loading...'</tt>).
  150. * It can be overridden at any time by passing the <code>text</code>
  151. * argument into <code>{@link #showBusy}</code>.
  152. */
  153. busyText : 'Loading...',
  154. <div id="cfg-Ext.ux.StatusBar-autoClear"></div>/**
  155. * @cfg {Number} autoClear
  156. * The number of milliseconds to wait after setting the status via
  157. * <code>{@link #setStatus}</code> before automatically clearing the status
  158. * text and icon (defaults to <tt>5000</tt>). Note that this only applies
  159. * when passing the <tt>clear</tt> argument to <code>{@link #setStatus}</code>
  160. * since that is the only way to defer clearing the status. This can
  161. * be overridden by specifying a different <tt>wait</tt> value in
  162. * <code>{@link #setStatus}</code>. Calls to <code>{@link #clearStatus}</code>
  163. * always clear the status bar immediately and ignore this value.
  164. */
  165. autoClear : 5000,
  166. <div id="cfg-Ext.ux.StatusBar-emptyText"></div>/**
  167. * @cfg {String} emptyText
  168. * The text string to use if no text has been set. Defaults to
  169. * <tt>'&nbsp;'</tt>). If there are no other items in the toolbar using
  170. * an empty string (<tt>''</tt>) for this value would end up in the toolbar
  171. * height collapsing since the empty string will not maintain the toolbar
  172. * height. Use <tt>''</tt> if the toolbar should collapse in height
  173. * vertically when no text is specified and there are no other items in
  174. * the toolbar.
  175. */
  176. emptyText : '&nbsp;',
  177. // private
  178. activeThreadId : 0,
  179. // private
  180. initComponent : function(){
  181. if(this.statusAlign=='right'){
  182. this.cls += ' x-status-right';
  183. }
  184. Ext.ux.StatusBar.superclass.initComponent.call(this);
  185. },
  186. // private
  187. afterRender : function(){
  188. Ext.ux.StatusBar.superclass.afterRender.call(this);
  189. var right = this.statusAlign == 'right';
  190. this.currIconCls = this.iconCls || this.defaultIconCls;
  191. this.statusEl = new Ext.Toolbar.TextItem({
  192. cls: 'x-status-text ' + (this.currIconCls || ''),
  193. text: this.text || this.defaultText || ''
  194. });
  195. if(right){
  196. this.add('->');
  197. this.add(this.statusEl);
  198. }else{
  199. this.insert(0, this.statusEl);
  200. this.insert(1, '->');
  201. }
  202. this.doLayout();
  203. },
  204. <div id="method-Ext.ux.StatusBar-setStatus"></div>/**
  205. * Sets the status {@link #text} and/or {@link #iconCls}. Also supports automatically clearing the
  206. * status that was set after a specified interval.
  207. * @param {Object/String} config A config object specifying what status to set, or a string assumed
  208. * to be the status text (and all other options are defaulted as explained below). A config
  209. * object containing any or all of the following properties can be passed:<ul>
  210. * <li><tt>text</tt> {String} : (optional) The status text to display. If not specified, any current
  211. * status text will remain unchanged.</li>
  212. * <li><tt>iconCls</tt> {String} : (optional) The CSS class used to customize the status icon (see
  213. * {@link #iconCls} for details). If not specified, any current iconCls will remain unchanged.</li>
  214. * <li><tt>clear</tt> {Boolean/Number/Object} : (optional) Allows you to set an internal callback that will
  215. * automatically clear the status text and iconCls after a specified amount of time has passed. If clear is not
  216. * specified, the new status will not be auto-cleared and will stay until updated again or cleared using
  217. * {@link #clearStatus}. If <tt>true</tt> is passed, the status will be cleared using {@link #autoClear},
  218. * {@link #defaultText} and {@link #defaultIconCls} via a fade out animation. If a numeric value is passed,
  219. * it will be used as the callback interval (in milliseconds), overriding the {@link #autoClear} value.
  220. * All other options will be defaulted as with the boolean option. To customize any other options,
  221. * you can pass an object in the format:<ul>
  222. * <li><tt>wait</tt> {Number} : (optional) The number of milliseconds to wait before clearing
  223. * (defaults to {@link #autoClear}).</li>
  224. * <li><tt>anim</tt> {Number} : (optional) False to clear the status immediately once the callback
  225. * executes (defaults to true which fades the status out).</li>
  226. * <li><tt>useDefaults</tt> {Number} : (optional) False to completely clear the status text and iconCls
  227. * (defaults to true which uses {@link #defaultText} and {@link #defaultIconCls}).</li>
  228. * </ul></li></ul>
  229. * Example usage:<pre><code>
  230. // Simple call to update the text
  231. statusBar.setStatus('New status');
  232. // Set the status and icon, auto-clearing with default options:
  233. statusBar.setStatus({
  234. text: 'New status',
  235. iconCls: 'x-status-custom',
  236. clear: true
  237. });
  238. // Auto-clear with custom options:
  239. statusBar.setStatus({
  240. text: 'New status',
  241. iconCls: 'x-status-custom',
  242. clear: {
  243. wait: 8000,
  244. anim: false,
  245. useDefaults: false
  246. }
  247. });
  248. </code></pre>
  249. * @return {Ext.ux.StatusBar} this
  250. */
  251. setStatus : function(o){
  252. o = o || {};
  253. if(typeof o == 'string'){
  254. o = {text:o};
  255. }
  256. if(o.text !== undefined){
  257. this.setText(o.text);
  258. }
  259. if(o.iconCls !== undefined){
  260. this.setIcon(o.iconCls);
  261. }
  262. if(o.clear){
  263. var c = o.clear,
  264. wait = this.autoClear,
  265. defaults = {useDefaults: true, anim: true};
  266. if(typeof c == 'object'){
  267. c = Ext.applyIf(c, defaults);
  268. if(c.wait){
  269. wait = c.wait;
  270. }
  271. }else if(typeof c == 'number'){
  272. wait = c;
  273. c = defaults;
  274. }else if(typeof c == 'boolean'){
  275. c = defaults;
  276. }
  277. c.threadId = this.activeThreadId;
  278. this.clearStatus.defer(wait, this, [c]);
  279. }
  280. return this;
  281. },
  282. <div id="method-Ext.ux.StatusBar-clearStatus"></div>/**
  283. * Clears the status {@link #text} and {@link #iconCls}. Also supports clearing via an optional fade out animation.
  284. * @param {Object} config (optional) A config object containing any or all of the following properties. If this
  285. * object is not specified the status will be cleared using the defaults below:<ul>
  286. * <li><tt>anim</tt> {Boolean} : (optional) True to clear the status by fading out the status element (defaults
  287. * to false which clears immediately).</li>
  288. * <li><tt>useDefaults</tt> {Boolean} : (optional) True to reset the text and icon using {@link #defaultText} and
  289. * {@link #defaultIconCls} (defaults to false which sets the text to '' and removes any existing icon class).</li>
  290. * </ul>
  291. * @return {Ext.ux.StatusBar} this
  292. */
  293. clearStatus : function(o){
  294. o = o || {};
  295. if(o.threadId && o.threadId !== this.activeThreadId){
  296. // this means the current call was made internally, but a newer
  297. // thread has set a message since this call was deferred. Since
  298. // we don't want to overwrite a newer message just ignore.
  299. return this;
  300. }
  301. var text = o.useDefaults ? this.defaultText : this.emptyText,
  302. iconCls = o.useDefaults ? (this.defaultIconCls ? this.defaultIconCls : '') : '';
  303. if(o.anim){
  304. // animate the statusEl Ext.Element
  305. this.statusEl.el.fadeOut({
  306. remove: false,
  307. useDisplay: true,
  308. scope: this,
  309. callback: function(){
  310. this.setStatus({
  311. text: text,
  312. iconCls: iconCls
  313. });
  314. this.statusEl.el.show();
  315. }
  316. });
  317. }else{
  318. // hide/show the el to avoid jumpy text or icon
  319. this.statusEl.hide();
  320. this.setStatus({
  321. text: text,
  322. iconCls: iconCls
  323. });
  324. this.statusEl.show();
  325. }
  326. return this;
  327. },
  328. <div id="method-Ext.ux.StatusBar-setText"></div>/**
  329. * Convenience method for setting the status text directly. For more flexible options see {@link #setStatus}.
  330. * @param {String} text (optional) The text to set (defaults to '')
  331. * @return {Ext.ux.StatusBar} this
  332. */
  333. setText : function(text){
  334. this.activeThreadId++;
  335. this.text = text || '';
  336. if(this.rendered){
  337. this.statusEl.setText(this.text);
  338. }
  339. return this;
  340. },
  341. <div id="method-Ext.ux.StatusBar-getText"></div>/**
  342. * Returns the current status text.
  343. * @return {String} The status text
  344. */
  345. getText : function(){
  346. return this.text;
  347. },
  348. <div id="method-Ext.ux.StatusBar-setIcon"></div>/**
  349. * Convenience method for setting the status icon directly. For more flexible options see {@link #setStatus}.
  350. * See {@link #iconCls} for complete details about customizing the icon.
  351. * @param {String} iconCls (optional) The icon class to set (defaults to '', and any current icon class is removed)
  352. * @return {Ext.ux.StatusBar} this
  353. */
  354. setIcon : function(cls){
  355. this.activeThreadId++;
  356. cls = cls || '';
  357. if(this.rendered){
  358. if(this.currIconCls){
  359. this.statusEl.removeClass(this.currIconCls);
  360. this.currIconCls = null;
  361. }
  362. if(cls.length > 0){
  363. this.statusEl.addClass(cls);
  364. this.currIconCls = cls;
  365. }
  366. }else{
  367. this.currIconCls = cls;
  368. }
  369. return this;
  370. },
  371. <div id="method-Ext.ux.StatusBar-showBusy"></div>/**
  372. * Convenience method for setting the status text and icon to special values that are pre-configured to indicate
  373. * a "busy" state, usually for loading or processing activities.
  374. * @param {Object/String} config (optional) A config object in the same format supported by {@link #setStatus}, or a
  375. * string to use as the status text (in which case all other options for setStatus will be defaulted). Use the
  376. * <tt>text</tt> and/or <tt>iconCls</tt> properties on the config to override the default {@link #busyText}
  377. * and {@link #busyIconCls} settings. If the config argument is not specified, {@link #busyText} and
  378. * {@link #busyIconCls} will be used in conjunction with all of the default options for {@link #setStatus}.
  379. * @return {Ext.ux.StatusBar} this
  380. */
  381. showBusy : function(o){
  382. if(typeof o == 'string'){
  383. o = {text:o};
  384. }
  385. o = Ext.applyIf(o || {}, {
  386. text: this.busyText,
  387. iconCls: this.busyIconCls
  388. });
  389. return this.setStatus(o);
  390. }
  391. });
  392. Ext.reg('statusbar', Ext.ux.StatusBar);
  393. </pre>
  394. </body>
  395. </html>