Web UI for ARGUS server
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.

192 lines
6.1 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.form.SliderField"></div>/**
  16. * @class Ext.form.SliderField
  17. * @extends Ext.form.Field
  18. * Wraps a {@link Ext.slider.MultiSlider Slider} so it can be used as a form field.
  19. * @constructor
  20. * Creates a new SliderField
  21. * @param {Object} config Configuration options. Note that you can pass in any slider configuration options, as well as
  22. * as any field configuration options.
  23. * @xtype sliderfield
  24. */
  25. Ext.form.SliderField = Ext.extend(Ext.form.Field, {
  26. <div id="cfg-Ext.form.SliderField-useTips"></div>/**
  27. * @cfg {Boolean} useTips
  28. * True to use an Ext.slider.Tip to display tips for the value. Defaults to <tt>true</tt>.
  29. */
  30. useTips : true,
  31. <div id="cfg-Ext.form.SliderField-tipText"></div>/**
  32. * @cfg {Function} tipText
  33. * A function used to display custom text for the slider tip. Defaults to <tt>null</tt>, which will
  34. * use the default on the plugin.
  35. */
  36. tipText : null,
  37. // private override
  38. actionMode: 'wrap',
  39. /**
  40. * Initialize the component.
  41. * @private
  42. */
  43. initComponent : function() {
  44. var cfg = Ext.copyTo({
  45. id: this.id + '-slider'
  46. }, this.initialConfig, ['vertical', 'minValue', 'maxValue', 'decimalPrecision', 'keyIncrement', 'increment', 'clickToChange', 'animate']);
  47. // only can use it if it exists.
  48. if (this.useTips) {
  49. var plug = this.tipText ? {getText: this.tipText} : {};
  50. cfg.plugins = [new Ext.slider.Tip(plug)];
  51. }
  52. this.slider = new Ext.Slider(cfg);
  53. Ext.form.SliderField.superclass.initComponent.call(this);
  54. },
  55. /**
  56. * Set up the hidden field
  57. * @param {Object} ct The container to render to.
  58. * @param {Object} position The position in the container to render to.
  59. * @private
  60. */
  61. onRender : function(ct, position){
  62. this.autoCreate = {
  63. id: this.id,
  64. name: this.name,
  65. type: 'hidden',
  66. tag: 'input'
  67. };
  68. Ext.form.SliderField.superclass.onRender.call(this, ct, position);
  69. this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
  70. this.resizeEl = this.positionEl = this.wrap;
  71. this.slider.render(this.wrap);
  72. },
  73. /**
  74. * Ensure that the slider size is set automatically when the field resizes.
  75. * @param {Object} w The width
  76. * @param {Object} h The height
  77. * @param {Object} aw The adjusted width
  78. * @param {Object} ah The adjusted height
  79. * @private
  80. */
  81. onResize : function(w, h, aw, ah){
  82. Ext.form.SliderField.superclass.onResize.call(this, w, h, aw, ah);
  83. this.slider.setSize(w, h);
  84. },
  85. /**
  86. * Initialize any events for this class.
  87. * @private
  88. */
  89. initEvents : function(){
  90. Ext.form.SliderField.superclass.initEvents.call(this);
  91. this.slider.on('change', this.onChange, this);
  92. },
  93. /**
  94. * Utility method to set the value of the field when the slider changes.
  95. * @param {Object} slider The slider object.
  96. * @param {Object} v The new value.
  97. * @private
  98. */
  99. onChange : function(slider, v){
  100. this.setValue(v, undefined, true);
  101. },
  102. /**
  103. * Enable the slider when the field is enabled.
  104. * @private
  105. */
  106. onEnable : function(){
  107. Ext.form.SliderField.superclass.onEnable.call(this);
  108. this.slider.enable();
  109. },
  110. /**
  111. * Disable the slider when the field is disabled.
  112. * @private
  113. */
  114. onDisable : function(){
  115. Ext.form.SliderField.superclass.onDisable.call(this);
  116. this.slider.disable();
  117. },
  118. /**
  119. * Ensure the slider is destroyed when the field is destroyed.
  120. * @private
  121. */
  122. beforeDestroy : function(){
  123. Ext.destroy(this.slider);
  124. Ext.form.SliderField.superclass.beforeDestroy.call(this);
  125. },
  126. /**
  127. * If a side icon is shown, do alignment to the slider
  128. * @private
  129. */
  130. alignErrorIcon : function(){
  131. this.errorIcon.alignTo(this.slider.el, 'tl-tr', [2, 0]);
  132. },
  133. <div id="method-Ext.form.SliderField-setMinValue"></div>/**
  134. * Sets the minimum field value.
  135. * @param {Number} v The new minimum value.
  136. * @return {Ext.form.SliderField} this
  137. */
  138. setMinValue : function(v){
  139. this.slider.setMinValue(v);
  140. return this;
  141. },
  142. <div id="method-Ext.form.SliderField-setMaxValue"></div>/**
  143. * Sets the maximum field value.
  144. * @param {Number} v The new maximum value.
  145. * @return {Ext.form.SliderField} this
  146. */
  147. setMaxValue : function(v){
  148. this.slider.setMaxValue(v);
  149. return this;
  150. },
  151. <div id="method-Ext.form.SliderField-setValue"></div>/**
  152. * Sets the value for this field.
  153. * @param {Number} v The new value.
  154. * @param {Boolean} animate (optional) Whether to animate the transition. If not specified, it will default to the animate config.
  155. * @return {Ext.form.SliderField} this
  156. */
  157. setValue : function(v, animate, /* private */ silent){
  158. // silent is used if the setValue method is invoked by the slider
  159. // which means we don't need to set the value on the slider.
  160. if(!silent){
  161. this.slider.setValue(v, animate);
  162. }
  163. return Ext.form.SliderField.superclass.setValue.call(this, this.slider.getValue());
  164. },
  165. <div id="method-Ext.form.SliderField-getValue"></div>/**
  166. * Gets the current value for this field.
  167. * @return {Number} The current value.
  168. */
  169. getValue : function(){
  170. return this.slider.getValue();
  171. }
  172. });
  173. Ext.reg('sliderfield', Ext.form.SliderField);</pre>
  174. </body>
  175. </html>