Bug Tracker

Ticket #2366: ui_slider_value_round_on_stepping.diff

File ui_slider_value_round_on_stepping.diff, 1.2 kB (added by zimbatm, 10 months ago)

Round value() if stepping

  • ui/ui.slider.js

     
    163163        }, 
    164164        value: function(handle) { 
    165165            if(this.handle.length == 1) this.currentHandle = this.handle; 
    166             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; 
     166            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; 
     167                        var o = this.options; 
     168                        if (o.stepping) { 
     169                            value = Math.round(value / o.stepping) * o.stepping; 
     170                        } 
     171                        return value 
    167172        }, 
    168173        convertValue: function(value) { 
    169174            return this.options.minValue + (value / (this.size - this.handleSize())) * this.options.realMaxValue; 
     
    271276        } 
    272277    }); 
    273278 
    274 })(jQuery); 
    275  No newline at end of file 
     279})(jQuery);