### Eclipse Workspace Patch 1.0 #P jQuery Index: tests/unit/slider/slider_core.js =================================================================== --- tests/unit/slider/slider_core.js (revision 2920) +++ tests/unit/slider/slider_core.js (working copy) @@ -243,4 +243,84 @@ el.slider("destroy"); }); +test("ARIA Min and Max", function() { + el = $('
'); + + options = { + max: 54, + min: 3, + orientation: 'horizontal', + value:15 + }; + + el.slider(options); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 54, "The ARIA-valuemax should be 54" ); + equals(handles.attr("aria-valuemin"), 3, "The ARIA-valuemin should be 3" ); + equals(handles.attr("aria-valuenow"), 15, "The ARIA-valuenow should be 15" ); + el.slider('destroy'); +}); + +test("ARIA Min and Max with default options", function() { + el = $(''); + + options = {}; + + el.slider(options); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 100, "The ARIA max should be 100" ); + equals(handles.attr("aria-valuemin"), 0, "The ARIA min should be 0" ); + equals(handles.attr("aria-valuenow"), 0, "The ARIA-valuenow should be 0" ); + el.slider('destroy'); +}); + +test("ARIA-valuenow after keydown LEFT", function(){ + el = $(''); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 4 + }; + el.slider(options); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(el.slider("value"), 3); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(el.slider("value"), 2); + + el.slider("destroy"); + +}); + +test("ARIA-valuenow after keydown RIGHT", function(){ + el = $(''); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 2 + }; + el.slider(options); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(el.slider("value"), 3); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(el.slider("value"), 4); + + el.slider("destroy"); + +}); + + })(jQuery); Index: ui/ui.slider.js =================================================================== --- ui/ui.slider.js (revision 2920) +++ ui/ui.slider.js (working copy) @@ -25,14 +25,14 @@ this.element .addClass("ui-slider" - + " ui-slider-" + this.orientation + + " ui-slider-" + this.orientation + " ui-widget" + " ui-widget-content" + " ui-corner-all"); this.range = $([]); - if (o.range) { + if (o.range) { if (o.range === true) { this.range = $(''); @@ -59,13 +59,13 @@ } if ($(".ui-slider-handle", this.element).length == 0) - $('') - .appendTo(this.element) - .addClass("ui-slider-handle"); + $('') + .appendTo(this.element) + .addClass("ui-slider-handle"); if (o.values && o.values.length) { while ($(".ui-slider-handle", this.element).length < o.values.length) - $('') + $('') .appendTo(this.element) .addClass("ui-slider-handle"); } @@ -106,8 +106,7 @@ var ret = true; - var index = $(this).data("index.ui-slider-handle"); + var index = $(this).data("index.ui-slider-handle"); if (self.options.disabled) return; @@ -170,10 +169,17 @@ }); + var ariaDefaults = {role: 'slider', + "aria-valuenow": this.options.value, + "aria-valuemin": this.options.min, + "aria-valuemax": this.options.max, + }; + this.handles.attr(ariaDefaults); + this._refreshValue(); }, - + destroy: function() { this.handles.remove(); @@ -368,7 +374,7 @@ this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate )); } - } + } } @@ -385,7 +391,7 @@ } this._trigger("stop", event, uiHash); }, - + _change: function(event, index) { var uiHash = { handle: this.handles[index], @@ -395,9 +401,11 @@ uiHash.value = this.values(index); uiHash.values = this.values(); } + this._trigger("change", event, uiHash); }, + value: function(newValue) { if (arguments.length) { @@ -469,6 +477,7 @@ if (val < this._valueMin()) val = this._valueMin(); if (val > this._valueMax()) val = this._valueMax(); + this.handles.attr("aria-valuenow",val); return val; }, @@ -550,7 +559,7 @@ range: false, step: 1, value: 0, - values: null + values: null, }) });