Skip to main content

Bug Tracker

Side navigation

Ticket #2366: ui_slider_value_round_on_stepping.diff


File ui_slider_value_round_on_stepping.diff, 1.2 KB (added by zimbatm, March 14, 2008 11:22PM UTC)

Round value() if stepping

Index: ui/ui.slider.js
===================================================================
--- ui/ui.slider.js	(revision 4915)
+++ ui/ui.slider.js	(working copy)
@@ -163,7 +163,12 @@
 		},
 		value: function(handle) {
 			if(this.handle.length == 1) this.currentHandle = this.handle;
-			return ((parseInt($(handle != undefined ? this.handle[handle] || handle : this.currentHandle).css(this.properties[0]),10) / (this.size - this.handleSize())) * this.options.realMaxValue) + this.options.minValue;
+			var value = ((parseInt($(handle != undefined ? this.handle[handle] || handle : this.currentHandle).css(this.properties[0]),10) / (this.size - this.handleSize())) * this.options.realMaxValue) + this.options.minValue;
+                        var o = this.options;
+                        if (o.stepping) {
+                            value = Math.round(value / o.stepping) * o.stepping;
+                        }
+                        return value
 		},
 		convertValue: function(value) {
 			return this.options.minValue + (value / (this.size - this.handleSize())) * this.options.realMaxValue;
@@ -271,4 +276,4 @@
 		}
 	});
 
-})(jQuery);
\ No newline at end of file
+})(jQuery);

Download in other formats:

Original Format