Single.html
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js"><span id='Ext-slider-Single'>/**
</span> * Slider which supports vertical or horizontal orientation, keyboard adjustments, configurable snapping, axis clicking
* and animation. Can be added as an item to any container.
*
* @example
* Ext.create('Ext.slider.Single', {
* width: 200,
* value: 50,
* increment: 10,
* minValue: 0,
* maxValue: 100,
* renderTo: Ext.getBody()
* });
*
* The class Ext.slider.Single is aliased to Ext.Slider for backwards compatibility.
*/
Ext.define('Ext.slider.Single', {
extend: 'Ext.slider.Multi',
alias: ['widget.slider', 'widget.sliderfield'],
alternateClassName: ['Ext.Slider', 'Ext.form.SliderField', 'Ext.slider.SingleSlider', 'Ext.slider.Slider'],
<span id='Ext-slider-Single-method-getValue'> /**
</span> * Returns the current value of the slider
* @return {Number} The current value of the slider
*/
getValue: function() {
// just returns the value of the first thumb, which should be the only one in a single slider
return this.callParent([0]);
},
<span id='Ext-slider-Single-method-setValue'> /**
</span> * Programmatically sets the value of the Slider. Ensures that the value is constrained within the minValue and
* maxValue.
* @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
* @param {Boolean} [animate] Turn on or off animation
*/
setValue: function(value, animate) {
var args = arguments,
len = args.length;
// this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
// index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
// signature without the required index. The index will always be 0 for a single slider
if (len == 1 || (len <= 3 && typeof args[1] != 'number')) {
args = Ext.toArray(args);
args.unshift(0);
}
return this.callParent(args);
},
// private
getNearest : function(){
// Since there's only 1 thumb, it's always the nearest
return this.thumbs[0];
}
});
</pre>
</body>
</html>