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; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
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.
23 * Ext.create('Ext.slider.Single', {
29 * renderTo: Ext.getBody()
32 * The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.
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'],
39 <span id='Ext-slider-Single-method-getValue'> /**
40 </span> * Returns the current value of the slider
41 * @return {Number} The current value of the slider
43 getValue: function() {
44 // just returns the value of the first thumb, which should be the only one in a single slider
45 return this.callParent([0]);
48 <span id='Ext-slider-Single-method-setValue'> /**
49 </span> * Programmatically sets the value of the Slider. Ensures that the value is constrained within the minValue and
51 * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
52 * @param {Boolean} [animate] Turn on or off animation
54 setValue: function(value, animate) {
55 var args = Ext.toArray(arguments),
58 // this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
59 // index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
60 // signature without the required index. The index will always be 0 for a single slider
61 if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
65 return this.callParent(args);
69 getNearest : function(){
70 // Since there's only 1 thumb, it's always the nearest
71 return this.thumbs[0];