From: Paul Bakaus Date: Thu, 26 Jun 2008 11:08:52 +0000 (+0000) Subject: slider: range can now be toggled on-the-fly (fixes #3004) X-Git-Tag: 1.5.1~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6a6829db7f2e7223b34d0e21aa372f11eb271344;p=jquery-ui.git slider: range can now be toggled on-the-fly (fixes #3004) --- diff --git a/ui/ui.slider.js b/ui/ui.slider.js index ad15cc04b..72135403d 100644 --- a/ui/ui.slider.js +++ b/ui/ui.slider.js @@ -58,6 +58,11 @@ $.widget("ui.slider", { if (/min|max|steps/.test(key)) { this.initBoundaries(); } + + if(key == "range") { + value ? this.handle.length == 2 && this.createRange() : this.removeRange(); + } + }, init: function() { @@ -200,12 +205,17 @@ $.widget("ui.slider", { createRange: function() { + if(this.rangeElement) return; this.rangeElement = $('
') .addClass('ui-slider-range') .css({ position: 'absolute' }) .appendTo(this.element); this.updateRange(); }, + removeRange: function() { + this.rangeElement.remove(); + this.rangeElement = null; + }, updateRange: function() { var prop = this.options.axis == "vertical" ? "top" : "left"; var size = this.options.axis == "vertical" ? "height" : "width";