Changeset 5539
- Timestamp:
- 05/09/08 16:48:33 (4 days ago)
- Location:
- trunk/ui
- Files:
-
- 2 modified
-
tests/automated/slider.js (modified) (2 diffs)
-
ui.slider.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/tests/automated/slider.js
r5533 r5539 9 9 stepping: stepping, 10 10 startValue: start, 11 min: 0, 12 max: 1000, 11 13 change: function(e, ui) { 12 14 equals(ui.value, result, "changed to " + ui.value); … … 45 47 })) 46 48 47 test("moveTo, relative positive value, above max", assertChange(1, 10, 100 , function() {48 this.slider("moveTo", "+=200 ");49 test("moveTo, relative positive value, above max", assertChange(1, 10, 1000, function() { 50 this.slider("moveTo", "+=2000"); 49 51 })) 50 52 -
trunk/ui/ui.slider.js
r5538 r5539 184 184 // propagate only for distance > 0, otherwise propagation is done my drag 185 185 this.offset = this.element.offset(); 186 186 187 this.moveTo({ 187 188 y: this.convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"), … … 206 207 }, 207 208 getRange: function() { 208 return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10) ) : null;209 return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null; 209 210 }, 210 211 … … 215 216 if(this.handle.length == 1) this.currentHandle = this.handle; 216 217 if(!axis) axis = this.options.axis == "vertical" ? "y" : "x"; 217 218 var value = ((parseInt($(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle).css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis]; 219 220 var o = this.options; 221 if (o.stepping[axis]) { 222 value = Math.round(value / o.stepping[axis]) * o.stepping[axis]; 223 } 224 return value; 218 219 var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle); 220 221 if(curHandle.data("mouse").sliderValue) { 222 return parseInt(curHandle.data("mouse").sliderValue[axis],10); 223 } else { 224 return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10); 225 } 226 225 227 }, 226 228 convertValue: function(value,axis) { … … 263 265 264 266 265 266 267 268 269 267 start: function(e, handle) { 270 268 … … 321 319 if(o.axis != "horizontal") this.currentHandle.css({ top: position.top }); 322 320 321 //Store the slider's value 322 this.currentHandle.data("mouse").sliderValue = { 323 x: this.convertValue(position.left, "x"), 324 y: this.convertValue(position.top, "y") 325 }; 326 323 327 if (this.rangeElement) 324 328 this.updateRange(); … … 354 358 if(x !== undefined && x.constructor != Number) { 355 359 var me = /^\-\=/.test(x), pe = /^\+\=/.test(x); 356 x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10); 360 if(me || pe) { 361 x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10); 362 } else { 363 x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10); 364 } 357 365 } 358 366 359 367 if(y !== undefined && y.constructor != Number) { 360 368 var me = /^\-\=/.test(y), pe = /^\+\=/.test(y); 361 y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10); 369 if(me || pe) { 370 y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10); 371 } else { 372 y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10); 373 } 362 374 } 363 375 … … 380 392 if (this.rangeElement) 381 393 this.updateRange(); 394 395 //Store the slider's value 396 this.currentHandle.data("mouse").sliderValue = { 397 x: this.convertValue(x, "x"), 398 y: this.convertValue(y, "y") 399 }; 382 400 383 401 if (!noPropagation) {