X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..b37ceabb82336ee82757cd32efe353cfab8ec267:/src/widgets/Slider.js diff --git a/src/widgets/Slider.js b/src/widgets/Slider.js index 57a0ee8c..85b1476f 100644 --- a/src/widgets/Slider.js +++ b/src/widgets/Slider.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.0 + * Ext JS Library 3.2.2 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -159,6 +159,14 @@ Ext.slider.Thumb = Ext.extend(Object, { if (this.dragStartValue != value) { slider.fireEvent('changecomplete', slider, value, this); } + }, + + /** + * @private + * Destroys the thumb + */ + destroy: function(){ + Ext.destroyMembers(this, 'tracker', 'el'); } }); @@ -510,26 +518,29 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { * @param {Ext.EventObject} e The Event object */ onKeyDown : function(e){ - if(this.disabled){e.preventDefault();return;} - var k = e.getKey(); + /* + * The behaviour for keyboard handling with multiple thumbs is currently undefined. + * There's no real sane default for it, so leave it like this until we come up + * with a better way of doing it. + */ + if(this.disabled || this.thumbs.length !== 1){ + e.preventDefault(); + return; + } + var k = e.getKey(), + val; switch(k){ case e.UP: case e.RIGHT: e.stopEvent(); - if(e.ctrlKey){ - this.setValue(this.maxValue, undefined, true); - }else{ - this.setValue(this.value+this.keyIncrement, undefined, true); - } + val = e.ctrlKey ? this.maxValue : this.getValue(0) + this.keyIncrement; + this.setValue(0, val, undefined, true); break; case e.DOWN: case e.LEFT: e.stopEvent(); - if(e.ctrlKey){ - this.setValue(this.minValue, undefined, true); - }else{ - this.setValue(this.value-this.keyIncrement, undefined, true); - } + val = e.ctrlKey ? this.minValue : this.getValue(0) - this.keyIncrement; + this.setValue(0, val, undefined, true); break; default: e.preventDefault(); @@ -613,11 +624,16 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { */ setMinValue : function(val){ this.minValue = val; - this.syncThumb(); - - for (var i=0, j = this.thumbs.length; i < j; i++) { - if (this.thumbs[i].value < val) this.thumbs[i].value = val; + var i = 0, + thumbs = this.thumbs, + len = thumbs.length, + t; + + for(; i < len; ++i){ + t = thumbs[i]; + t.value = t.value < val ? val : t.value; } + this.syncThumb(); }, /** @@ -627,11 +643,16 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { */ setMaxValue : function(val){ this.maxValue = val; - this.syncThumb(); - - for (var i=0; i < this.thumbs.length; i++) { - if (this.thumbs[i].value > val) this.thumbs[i].value = val; + var i = 0, + thumbs = this.thumbs, + len = thumbs.length, + t; + + for(; i < len; ++i){ + t = thumbs[i]; + t.value = t.value > val ? val : t.value; } + this.syncThumb(); }, /** @@ -647,12 +668,14 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { v = this.normalizeValue(v); - if (v !== thumb.value && this.fireEvent('beforechange', this, v, thumb.value) !== false) { + if (v !== thumb.value && this.fireEvent('beforechange', this, v, thumb.value, thumb) !== false) { thumb.value = v; - this.moveThumb(index, this.translateValue(v), animate !== false); - this.fireEvent('change', this, v, thumb); - if(changeComplete){ - this.fireEvent('changecomplete', this, v, thumb); + if(this.rendered){ + this.moveThumb(index, this.translateValue(v), animate !== false); + this.fireEvent('change', this, v, thumb); + if(changeComplete){ + this.fireEvent('changecomplete', this, v, thumb); + } } } }, @@ -710,7 +733,10 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { for(; i < len; ++i){ thumbs[i].el.stopFx(); } - this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r'))); + // check to see if we're using an auto width + if(Ext.isNumber(w)){ + this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r'))); + } this.syncThumb(); Ext.slider.MultiSlider.superclass.onResize.apply(this, arguments); }, @@ -802,7 +828,12 @@ Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, { // private beforeDestroy : function(){ - Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder'); + var thumbs = this.thumbs; + for(var i = 0, len = thumbs.length; i < len; ++i){ + thumbs[i].destroy(); + thumbs[i] = null; + } + Ext.destroyMembers(this, 'endEl', 'innerEl', 'focusEl', 'thumbHolder'); Ext.slider.MultiSlider.superclass.beforeDestroy.call(this); } });