3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
17 <div id="cls-Ext.slider.Thumb"></div>/**
18 * @class Ext.slider.Thumb
20 * Represents a single thumb element on a Slider. This would not usually be created manually and would instead
21 * be created internally by an {@link Ext.slider.MultiSlider Ext.Slider}.
23 Ext.slider.Thumb = Ext.extend(Object, {
25 <div id="cfg-Ext.slider.Thumb-slider"></div>/**
27 * @cfg {Ext.slider.MultiSlider} slider The Slider to render to (required)
29 constructor: function(config) {
30 <div id="prop-Ext.slider.Thumb-slider"></div>/**
32 * @type Ext.slider.MultiSlider
33 * The slider this thumb is contained within
35 Ext.apply(this, config || {}, {
36 cls: 'x-slider-thumb',
38 <div id="cfg-Ext.slider.Thumb-constrain"></div>/**
39 * @cfg {Boolean} constrain True to constrain the thumb so that it cannot overlap its siblings
44 Ext.slider.Thumb.superclass.constructor.call(this, config);
46 if (this.slider.vertical) {
47 Ext.apply(this, Ext.slider.Thumb.Vertical);
51 <div id="method-Ext.slider.Thumb-render"></div>/**
52 * Renders the thumb into a slider
55 this.el = this.slider.innerEl.insertFirst({cls: this.cls});
60 <div id="method-Ext.slider.Thumb-enable"></div>/**
61 * Enables the thumb if it is currently disabled
64 this.disabled = false;
65 this.el.removeClass(this.slider.disabledClass);
68 <div id="method-Ext.slider.Thumb-disable"></div>/**
69 * Disables the thumb if it is currently enabled
73 this.el.addClass(this.slider.disabledClass);
76 <div id="method-Ext.slider.Thumb-initEvents"></div>/**
77 * Sets up an Ext.dd.DragTracker for this thumb
79 initEvents: function() {
82 el.addClassOnOver('x-slider-thumb-over');
84 this.tracker = new Ext.dd.DragTracker({
85 onBeforeStart: this.onBeforeDragStart.createDelegate(this),
86 onStart : this.onDragStart.createDelegate(this),
87 onDrag : this.onDrag.createDelegate(this),
88 onEnd : this.onDragEnd.createDelegate(this),
93 this.tracker.initEl(el);
98 * This is tied into the internal Ext.dd.DragTracker. If the slider is currently disabled,
99 * this returns false to disable the DragTracker too.
100 * @return {Boolean} False if the slider is currently disabled
102 onBeforeDragStart : function(e) {
106 this.slider.promoteThumb(this);
113 * This is tied into the internal Ext.dd.DragTracker's onStart template method. Adds the drag CSS class
114 * to the thumb and fires the 'dragstart' event
116 onDragStart: function(e){
117 this.el.addClass('x-slider-thumb-drag');
118 this.dragging = true;
119 this.dragStartValue = this.value;
121 this.slider.fireEvent('dragstart', this.slider, e, this);
126 * This is tied into the internal Ext.dd.DragTracker's onDrag template method. This is called every time
127 * the DragTracker detects a drag movement. It updates the Slider's value using the position of the drag
129 onDrag: function(e) {
130 var slider = this.slider,
132 newValue = this.getNewValue();
134 if (this.constrain) {
135 var above = slider.thumbs[index + 1],
136 below = slider.thumbs[index - 1];
138 if (below != undefined && newValue <= below.value) newValue = below.value;
139 if (above != undefined && newValue >= above.value) newValue = above.value;
142 slider.setValue(index, newValue, false);
143 slider.fireEvent('drag', slider, e, this);
146 getNewValue: function() {
147 var slider = this.slider,
148 pos = slider.innerEl.translatePoints(this.tracker.getXY());
150 return Ext.util.Format.round(slider.reverseValue(pos.left), slider.decimalPrecision);
155 * This is tied to the internal Ext.dd.DragTracker's onEnd template method. Removes the drag CSS class and
156 * fires the 'changecomplete' event with the new value
158 onDragEnd: function(e) {
159 var slider = this.slider,
162 this.el.removeClass('x-slider-thumb-drag');
164 this.dragging = false;
165 slider.fireEvent('dragend', slider, e);
167 if (this.dragStartValue != value) {
168 slider.fireEvent('changecomplete', slider, value, this);
173 <div id="cls-Ext.slider.MultiSlider"></div>/**
174 * @class Ext.slider.MultiSlider
175 * @extends Ext.BoxComponent
176 * 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 usage:
179 renderTo: Ext.getBody(),
187 * Sliders can be created with more than one thumb handle by passing an array of values instead of a single one:
190 renderTo: Ext.getBody(),
192 values: [25, 50, 75],
196 //this defaults to true, setting to false allows the thumbs to pass each other
197 {@link #constrainThumbs}: false
201 Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, {
202 <div id="cfg-Ext.slider.MultiSlider-value"></div>/**
203 * @cfg {Number} value The value to initialize the slider with. Defaults to minValue.
205 <div id="cfg-Ext.slider.MultiSlider-vertical"></div>/**
206 * @cfg {Boolean} vertical Orient the Slider vertically rather than horizontally, defaults to false.
209 <div id="cfg-Ext.slider.MultiSlider-minValue"></div>/**
210 * @cfg {Number} minValue The minimum value for the Slider. Defaults to 0.
213 <div id="cfg-Ext.slider.MultiSlider-maxValue"></div>/**
214 * @cfg {Number} maxValue The maximum value for the Slider. Defaults to 100.
217 <div id="cfg-Ext.slider.MultiSlider-decimalPrecision."></div>/**
218 * @cfg {Number/Boolean} decimalPrecision.
219 * <p>The number of decimal places to which to round the Slider's value. Defaults to 0.</p>
220 * <p>To disable rounding, configure as <tt><b>false</b></tt>.</p>
223 <div id="cfg-Ext.slider.MultiSlider-keyIncrement"></div>/**
224 * @cfg {Number} keyIncrement How many units to change the Slider when adjusting with keyboard navigation. Defaults to 1. If the increment config is larger, it will be used instead.
227 <div id="cfg-Ext.slider.MultiSlider-increment"></div>/**
228 * @cfg {Number} increment How many units to change the slider when adjusting by drag and drop. Use this option to enable 'snapping'.
234 * @property clickRange
236 * Determines whether or not a click to the slider component is considered to be a user request to change the value. Specified as an array of [top, bottom],
237 * the click event's 'top' property is compared to these numbers and the click only considered a change request if it falls within them. e.g. if the 'top'
238 * value of the click event is 4 or 16, the click is not considered a change request as it falls outside of the [5, 15] range
242 <div id="cfg-Ext.slider.MultiSlider-clickToChange"></div>/**
243 * @cfg {Boolean} clickToChange Determines whether or not clicking on the Slider axis will change the slider. Defaults to true
245 clickToChange : true,
246 <div id="cfg-Ext.slider.MultiSlider-animate"></div>/**
247 * @cfg {Boolean} animate Turn on or off animation. Defaults to true
251 <div id="prop-Ext.slider.MultiSlider-dragging"></div>/**
252 * True while the thumb is in a drag operation
257 <div id="cfg-Ext.slider.MultiSlider-constrainThumbs"></div>/**
258 * @cfg {Boolean} constrainThumbs True to disallow thumbs from overlapping one another. Defaults to true
260 constrainThumbs: true,
264 * @property topThumbZIndex
266 * The number used internally to set the z index of the top thumb (see promoteThumb for details)
268 topThumbZIndex: 10000,
271 initComponent : function(){
272 if(!Ext.isDefined(this.value)){
273 this.value = this.minValue;
276 <div id="prop-Ext.slider.MultiSlider-thumbs"></div>/**
279 * Array containing references to each thumb
283 Ext.slider.MultiSlider.superclass.initComponent.call(this);
285 this.keyIncrement = Math.max(this.increment, this.keyIncrement);
287 <div id="event-Ext.slider.MultiSlider-beforechange"></div>/**
288 * @event beforechange
289 * Fires before the slider value is changed. By returning false from an event handler,
290 * you can cancel the event and prevent the slider from changing.
291 * @param {Ext.Slider} slider The slider
292 * @param {Number} newValue The new value which the slider is being changed to.
293 * @param {Number} oldValue The old value which the slider was previously.
297 <div id="event-Ext.slider.MultiSlider-change"></div>/**
299 * Fires when the slider value is changed.
300 * @param {Ext.Slider} slider The slider
301 * @param {Number} newValue The new value which the slider has been changed to.
302 * @param {Ext.slider.Thumb} thumb The thumb that was changed
306 <div id="event-Ext.slider.MultiSlider-changecomplete"></div>/**
307 * @event changecomplete
308 * Fires when the slider value is changed by the user and any drag operations have completed.
309 * @param {Ext.Slider} slider The slider
310 * @param {Number} newValue The new value which the slider has been changed to.
311 * @param {Ext.slider.Thumb} thumb The thumb that was changed
315 <div id="event-Ext.slider.MultiSlider-dragstart"></div>/**
317 * Fires after a drag operation has started.
318 * @param {Ext.Slider} slider The slider
319 * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker
323 <div id="event-Ext.slider.MultiSlider-drag"></div>/**
325 * Fires continuously during the drag operation while the mouse is moving.
326 * @param {Ext.Slider} slider The slider
327 * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker
331 <div id="event-Ext.slider.MultiSlider-dragend"></div>/**
333 * Fires after the drag operation has completed.
334 * @param {Ext.Slider} slider The slider
335 * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker
340 <div id="prop-Ext.slider.MultiSlider-values"></div>/**
343 * Array of values to initalize the thumbs with
345 if (this.values == undefined || Ext.isEmpty(this.values)) this.values = [0];
347 var values = this.values;
349 for (var i=0; i < values.length; i++) {
350 this.addThumb(values[i]);
354 Ext.apply(this, Ext.slider.Vertical);
358 <div id="method-Ext.slider.MultiSlider-addThumb"></div>/**
359 * Creates a new thumb and adds it to the slider
360 * @param {Number} value The initial value to set on the thumb. Defaults to 0
362 addThumb: function(value) {
363 var thumb = new Ext.slider.Thumb({
366 index : this.thumbs.length,
367 constrain: this.constrainThumbs
369 this.thumbs.push(thumb);
371 //render the thumb now if needed
372 if (this.rendered) thumb.render();
377 * Moves the given thumb above all other by increasing its z-index. This is called when as drag
378 * any thumb, so that the thumb that was just dragged is always at the highest z-index. This is
379 * required when the thumbs are stacked on top of each other at one of the ends of the slider's
380 * range, which can result in the user not being able to move any of them.
381 * @param {Ext.slider.Thumb} topThumb The thumb to move to the top
383 promoteThumb: function(topThumb) {
384 var thumbs = this.thumbs,
387 for (var i = 0, j = thumbs.length; i < j; i++) {
390 if (thumb == topThumb) {
391 zIndex = this.topThumbZIndex;
396 thumb.el.setStyle('zIndex', zIndex);
401 onRender : function() {
403 cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),
407 cls:'x-slider-inner',
408 cn : [{tag:'a', cls:'x-slider-focus', href:"#", tabIndex: '-1', hidefocus:'on'}]
413 Ext.slider.MultiSlider.superclass.onRender.apply(this, arguments);
415 this.endEl = this.el.first();
416 this.innerEl = this.endEl.first();
417 this.focusEl = this.innerEl.child('.x-slider-focus');
420 for (var i=0; i < this.thumbs.length; i++) {
421 this.thumbs[i].render();
424 //calculate the size of half a thumb
425 var thumb = this.innerEl.child('.x-slider-thumb');
426 this.halfThumb = (this.vertical ? thumb.getHeight() : thumb.getWidth()) / 2;
433 * Adds keyboard and mouse listeners on this.el. Ignores click events on the internal focus element.
434 * Creates a new DragTracker which is used to control what happens when the user drags the thumb around.
436 initEvents : function(){
439 mousedown: this.onMouseDown,
440 keydown : this.onKeyDown
443 this.focusEl.swallowEvent("click", true);
448 * Mousedown handler for the slider. If the clickToChange is enabled and the click was not on the draggable 'thumb',
449 * this calculates the new value of the slider and tells the implementation (Horizontal or Vertical) to move the thumb
450 * @param {Ext.EventObject} e The click event
452 onMouseDown : function(e){
457 //see if the click was on any of the thumbs
458 var thumbClicked = false;
459 for (var i=0; i < this.thumbs.length; i++) {
460 thumbClicked = thumbClicked || e.target == this.thumbs[i].el.dom;
463 if (this.clickToChange && !thumbClicked) {
464 var local = this.innerEl.translatePoints(e.getXY());
465 this.onClickChange(local);
472 * Moves the thumb to the indicated position. Note that a Vertical implementation is provided in Ext.slider.Vertical.
473 * Only changes the value if the click was within this.clickRange.
474 * @param {Object} local Object containing top and left values for the click event.
476 onClickChange : function(local) {
477 if (local.top > this.clickRange[0] && local.top < this.clickRange[1]) {
478 //find the nearest thumb to the click event
479 var thumb = this.getNearest(local, 'left'),
482 this.setValue(index, Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);
488 * Returns the nearest thumb to a click event, along with its distance
489 * @param {Object} local Object containing top and left values from a click event
490 * @param {String} prop The property of local to compare on. Use 'left' for horizontal sliders, 'top' for vertical ones
491 * @return {Object} The closest thumb object and its distance from the click event
493 getNearest: function(local, prop) {
494 var localValue = prop == 'top' ? this.innerEl.getHeight() - local[prop] : local[prop],
495 clickValue = this.reverseValue(localValue),
496 nearestDistance = (this.maxValue - this.minValue) + 5, //add a small fudge for the end of the slider
500 for (var i=0; i < this.thumbs.length; i++) {
501 var thumb = this.thumbs[i],
503 dist = Math.abs(value - clickValue);
505 if (Math.abs(dist <= nearestDistance)) {
508 nearestDistance = dist;
516 * Handler for any keypresses captured by the slider. If the key is UP or RIGHT, the thumb is moved along to the right
517 * by this.keyIncrement. If DOWN or LEFT it is moved left. Pressing CTRL moves the slider to the end in either direction
518 * @param {Ext.EventObject} e The Event object
520 onKeyDown : function(e){
521 if(this.disabled){e.preventDefault();return;}
528 this.setValue(this.maxValue, undefined, true);
530 this.setValue(this.value+this.keyIncrement, undefined, true);
537 this.setValue(this.minValue, undefined, true);
539 this.setValue(this.value-this.keyIncrement, undefined, true);
549 * If using snapping, this takes a desired new value and returns the closest snapped
551 * @param {Number} value The unsnapped value
552 * @return {Number} The value of the nearest snap target
554 doSnap : function(value){
555 if (!(this.increment && value)) {
558 var newValue = value,
559 inc = this.increment,
565 } else if (m * 2 < -inc) {
569 return newValue.constrain(this.minValue, this.maxValue);
573 afterRender : function(){
574 Ext.slider.MultiSlider.superclass.afterRender.apply(this, arguments);
576 for (var i=0; i < this.thumbs.length; i++) {
577 var thumb = this.thumbs[i];
579 if (thumb.value !== undefined) {
580 var v = this.normalizeValue(thumb.value);
582 if (v !== thumb.value) {
583 // delete this.value;
584 this.setValue(i, v, false);
586 this.moveThumb(i, this.translateValue(v), false);
594 * Returns the ratio of pixels to mapped values. e.g. if the slider is 200px wide and maxValue - minValue is 100,
596 * @return {Number} The ratio of pixels to mapped values
598 getRatio : function(){
599 var w = this.innerEl.getWidth(),
600 v = this.maxValue - this.minValue;
601 return v == 0 ? w : (w/v);
606 * Returns a snapped, constrained value when given a desired value
607 * @param {Number} value Raw number value
608 * @return {Number} The raw value rounded to the correct d.p. and constrained within the set max and min values
610 normalizeValue : function(v){
612 v = Ext.util.Format.round(v, this.decimalPrecision);
613 v = v.constrain(this.minValue, this.maxValue);
617 <div id="method-Ext.slider.MultiSlider-setMinValue"></div>/**
618 * Sets the minimum value for the slider instance. If the current value is less than the
619 * minimum value, the current value will be changed.
620 * @param {Number} val The new minimum value
622 setMinValue : function(val){
626 for (var i=0, j = this.thumbs.length; i < j; i++) {
627 if (this.thumbs[i].value < val) this.thumbs[i].value = val;
631 <div id="method-Ext.slider.MultiSlider-setMaxValue"></div>/**
632 * Sets the maximum value for the slider instance. If the current value is more than the
633 * maximum value, the current value will be changed.
634 * @param {Number} val The new maximum value
636 setMaxValue : function(val){
640 for (var i=0; i < this.thumbs.length; i++) {
641 if (this.thumbs[i].value > val) this.thumbs[i].value = val;
645 <div id="method-Ext.slider.MultiSlider-setValue"></div>/**
646 * Programmatically sets the value of the Slider. Ensures that the value is constrained within
647 * the minValue and maxValue.
648 * @param {Number} index Index of the thumb to move
649 * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
650 * @param {Boolean} animate Turn on or off animation, defaults to true
652 setValue : function(index, v, animate, changeComplete) {
653 var thumb = this.thumbs[index],
656 v = this.normalizeValue(v);
658 if (v !== thumb.value && this.fireEvent('beforechange', this, v, thumb.value) !== false) {
660 this.moveThumb(index, this.translateValue(v), animate !== false);
661 this.fireEvent('change', this, v, thumb);
663 this.fireEvent('changecomplete', this, v, thumb);
671 translateValue : function(v) {
672 var ratio = this.getRatio();
673 return (v * ratio) - (this.minValue * ratio) - this.halfThumb;
678 * Given a pixel location along the slider, returns the mapped slider value for that pixel.
679 * E.g. if we have a slider 200px wide with minValue = 100 and maxValue = 500, reverseValue(50)
681 * @param {Number} pos The position along the slider to return a mapped value for
682 * @return {Number} The mapped value for the given position
684 reverseValue : function(pos){
685 var ratio = this.getRatio();
686 return (pos + (this.minValue * ratio)) / ratio;
691 * @param {Number} index Index of the thumb to move
693 moveThumb: function(index, v, animate){
694 var thumb = this.thumbs[index].el;
696 if(!animate || this.animate === false){
699 thumb.shift({left: v, stopFx: true, duration:.35});
705 this.focusEl.focus(10);
709 onResize : function(w, h){
710 var thumbs = this.thumbs,
715 * If we happen to be animating during a resize, the position of the thumb will likely be off
716 * when the animation stops. As such, just stop any animations before syncing the thumbs.
719 thumbs[i].el.stopFx();
721 this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
723 Ext.slider.MultiSlider.superclass.onResize.apply(this, arguments);
727 onDisable: function(){
728 Ext.slider.MultiSlider.superclass.onDisable.call(this);
730 for (var i=0; i < this.thumbs.length; i++) {
731 var thumb = this.thumbs[i],
737 //IE breaks when using overflow visible and opacity other than 1.
738 //Create a place holder for the thumb and display it.
742 this.innerEl.addClass(this.disabledClass).dom.disabled = true;
744 if (!this.thumbHolder) {
745 this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});
748 this.thumbHolder.show().setXY(xy);
754 onEnable: function(){
755 Ext.slider.MultiSlider.superclass.onEnable.call(this);
757 for (var i=0; i < this.thumbs.length; i++) {
758 var thumb = this.thumbs[i],
764 this.innerEl.removeClass(this.disabledClass).dom.disabled = false;
766 if (this.thumbHolder) this.thumbHolder.hide();
774 <div id="method-Ext.slider.MultiSlider-syncThumb"></div>/**
775 * Synchronizes the thumb position to the proper proportion of the total component width based
776 * on the current slider {@link #value}. This will be called automatically when the Slider
777 * is resized by a layout, but if it is rendered auto width, this method can be called from
778 * another resize handler to sync the Slider if necessary.
780 syncThumb : function() {
782 for (var i=0; i < this.thumbs.length; i++) {
783 this.moveThumb(i, this.translateValue(this.thumbs[i].value));
788 <div id="method-Ext.slider.MultiSlider-getValue"></div>/**
789 * Returns the current value of the slider
790 * @param {Number} index The index of the thumb to return a value for
791 * @return {Number} The current value of the slider
793 getValue : function(index) {
794 return this.thumbs[index].value;
797 <div id="method-Ext.slider.MultiSlider-getValues"></div>/**
798 * Returns an array of values - one for the location of each thumb
799 * @return {Array} The set of thumb values
801 getValues: function() {
804 for (var i=0; i < this.thumbs.length; i++) {
805 values.push(this.thumbs[i].value);
812 beforeDestroy : function(){
813 Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');
814 Ext.slider.MultiSlider.superclass.beforeDestroy.call(this);
818 Ext.reg('multislider', Ext.slider.MultiSlider);
820 <div id="cls-Ext.slider.SingleSlider"></div>/**
821 * @class Ext.slider.SingleSlider
822 * @extends Ext.slider.MultiSlider
823 * Slider which supports vertical or horizontal orientation, keyboard adjustments,
824 * configurable snapping, axis clicking and animation. Can be added as an item to
825 * any container. Example usage:
827 new Ext.slider.SingleSlider({
828 renderTo: Ext.getBody(),
836 * The class Ext.slider.SingleSlider is aliased to Ext.Slider for backwards compatibility.
838 Ext.slider.SingleSlider = Ext.extend(Ext.slider.MultiSlider, {
839 constructor: function(config) {
840 config = config || {};
842 Ext.applyIf(config, {
843 values: [config.value || 0]
846 Ext.slider.SingleSlider.superclass.constructor.call(this, config);
849 <div id="method-Ext.slider.SingleSlider-getValue"></div>/**
850 * Returns the current value of the slider
851 * @return {Number} The current value of the slider
853 getValue: function() {
854 //just returns the value of the first thumb, which should be the only one in a single slider
855 return Ext.slider.SingleSlider.superclass.getValue.call(this, 0);
858 <div id="method-Ext.slider.SingleSlider-setValue"></div>/**
859 * Programmatically sets the value of the Slider. Ensures that the value is constrained within
860 * the minValue and maxValue.
861 * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)
862 * @param {Boolean} animate Turn on or off animation, defaults to true
864 setValue: function(value, animate) {
865 var args = Ext.toArray(arguments),
868 //this is to maintain backwards compatiblity for sliders with only one thunb. Usually you must pass the thumb
869 //index to setValue, but if we only have one thumb we inject the index here first if given the multi-slider
870 //signature without the required index. The index will always be 0 for a single slider
871 if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
875 return Ext.slider.SingleSlider.superclass.setValue.apply(this, args);
878 <div id="method-Ext.slider.SingleSlider-syncThumb"></div>/**
879 * Synchronizes the thumb position to the proper proportion of the total component width based
880 * on the current slider {@link #value}. This will be called automatically when the Slider
881 * is resized by a layout, but if it is rendered auto width, this method can be called from
882 * another resize handler to sync the Slider if necessary.
884 syncThumb : function() {
885 return Ext.slider.SingleSlider.superclass.syncThumb.apply(this, [0].concat(arguments));
889 getNearest : function(){
890 // Since there's only 1 thumb, it's always the nearest
891 return this.thumbs[0];
895 //backwards compatibility
896 Ext.Slider = Ext.slider.SingleSlider;
898 Ext.reg('slider', Ext.slider.SingleSlider);
900 // private class to support vertical sliders
901 Ext.slider.Vertical = {
902 onResize : function(w, h){
903 this.innerEl.setHeight(h - (this.el.getPadding('t') + this.endEl.getPadding('b')));
907 getRatio : function(){
908 var h = this.innerEl.getHeight(),
909 v = this.maxValue - this.minValue;
913 moveThumb: function(index, v, animate) {
914 var thumb = this.thumbs[index],
917 if (!animate || this.animate === false) {
920 el.shift({bottom: v, stopFx: true, duration:.35});
924 onClickChange : function(local) {
925 if (local.left > this.clickRange[0] && local.left < this.clickRange[1]) {
926 var thumb = this.getNearest(local, 'top'),
928 value = this.minValue + this.reverseValue(this.innerEl.getHeight() - local.top);
930 this.setValue(index, Ext.util.Format.round(value, this.decimalPrecision), undefined, true);
935 //private class to support vertical dragging of thumbs within a slider
936 Ext.slider.Thumb.Vertical = {
937 getNewValue: function() {
938 var slider = this.slider,
939 innerEl = slider.innerEl,
940 pos = innerEl.translatePoints(this.tracker.getXY()),
941 bottom = innerEl.getHeight() - pos.top;
943 return slider.minValue + Ext.util.Format.round(bottom / slider.getRatio(), slider.decimalPrecision);