</code></pre>\r
*/\r
Ext.Slider = Ext.extend(Ext.BoxComponent, {\r
- <div id="cfg-Ext.Slider-value"></div>/**\r
- * @cfg {Number} value The value to initialize the slider with. Defaults to minValue.\r
- */\r
- <div id="cfg-Ext.Slider-vertical"></div>/**\r
- * @cfg {Boolean} vertical Orient the Slider vertically rather than horizontally, defaults to false.\r
- */\r
+ <div id="cfg-Ext.Slider-value"></div>/**\r
+ * @cfg {Number} value The value to initialize the slider with. Defaults to minValue.\r
+ */\r
+ <div id="cfg-Ext.Slider-vertical"></div>/**\r
+ * @cfg {Boolean} vertical Orient the Slider vertically rather than horizontally, defaults to false.\r
+ */\r
vertical: false,\r
- <div id="cfg-Ext.Slider-minValue"></div>/**\r
- * @cfg {Number} minValue The minimum value for the Slider. Defaults to 0.\r
- */\r
+ <div id="cfg-Ext.Slider-minValue"></div>/**\r
+ * @cfg {Number} minValue The minimum value for the Slider. Defaults to 0.\r
+ */\r
minValue: 0,\r
- <div id="cfg-Ext.Slider-maxValue"></div>/**\r
- * @cfg {Number} maxValue The maximum value for the Slider. Defaults to 100.\r
- */\r
+ <div id="cfg-Ext.Slider-maxValue"></div>/**\r
+ * @cfg {Number} maxValue The maximum value for the Slider. Defaults to 100.\r
+ */\r
maxValue: 100,\r
<div id="cfg-Ext.Slider-decimalPrecision."></div>/**\r
* @cfg {Number/Boolean} decimalPrecision.\r
* <p>To disable rounding, configure as <tt><b>false</b></tt>.</p>\r
*/\r
decimalPrecision: 0,\r
- <div id="cfg-Ext.Slider-keyIncrement"></div>/**\r
- * @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.\r
- */\r
+ <div id="cfg-Ext.Slider-keyIncrement"></div>/**\r
+ * @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.\r
+ */\r
keyIncrement: 1,\r
- <div id="cfg-Ext.Slider-increment"></div>/**\r
- * @cfg {Number} increment How many units to change the slider when adjusting by drag and drop. Use this option to enable 'snapping'.\r
- */\r
+ <div id="cfg-Ext.Slider-increment"></div>/**\r
+ * @cfg {Number} increment How many units to change the slider when adjusting by drag and drop. Use this option to enable 'snapping'.\r
+ */\r
increment: 0,\r
- // private\r
+ // private\r
clickRange: [5,15],\r
- <div id="cfg-Ext.Slider-clickToChange"></div>/**\r
- * @cfg {Boolean} clickToChange Determines whether or not clicking on the Slider axis will change the slider. Defaults to true\r
- */\r
+ <div id="cfg-Ext.Slider-clickToChange"></div>/**\r
+ * @cfg {Boolean} clickToChange Determines whether or not clicking on the Slider axis will change the slider. Defaults to true\r
+ */\r
clickToChange : true,\r
- <div id="cfg-Ext.Slider-animate"></div>/**\r
- * @cfg {Boolean} animate Turn on or off animation. Defaults to true\r
- */\r
+ <div id="cfg-Ext.Slider-animate"></div>/**\r
+ * @cfg {Boolean} animate Turn on or off animation. Defaults to true\r
+ */\r
animate: true,\r
\r
<div id="prop-Ext.Slider-dragging"></div>/**\r
* @event beforechange\r
* Fires before the slider value is changed. By returning false from an event handler,\r
* you can cancel the event and prevent the slider from changing.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Number} newValue The new value which the slider is being changed to.\r
- * @param {Number} oldValue The old value which the slider was previously.\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Number} newValue The new value which the slider is being changed to.\r
+ * @param {Number} oldValue The old value which the slider was previously.\r
+ */\r
+ 'beforechange',\r
+ <div id="event-Ext.Slider-change"></div>/**\r
+ * @event change\r
+ * Fires when the slider value is changed.\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Number} newValue The new value which the slider has been changed to.\r
*/\r
- 'beforechange',\r
- <div id="event-Ext.Slider-change"></div>/**\r
- * @event change\r
- * Fires when the slider value is changed.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Number} newValue The new value which the slider has been changed to.\r
- */\r
- 'change',\r
- <div id="event-Ext.Slider-changecomplete"></div>/**\r
- * @event changecomplete\r
- * Fires when the slider value is changed by the user and any drag operations have completed.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Number} newValue The new value which the slider has been changed to.\r
- */\r
- 'changecomplete',\r
- <div id="event-Ext.Slider-dragstart"></div>/**\r
- * @event dragstart\r
+ 'change',\r
+ <div id="event-Ext.Slider-changecomplete"></div>/**\r
+ * @event changecomplete\r
+ * Fires when the slider value is changed by the user and any drag operations have completed.\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Number} newValue The new value which the slider has been changed to.\r
+ */\r
+ 'changecomplete',\r
+ <div id="event-Ext.Slider-dragstart"></div>/**\r
+ * @event dragstart\r
* Fires after a drag operation has started.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
- */\r
- 'dragstart',\r
- <div id="event-Ext.Slider-drag"></div>/**\r
- * @event drag\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
+ */\r
+ 'dragstart',\r
+ <div id="event-Ext.Slider-drag"></div>/**\r
+ * @event drag\r
* Fires continuously during the drag operation while the mouse is moving.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
- */\r
- 'drag',\r
- <div id="event-Ext.Slider-dragend"></div>/**\r
- * @event dragend\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
+ */\r
+ 'drag',\r
+ <div id="event-Ext.Slider-dragend"></div>/**\r
+ * @event dragend\r
* Fires after the drag operation has completed.\r
- * @param {Ext.Slider} slider The slider\r
- * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
- */\r
- 'dragend'\r
- );\r
+ * @param {Ext.Slider} slider The slider\r
+ * @param {Ext.EventObject} e The event fired from Ext.dd.DragTracker\r
+ */\r
+ 'dragend'\r
+ );\r
\r
if(this.vertical){\r
Ext.apply(this, Ext.Slider.Vertical);\r
}\r
},\r
\r
- // private override\r
+ // private override\r
onRender : function(){\r
this.autoEl = {\r
cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),\r
this.initEvents();\r
},\r
\r
- // private override\r
+ // private override\r
initEvents : function(){\r
this.thumb.addClassOnOver('x-slider-thumb-over');\r
this.mon(this.el, {\r
this.tracker.initEl(this.thumb);\r
},\r
\r
- // private override\r
+ // private override\r
onMouseDown : function(e){\r
if(this.disabled){\r
return;\r
this.focus();\r
},\r
\r
- // private\r
+ // private\r
onClickChange : function(local){\r
if(local.top > this.clickRange[0] && local.top < this.clickRange[1]){\r
this.setValue(Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);\r
}\r
},\r
\r
- // private\r
+ // private\r
onKeyDown : function(e){\r
if(this.disabled){e.preventDefault();return;}\r
var k = e.getKey();\r
}\r
},\r
\r
- // private\r
+ // private\r
doSnap : function(value){\r
if(!(this.increment && value)){\r
return value;\r
}\r
- var newValue = value, \r
+ var newValue = value,\r
inc = this.increment,\r
m = value % inc;\r
if(m != 0){\r
return newValue.constrain(this.minValue, this.maxValue);\r
},\r
\r
- // private\r
+ // private\r
afterRender : function(){\r
Ext.Slider.superclass.afterRender.apply(this, arguments);\r
if(this.value !== undefined){\r
}\r
},\r
\r
- // private\r
+ // private\r
getRatio : function(){\r
var w = this.innerEl.getWidth(),\r
v = this.maxValue - this.minValue;\r
return v == 0 ? w : (w/v);\r
},\r
\r
- // private\r
+ // private\r
normalizeValue : function(v){\r
v = this.doSnap(v);\r
v = Ext.util.Format.round(v, this.decimalPrecision);\r
v = v.constrain(this.minValue, this.maxValue);\r
return v;\r
},\r
+ \r
+ <div id="method-Ext.Slider-setMinValue"></div>/**\r
+ * Sets the minimum value for the slider instance. If the current value is less than the \r
+ * minimum value, the current value will be changed.\r
+ * @param {Number} val The new minimum value\r
+ */\r
+ setMinValue : function(val){\r
+ this.minValue = val;\r
+ this.syncThumb();\r
+ if(this.value < val){\r
+ this.setValue(val);\r
+ }\r
+ },\r
+ \r
+ <div id="method-Ext.Slider-setMaxValue"></div>/**\r
+ * Sets the maximum value for the slider instance. If the current value is more than the \r
+ * maximum value, the current value will be changed.\r
+ * @param {Number} val The new maximum value\r
+ */\r
+ setMaxValue : function(val){\r
+ this.maxValue = val;\r
+ this.syncThumb();\r
+ if(this.value > val){\r
+ this.setValue(val);\r
+ }\r
+ },\r
\r
- <div id="method-Ext.Slider-setValue"></div>/**\r
- * Programmatically sets the value of the Slider. Ensures that the value is constrained within\r
- * the minValue and maxValue.\r
- * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)\r
- * @param {Boolean} animate Turn on or off animation, defaults to true\r
- */\r
+ <div id="method-Ext.Slider-setValue"></div>/**\r
+ * Programmatically sets the value of the Slider. Ensures that the value is constrained within\r
+ * the minValue and maxValue.\r
+ * @param {Number} value The value to set the slider to. (This will be constrained within minValue and maxValue)\r
+ * @param {Boolean} animate Turn on or off animation, defaults to true\r
+ */\r
setValue : function(v, animate, changeComplete){\r
v = this.normalizeValue(v);\r
if(v !== this.value && this.fireEvent('beforechange', this, v, this.value) !== false){\r
}\r
},\r
\r
- // private\r
+ // private\r
translateValue : function(v){\r
var ratio = this.getRatio();\r
return (v * ratio) - (this.minValue * ratio) - this.halfThumb;\r
},\r
\r
- reverseValue : function(pos){\r
+ reverseValue : function(pos){\r
var ratio = this.getRatio();\r
- return (pos + this.halfThumb + (this.minValue * ratio)) / ratio;\r
+ return (pos + (this.minValue * ratio)) / ratio;\r
},\r
\r
- // private\r
+ // private\r
moveThumb: function(v, animate){\r
if(!animate || this.animate === false){\r
this.thumb.setLeft(v);\r
}\r
},\r
\r
- // private\r
+ // private\r
focus : function(){\r
this.focusEl.focus(10);\r
},\r
\r
- // private\r
+ // private\r
onBeforeDragStart : function(e){\r
return !this.disabled;\r
},\r
\r
- // private\r
+ // private\r
onDragStart: function(e){\r
this.thumb.addClass('x-slider-thumb-drag');\r
this.dragging = true;\r
this.fireEvent('dragstart', this, e);\r
},\r
\r
- // private\r
+ // private\r
onDrag: function(e){\r
var pos = this.innerEl.translatePoints(this.tracker.getXY());\r
this.setValue(Ext.util.Format.round(this.reverseValue(pos.left), this.decimalPrecision), false);\r
this.fireEvent('drag', this, e);\r
},\r
\r
- // private\r
+ // private\r
onDragEnd: function(e){\r
this.thumb.removeClass('x-slider-thumb-drag');\r
this.dragging = false;\r
}\r
},\r
\r
- // private\r
+ // private\r
onResize : function(w, h){\r
this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));\r
this.syncThumb();\r
+ Ext.Slider.superclass.onResize.apply(this, arguments);\r
},\r
- \r
+\r
//private\r
onDisable: function(){\r
Ext.Slider.superclass.onDisable.call(this);\r
this.thumb.hide();\r
this.innerEl.addClass(this.disabledClass).dom.disabled = true;\r
if (!this.thumbHolder){\r
- this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass}); \r
+ this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});\r
}\r
this.thumbHolder.show().setXY(xy);\r
}\r
},\r
- \r
+\r
//private\r
onEnable: function(){\r
Ext.Slider.superclass.onEnable.call(this);\r
this.syncThumb();\r
}\r
},\r
- \r
+\r
<div id="method-Ext.Slider-syncThumb"></div>/**\r
* Synchronizes the thumb position to the proper proportion of the total component width based\r
* on the current slider {@link #value}. This will be called automatically when the Slider\r
}\r
},\r
\r
- <div id="method-Ext.Slider-getValue"></div>/**\r
- * Returns the current value of the slider\r
- * @return {Number} The current value of the slider\r
- */\r
+ <div id="method-Ext.Slider-getValue"></div>/**\r
+ * Returns the current value of the slider\r
+ * @return {Number} The current value of the slider\r
+ */\r
getValue : function(){\r
return this.value;\r
},\r
- \r
+\r
// private\r
beforeDestroy : function(){\r
Ext.destroyMembers(this, 'endEl', 'innerEl', 'thumb', 'halfThumb', 'focusEl', 'tracker', 'thumbHolder');\r