Skip to content

Commit fbb9125

Browse files
committed
fixed #4391 - ui-state-hover, ui-state-active and disabled sliders
1 parent 0c28f50 commit fbb9125

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

ui/ui.slider.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,26 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
7777
this.handle = this.handles.eq(0);
7878

7979
this.handles.add(this.range).filter("a")
80-
.click(function(event) { event.preventDefault(); })
81-
.hover(function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); })
82-
.focus(function() { $(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus'); })
83-
.blur(function() { $(this).removeClass('ui-state-focus'); });
80+
.click(function(event) {
81+
event.preventDefault();
82+
})
83+
.hover(function() {
84+
if (!o.disabled) {
85+
$(this).addClass('ui-state-hover');
86+
}
87+
}, function() {
88+
$(this).removeClass('ui-state-hover');
89+
})
90+
.focus(function() {
91+
if (!o.disabled) {
92+
$(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus');
93+
} else {
94+
$(this).blur();
95+
}
96+
})
97+
.blur(function() {
98+
$(this).removeClass('ui-state-focus');
99+
});
84100

85101
this.handles.each(function(i) {
86102
$(this).data("index.ui-slider-handle", i);
@@ -415,6 +431,14 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
415431
$.widget.prototype._setData.apply(this, arguments);
416432

417433
switch (key) {
434+
case 'disabled':
435+
if (value) {
436+
this.handles.filter(".ui-state-focus").blur();
437+
this.handles.removeClass("ui-state-hover");
438+
this.handles.attr("disabled", "disabled");
439+
} else {
440+
this.handles.removeAttr("disabled");
441+
}
418442
case 'orientation':
419443

420444
this._detectOrientation();

0 commit comments

Comments
 (0)