Skip to main content

Bug Tracker

Side navigation

Ticket #2053: ui-slider-startValue.patch
File ui-slider-startValue.patch, 2.1 KB (added by joern, March 13, 2008 02:24PM UTC)

startvalue as array for multiple handles patch, requires #2500 to be fixed

Index: ui/ui.slider.js
===================================================================
--- ui/ui.slider.js	(revision 4895)
+++ ui/ui.slider.js	(working copy)
@@ -32,8 +32,7 @@
 		$.extend(o, {
 			axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
 			maxValue: !isNaN(parseInt(o.maxValue,10)) ? parseInt(o.maxValue,10) :  100,
-			minValue: parseInt(o.minValue,10) || 0,
-			startValue: parseInt(o.startValue,10) || 'none'		
+			minValue: parseInt(o.minValue,10) || 0
 		});
 		
 		//Prepare the real maxValue
@@ -93,7 +92,12 @@
 		this.element.bind('click', function(e) { self.click.apply(self, [e]); });
 		
 		//Move the first handle to the startValue
-		if(!isNaN(o.startValue)) this.moveTo(o.startValue, 0);
+		if (o.startValue && o.startValue.length) {
+			$.each(o.startValue, function(index, value) {
+				self.moveTo(value, index);
+			});
+		} else if (!isNaN(o.startValue))
+			this.moveTo(o.startValue, 0);
 		
 		//If we only have one handle, set the previous handle to this one to allow clicking before selecting the handle
 		if(this.handle.length == 1) this.previousHandle = this.handle;
@@ -237,8 +241,17 @@
 			if(handle == undefined && !this.currentHandle && this.handle.length != 1) return false; //If no handle has been passed, no current handle is available and we have multiple handles, return false
 			if(handle == undefined && !this.currentHandle) handle = 0; //If only one handle is available, use it
 			if(handle != undefined) this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
-
-			if(value.constructor == String) value = /\-\=/.test(value) ? this.value() - parseInt(value.replace('-=', ''),10) : this.value() + parseInt(value.replace('+=', ''),10);
+	
+			if(value.constructor == String) {
+				if (/^\-\=/.test(value) ) {
+					value = this.value() - parseInt(value.replace('-=', ''), 10)
+				} else if (/^\+\=/.test(value) ) {
+					value = this.value() + parseInt(value.replace('+=', ''), 10)
+				} else {
+					value = parseInt(value, 10);
+				}
+			}
+			
 			if(o.stepping) value = Math.round(value / o.stepping) * o.stepping;
 			value = this.translateValue(value);

Download in other formats:

Original Format