From 6a6829db7f2e7223b34d0e21aa372f11eb271344 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Thu, 26 Jun 2008 11:08:52 +0000 Subject: [PATCH] slider: range can now be toggled on-the-fly (fixes #3004) --- ui/ui.slider.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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"; -- 2.39.5