Single.html 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-slider-Single'>/**
  19. </span> * Slider which supports vertical or horizontal orientation, keyboard adjustments, configurable snapping, axis clicking
  20. * and animation. Can be added as an item to any container.
  21. *
  22. * @example
  23. * Ext.create('Ext.slider.Single', {
  24. * width: 200,
  25. * value: 50,
  26. * increment: 10,
  27. * minValue: 0,
  28. * maxValue: 100,
  29. * renderTo: Ext.getBody()
  30. * });
  31. *
  32. * The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.
  33. */
  34. Ext.define('Ext.slider.Single', {
  35. extend: 'Ext.slider.Multi',
  36. alias: ['widget.slider', 'widget.sliderfield'],
  37. alternateClassName: ['Ext.Slider', 'Ext.form.SliderField', 'Ext.slider.SingleSlider', 'Ext.slider.Slider'],
  38. <span id='Ext-slider-Single-method-getValue'> /**
  39. </span> * Returns the current value of the slider
  40. * @return {Number} The current value of the slider
  41. */
  42. getValue: function() {
  43. // just returns the value of the first thumb, which should be the only one in a single slider
  44. return this.callParent([0]);
  45. },
  46. <span id='Ext-slider-Single-method-setValue'> /**
  47. </span> * Programmatically sets the value of the Slider. Ensures that the value is constrained within the minValue and
  48. * maxValue.
  49. * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
  50. * @param {Boolean} [animate] Turn on or off animation
  51. */
  52. setValue: function(value, animate) {
  53. var args = arguments,
  54. len = args.length;
  55. // this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
  56. // index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
  57. // signature without the required index. The index will always be 0 for a single slider
  58. if (len == 1 || (len &lt;= 3 &amp;&amp; typeof args[1] != 'number')) {
  59. args = Ext.toArray(args);
  60. args.unshift(0);
  61. }
  62. return this.callParent(args);
  63. },
  64. // private
  65. getNearest : function(){
  66. // Since there's only 1 thumb, it's always the nearest
  67. return this.thumbs[0];
  68. }
  69. });
  70. </pre>
  71. </body>
  72. </html>