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.

138 lines
4.1 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. Ext.ns('Ext.ux.menu');
  16. <div id="cls-Ext.ux.menu.RangeMenu"></div>/**
  17. * @class Ext.ux.menu.RangeMenu
  18. * @extends Ext.menu.Menu
  19. * Custom implementation of Ext.menu.Menu that has preconfigured
  20. * items for gt, lt, eq.
  21. * <p><b><u>Example Usage:</u></b></p>
  22. * <pre><code>
  23. * </code></pre>
  24. */
  25. Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
  26. constructor : function (config) {
  27. Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
  28. this.addEvents(
  29. <div id="event-Ext.ux.menu.RangeMenu-update"></div>/**
  30. * @event update
  31. * Fires when a filter configuration has changed
  32. * @param {Ext.ux.grid.filter.Filter} this The filter object.
  33. */
  34. 'update'
  35. );
  36. this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
  37. var i, len, item, cfg, Cls;
  38. for (i = 0, len = this.menuItems.length; i < len; i++) {
  39. item = this.menuItems[i];
  40. if (item !== '-') {
  41. // defaults
  42. cfg = {
  43. itemId: 'range-' + item,
  44. enableKeyEvents: true,
  45. iconCls: this.iconCls[item] || 'no-icon',
  46. listeners: {
  47. scope: this,
  48. keyup: this.onInputKeyUp
  49. }
  50. };
  51. Ext.apply(
  52. cfg,
  53. // custom configs
  54. Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
  55. // configurable defaults
  56. this.menuItemCfgs
  57. );
  58. Cls = cfg.fieldCls || this.fieldCls;
  59. item = this.fields[item] = new Cls(cfg);
  60. }
  61. this.add(item);
  62. }
  63. },
  64. /**
  65. * @private
  66. * called by this.updateTask
  67. */
  68. fireUpdate : function () {
  69. this.fireEvent('update', this);
  70. },
  71. <div id="method-Ext.ux.menu.RangeMenu-getValue"></div>/**
  72. * Get and return the value of the filter.
  73. * @return {String} The value of this filter
  74. */
  75. getValue : function () {
  76. var result = {}, key, field;
  77. for (key in this.fields) {
  78. field = this.fields[key];
  79. if (field.isValid() && String(field.getValue()).length > 0) {
  80. result[key] = field.getValue();
  81. }
  82. }
  83. return result;
  84. },
  85. <div id="method-Ext.ux.menu.RangeMenu-setValue"></div>/**
  86. * Set the value of this menu and fires the 'update' event.
  87. * @param {Object} data The data to assign to this menu
  88. */
  89. setValue : function (data) {
  90. var key;
  91. for (key in this.fields) {
  92. this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
  93. }
  94. this.fireEvent('update', this);
  95. },
  96. /**
  97. * @private
  98. * Handler method called when there is a keyup event on an input
  99. * item of this menu.
  100. */
  101. onInputKeyUp : function (field, e) {
  102. var k = e.getKey();
  103. if (k == e.RETURN && field.isValid()) {
  104. e.stopEvent();
  105. this.hide(true);
  106. return;
  107. }
  108. if (field == this.fields.eq) {
  109. if (this.fields.gt) {
  110. this.fields.gt.setValue(null);
  111. }
  112. if (this.fields.lt) {
  113. this.fields.lt.setValue(null);
  114. }
  115. }
  116. else {
  117. this.fields.eq.setValue(null);
  118. }
  119. // restart the timer
  120. this.updateTask.delay(this.updateBuffer);
  121. }
  122. });
  123. </pre>
  124. </body>
  125. </html>