Ticket #2053: ui-slider-startValue.patch
| File ui-slider-startValue.patch, 2.1 kB (added by joern, 6 months ago) |
|---|
-
ui/ui.slider.js
32 32 $.extend(o, { 33 33 axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'), 34 34 maxValue: !isNaN(parseInt(o.maxValue,10)) ? parseInt(o.maxValue,10) : 100, 35 minValue: parseInt(o.minValue,10) || 0, 36 startValue: parseInt(o.startValue,10) || 'none' 35 minValue: parseInt(o.minValue,10) || 0 37 36 }); 38 37 39 38 //Prepare the real maxValue … … 93 92 this.element.bind('click', function(e) { self.click.apply(self, [e]); }); 94 93 95 94 //Move the first handle to the startValue 96 if(!isNaN(o.startValue)) this.moveTo(o.startValue, 0); 95 if (o.startValue && o.startValue.length) { 96 $.each(o.startValue, function(index, value) { 97 self.moveTo(value, index); 98 }); 99 } else if (!isNaN(o.startValue)) 100 this.moveTo(o.startValue, 0); 97 101 98 102 //If we only have one handle, set the previous handle to this one to allow clicking before selecting the handle 99 103 if(this.handle.length == 1) this.previousHandle = this.handle; … … 237 241 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 238 242 if(handle == undefined && !this.currentHandle) handle = 0; //If only one handle is available, use it 239 243 if(handle != undefined) this.currentHandle = this.previousHandle = $(this.handle[handle] || handle); 240 241 if(value.constructor == String) value = /\-\=/.test(value) ? this.value() - parseInt(value.replace('-=', ''),10) : this.value() + parseInt(value.replace('+=', ''),10); 244 245 if(value.constructor == String) { 246 if (/^\-\=/.test(value) ) { 247 value = this.value() - parseInt(value.replace('-=', ''), 10) 248 } else if (/^\+\=/.test(value) ) { 249 value = this.value() + parseInt(value.replace('+=', ''), 10) 250 } else { 251 value = parseInt(value, 10); 252 } 253 } 254 242 255 if(o.stepping) value = Math.round(value / o.stepping) * o.stepping; 243 256 value = this.translateValue(value); 244 257
