mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Tweaking attr to normalize for FF2 ARIA implementation. Removed ariaRole and ariaState API. (Assist: Scott González, Fixes #3529)
This commit is contained in:
parent
f425cae7c4
commit
b420cbb3ce
@ -56,16 +56,16 @@ test("accessibility", function() {
|
|||||||
expect(7);
|
expect(7);
|
||||||
el = $("#progressbar").progressbar();
|
el = $("#progressbar").progressbar();
|
||||||
|
|
||||||
equals(el.ariaRole(), "progressbar", "aria role");
|
equals(el.attr("role"), "progressbar", "aria role");
|
||||||
equals(el.ariaState("valuemin"), 0, "aria-valuemin");
|
equals(el.attr("aria-valuemin"), 0, "aria-valuemin");
|
||||||
equals(el.ariaState("valuemax"), 100, "aria-valuemax");
|
equals(el.attr("aria-valuemax"), 100, "aria-valuemax");
|
||||||
equals(el.ariaState("valuenow"), 0, "aria-valuenow initially");
|
equals(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
|
||||||
el.progressbar("progress", 77);
|
el.progressbar("progress", 77);
|
||||||
equals(el.ariaState("valuenow"), 77, "aria-valuenow");
|
equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
|
||||||
el.progressbar("disable");
|
el.progressbar("disable");
|
||||||
equals(el.ariaState("disabled"), "true", "aria-disabled");
|
equals(el.attr("aria-disabled"), "true", "aria-disabled");
|
||||||
el.progressbar("enable");
|
el.progressbar("enable");
|
||||||
equals(el.ariaState("disabled"), "false", "enabled");
|
equals(el.attr("aria-disabled"), "false", "enabled");
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -108,6 +108,27 @@ $.ui = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// WAI-ARIA normalization
|
||||||
|
// tweak $.attr for FF2 implementation
|
||||||
|
if (isFF2){
|
||||||
|
|
||||||
|
var attr = $.attr;
|
||||||
|
$.attr = function(elem, name, value) {
|
||||||
|
var set = value !== undefined,
|
||||||
|
state = /^aria-/;
|
||||||
|
|
||||||
|
return (name == 'role'
|
||||||
|
? (set
|
||||||
|
? attr.call(this, elem, name, "wairole:" + value)
|
||||||
|
: (attr.apply(this, arguments) || "").replace(/^wairole:/, ""))
|
||||||
|
: (state.test(name)
|
||||||
|
? (set
|
||||||
|
? elem.setAttributeNS("http://www.w3.org/2005/07/aaa", name.replace(state, "aaa:"), value)
|
||||||
|
: attr.call(this, elem, name.replace(state, "aaa:")))
|
||||||
|
: attr.apply(this,arguments)));
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//jQuery plugins
|
//jQuery plugins
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
@ -133,32 +154,6 @@ $.fn.extend({
|
|||||||
.attr('unselectable', 'on')
|
.attr('unselectable', 'on')
|
||||||
.css('MozUserSelect', 'none')
|
.css('MozUserSelect', 'none')
|
||||||
.bind('selectstart.ui', function() { return false; });
|
.bind('selectstart.ui', function() { return false; });
|
||||||
},
|
|
||||||
|
|
||||||
// WAI-ARIA Semantics
|
|
||||||
ariaRole: function(role) {
|
|
||||||
return (role !== undefined
|
|
||||||
|
|
||||||
// setter
|
|
||||||
? this.attr("role", isFF2 ? "wairole:" + role : role)
|
|
||||||
|
|
||||||
// getter
|
|
||||||
: (this.attr("role") || "").replace(/^wairole:/, ""));
|
|
||||||
},
|
|
||||||
|
|
||||||
ariaState: function(state, value) {
|
|
||||||
return (value !== undefined
|
|
||||||
|
|
||||||
// setter
|
|
||||||
? this.each(function(i, el) {
|
|
||||||
(isFF2
|
|
||||||
? el.setAttributeNS("http://www.w3.org/2005/07/aaa",
|
|
||||||
"aaa:" + state, value)
|
|
||||||
: $(el).attr("aria-" + state, value));
|
|
||||||
})
|
|
||||||
|
|
||||||
// getter
|
|
||||||
: this.attr(isFF2 ? "aaa:" + state : "aria-" + state));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -83,8 +83,8 @@ $.widget("ui.dialog", {
|
|||||||
(options.closeOnEscape && ev.keyCode
|
(options.closeOnEscape && ev.keyCode
|
||||||
&& ev.keyCode == $.keyCode.ESCAPE && self.close());
|
&& ev.keyCode == $.keyCode.ESCAPE && self.close());
|
||||||
})
|
})
|
||||||
.ariaRole("dialog")
|
.attr("role","dialog")
|
||||||
.ariaState("labelledby", titleId)
|
.attr("aria-labelledby", titleId)
|
||||||
.mouseup(function() {
|
.mouseup(function() {
|
||||||
self.moveToTop();
|
self.moveToTop();
|
||||||
}),
|
}),
|
||||||
|
@ -25,10 +25,10 @@ $.widget("ui.progressbar", {
|
|||||||
this.element
|
this.element
|
||||||
.addClass("ui-progressbar")
|
.addClass("ui-progressbar")
|
||||||
.width(options.width)
|
.width(options.width)
|
||||||
.ariaRole("progressbar")
|
.attr("role","progressbar")
|
||||||
.ariaState("valuemin","0")
|
.attr("aria-valuemin","0")
|
||||||
.ariaState("valuemax","100")
|
.attr("aria-valuemax","100")
|
||||||
.ariaState("valuenow","0");
|
.attr("aria-valuenow","0");
|
||||||
|
|
||||||
$.extend(this, {
|
$.extend(this, {
|
||||||
active: false,
|
active: false,
|
||||||
@ -103,13 +103,13 @@ $.widget("ui.progressbar", {
|
|||||||
disable: function() {
|
disable: function() {
|
||||||
this.element.addClass("ui-progressbar-disabled");
|
this.element.addClass("ui-progressbar-disabled");
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
this.element.ariaState("disabled", true);
|
this.element.attr("aria-disabled", true);
|
||||||
},
|
},
|
||||||
|
|
||||||
enable: function() {
|
enable: function() {
|
||||||
this.element.removeClass("ui-progressbar-disabled");
|
this.element.removeClass("ui-progressbar-disabled");
|
||||||
this.disabled = false;
|
this.disabled = false;
|
||||||
this.element.ariaState("disabled", false);
|
this.element.attr("aria-disabled", false);
|
||||||
},
|
},
|
||||||
|
|
||||||
pause: function() {
|
pause: function() {
|
||||||
@ -132,7 +132,7 @@ $.widget("ui.progressbar", {
|
|||||||
if (this.options.range && !this.options.text) {
|
if (this.options.range && !this.options.text) {
|
||||||
this.textElement.html(percent + '%');
|
this.textElement.html(percent + '%');
|
||||||
}
|
}
|
||||||
this.element.ariaState("valuenow", percent);
|
this.element.attr("aria-valuenow", percent);
|
||||||
this._propagate('progress', this.ui());
|
this._propagate('progress', this.ui());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user