]> source.dussan.org Git - jquery-ui.git/commitdiff
slider: fixed disabled on init, methods enable and disable
authorRichard Worth <rdworth@gmail.com>
Sat, 19 Sep 2009 15:19:42 +0000 (15:19 +0000)
committerRichard Worth <rdworth@gmail.com>
Sat, 19 Sep 2009 15:19:42 +0000 (15:19 +0000)
tests/unit/slider/slider_methods.js
ui/jquery.ui.slider.js

index 711c16f2c3e6385579a6c91ae8fb5c14e8d83c8d..37977efb9bbd7af5b0fa8ece3fc62492ff1ea00c 100644 (file)
@@ -69,14 +69,26 @@ test("enable", function() {
        var expected = $('<div></div>').slider(),
                actual = expected.slider('enable');
        equals(actual, expected, 'enable is chainable');
-       ok(false, "missing test - untested code is broken code.");
+
+       var el = $('<div></div>').slider({ disabled: true });
+       ok(el.hasClass('.ui-disabled'), 'slider has ui-disabled class before enable method call');
+       ok(el.hasClass('.ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call');
+       el.slider('enable');
+       ok(!el.hasClass('.ui-disabled'), 'slider does not have ui-disabled class after enable method call');
+       ok(!el.hasClass('.ui-slider-disabled'), 'slider does not have ui-slider-disabled class after enable method call');
 });
 
 test("disable", function() {
        var expected = $('<div></div>').slider(),
                actual = expected.slider('disable');
        equals(actual, expected, 'disable is chainable');
-       ok(false, "missing test - untested code is broken code.");
+
+       var el = $('<div></div>').slider({ disabled: false });
+       ok(!el.hasClass('.ui-disabled'), 'slider does not have ui-disabled class before disabled method call');
+       ok(!el.hasClass('.ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call');
+       el.slider('disable');
+       ok(el.hasClass('.ui-disabled'), 'slider has ui-disabled class after disable method call');
+       ok(el.hasClass('.ui-slider-disabled'), 'slider has ui-slider-disabled class after disable method call');
 });
 
 test("value", function() {
index f2ea5f67e3cdeb2de3d591614b3d31d274929f61..ca2dad2eb646c145a49715a9362f3328a93a3076 100644 (file)
@@ -29,6 +29,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
                                + " ui-widget"
                                + " ui-widget-content"
                                + " ui-corner-all");
+               
+               if (o.disabled) {
+                       this.element.addClass('ui-slider-disabled ui-disabled');
+               }
 
                this.range = $([]);
 
@@ -439,8 +443,10 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
                                        this.handles.filter(".ui-state-focus").blur();
                                        this.handles.removeClass("ui-state-hover");
                                        this.handles.attr("disabled", "disabled");
+                                       this.element.addClass("ui-disabled");
                                } else {
                                        this.handles.removeAttr("disabled");
+                                       this.element.removeClass("ui-disabled");
                                }
                        case 'orientation':