aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui.slider.js
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2009-02-17 12:21:42 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2009-02-17 12:21:42 +0000
commit9c4b8a9141db4718126f7d383267b22f4eb5df71 (patch)
treef72b6b92ad86796b6d9cba2c61d68aaccde4ac4c /ui/ui.slider.js
parent77043b9bf2baf00034463cf9dc690976e181b31c (diff)
downloadjquery-ui-9c4b8a9141db4718126f7d383267b22f4eb5df71.tar.gz
jquery-ui-9c4b8a9141db4718126f7d383267b22f4eb5df71.zip
slider:
- fixed propagation of change event within _slide (fixes #4005 - slider and change callback with range: true) - normalized all ui hash information
Diffstat (limited to 'ui/ui.slider.js')
-rw-r--r--ui/ui.slider.js64
1 files changed, 32 insertions, 32 deletions
diff --git a/ui/ui.slider.js b/ui/ui.slider.js
index a9a9b4cdc..91f257157 100644
--- a/ui/ui.slider.js
+++ b/ui/ui.slider.js
@@ -101,7 +101,7 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
if (!self._keySliding) {
self._keySliding = true;
$(this).addClass("ui-state-active");
- self._start(event);
+ self._start(event, index);
}
break;
}
@@ -138,9 +138,11 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
}).keyup(function(event) {
+ var index = $(this).data("index.ui-slider-handle");
+
if (self._keySliding) {
- self._stop(event);
- self._change(event);
+ self._stop(event, index);
+ self._change(event, index);
self._keySliding = false;
$(this).removeClass("ui-state-active");
}
@@ -177,8 +179,6 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
if (o.disabled)
return false;
- this._start(event);
-
this.elementSize = {
width: this.element.outerWidth(),
height: this.element.outerHeight()
@@ -206,6 +206,8 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
closestHandle = $(this.handles[++index]);
}
+ this._start(event, index);
+
self._handleIndex = index;
closestHandle
@@ -247,8 +249,8 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
_mouseStop: function(event) {
this.handles.removeClass("ui-state-active");
- this._stop(event);
- this._change(event);
+ this._stop(event, this._handleIndex);
+ this._change(event, this._handleIndex);
this._handleIndex = null;
this._clickOffset = null;
@@ -289,10 +291,8 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
},
- _start: function(event) {
- this._trigger("start", event, {
- value: this.value()
- });
+ _start: function(event, index) {
+ this._trigger("start", event, this._uiHash(index));
},
_slide: function(event, index, newVal) {
@@ -310,14 +310,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
var newValues = this.values();
newValues[index] = newVal;
// A slide can be canceled by returning false from the slide callback
- var allowed = this._trigger("slide", event, {
- handle: handle,
- value: newVal,
- values: newValues
- });
+ var allowed = this._trigger("slide", event, this._uiHash(index, newVal, newValues));
var otherVal = this.values(index ? 0 : 1);
if (allowed !== false) {
- this.values(index, newVal, ( event.type == 'mousedown' && this.options.animate ));
+ this.values(index, newVal, ( event.type == 'mousedown' && this.options.animate ), true);
}
}
@@ -325,10 +321,7 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
if (newVal != this.value()) {
// A slide can be canceled by returning false from the slide callback
- var allowed = this._trigger("slide", event, {
- handle: handle,
- value: newVal
- });
+ var allowed = this._trigger("slide", event, this._uiHash(index, newVal));
if (allowed !== false) {
this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate ));
}
@@ -339,35 +332,31 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
},
- _stop: function(event) {
- this._trigger("stop", event, {
- value: this.value()
- });
+ _stop: function(event, index) {
+ this._trigger("stop", event, this._uiHash(index));
},
- _change: function(event) {
- this._trigger("change", event, {
- value: this.value()
- });
+ _change: function(event, index) {
+ this._trigger("change", event, this._uiHash(index));
},
value: function(newValue) {
if (arguments.length) {
this._setData("value", newValue);
- this._change();
+ this._change(null, 0);
}
return this._value();
},
- values: function(index, newValue, animated) {
+ values: function(index, newValue, animated, noPropagation) {
if (arguments.length > 1) {
this.options.values[index] = newValue;
this._refreshValue(animated);
- this._change();
+ if(!noPropagation) this._change(null, index);
}
if (arguments.length) {
@@ -479,6 +468,17 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
(oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ bottom: valPercent + '%', height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate });
}
+ },
+
+ _uiHash: function(index, value, values) {
+
+ var multiple = this.options.values && this.options.values.length;
+ return {
+ handle: this.handles[index],
+ value: value || (multiple ? this.values(index) : this.value()),
+ values: values || (multiple && this.values())
+ };
+
}
}));