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.

196 lines
6.9 KiB

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