Changeset 4897
- Timestamp:
- 03/14/08 11:20:46 (9 months ago)
- Location:
- trunk/ui
- Files:
-
- 2 added
- 1 modified
-
tests/slider_test.html (added)
-
tests/slider_test.js (added)
-
ui.slider.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/ui.slider.js
r4890 r4897 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 … … 73 72 .bind('blur', function(e) { self.blur(this.firstChild); }) 74 73 .bind('keydown', function(e) { 75 if(/(37|39)/.test(e.keyCode)) 74 if(/(37|39)/.test(e.keyCode)) { 76 75 self.moveTo((e.keyCode == 37 ? '-' : '+')+'='+(self.options.stepping ? self.options.stepping : (self.options.realMaxValue / self.size)*5),this.firstChild); 76 } 77 77 }) 78 78 ; … … 94 94 95 95 //Move the first handle to the startValue 96 if(!isNaN(o.startValue)) this.moveTo(o.startValue, 0); 96 if (o.startValue && o.startValue.length) { 97 $.each(o.startValue, function(index, value) { 98 self.moveTo(value, index, true); 99 }); 100 } else if (!isNaN(o.startValue)) 101 this.moveTo(o.startValue, 0, true); 97 102 98 103 //If we only have one handle, set the previous handle to this one to allow clicking before selecting the handle … … 137 142 this.element 138 143 .removeClass("ui-slider ui-slider-disabled") 139 .removeData("u l-slider")144 .removeData("ui-slider") 140 145 .unbind(".slider"); 141 this.handle s.removeMouseInteraction();146 this.handle.removeMouseInteraction(); 142 147 }, 143 148 enable: function() { … … 232 237 233 238 }, 234 moveTo: function(value, handle) { 235 239 moveTo: function(value, handle, noPropagation) { 236 240 var o = this.options; 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 } 251 } 252 242 253 if(o.stepping) value = Math.round(value / o.stepping) * o.stepping; 243 254 value = this.translateValue(value); … … 253 264 if(this.rangeElement) this.updateRange(); 254 265 255 this.propagate('start', null); 256 this.propagate('stop', null); 257 this.propagate('change', null); 258 266 if (!noPropagation) { 267 this.propagate('start', null); 268 this.propagate('stop', null); 269 this.propagate('change', null); 270 } 259 271 } 260 272 });
