4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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> * @class Ext.slider.Single
20 * @extends Ext.slider.Multi
21 * Slider which supports vertical or horizontal orientation, keyboard adjustments,
22 * configurable snapping, axis clicking and animation. Can be added as an item to
24 * {@img Ext.slider.Single/Ext.slider.Single.png Ext.slider.Single component}
26 <pre><code>
27 Ext.create('Ext.slider.Single', {
33 renderTo: Ext.getBody()
35 </code></pre>
36 * The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.
39 Ext.define('Ext.slider.Single', {
40 extend: 'Ext.slider.Multi',
41 alias: ['widget.slider', 'widget.sliderfield'],
42 alternateClassName: ['Ext.Slider', 'Ext.form.SliderField', 'Ext.slider.SingleSlider', 'Ext.slider.Slider'],
44 <span id='Ext-slider-Single-method-getValue'> /**
45 </span> * Returns the current value of the slider
46 * @return {Number} The current value of the slider
48 getValue: function() {
49 //just returns the value of the first thumb, which should be the only one in a single slider
50 return this.callParent([0]);
53 <span id='Ext-slider-Single-method-setValue'> /**
54 </span> * Programmatically sets the value of the Slider. Ensures that the value is constrained within
55 * the minValue and maxValue.
56 * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
57 * @param {Boolean} animate Turn on or off animation, defaults to true
59 setValue: function(value, animate) {
60 var args = Ext.toArray(arguments),
63 //this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
64 //index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
65 //signature without the required index. The index will always be 0 for a single slider
66 if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
70 return this.callParent(args);
74 getNearest : function(){
75 // Since there's only 1 thumb, it's always the nearest
76 return this.thumbs[0];