]> source.dussan.org Git - jquery-ui.git/commitdiff
slider: range can now be toggled on-the-fly (fixes #3004)
authorPaul Bakaus <paul.bakaus@googlemail.com>
Thu, 26 Jun 2008 11:08:52 +0000 (11:08 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Thu, 26 Jun 2008 11:08:52 +0000 (11:08 +0000)
ui/ui.slider.js

index ad15cc04b96a994099aaf6b0ba4a567f6d766798..72135403dcec74948c6e53d67b9bece32fe465c6 100644 (file)
@@ -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 = $('<div></div>')
                        .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";