Answer checks should offer feedback to assistive tech. This commit adds

a page level javascript SR object to enable reading of alert messages.
LMS-2158
This commit is contained in:
Dave St.Germain
2014-02-13 13:50:41 -05:00
parent 021e6f5b45
commit 0773f0687d
25 changed files with 310 additions and 217 deletions

View File

@@ -141,3 +141,39 @@ $('.nav-skip').keypress(function(e) {
}
}
});
// Creates a window level SR object that can be used for giving audible feedback to screen readers.
$(function(){
var SRAlert;
SRAlert = (function() {
function SRAlert() {
$('body').append('<div id="reader-feedback" class="sr" style="display:none" aria-hidden="false" aria-atomic="true" aria-live="assertive"></div>');
this.el = $('#reader-feedback');
}
SRAlert.prototype.clear = function() {
return this.el.html(' ');
};
SRAlert.prototype.readElts = function(elts) {
var feedback,
_this = this;
feedback = '';
$.each(elts, function(idx, value) {
return feedback += '<p>' + $(value).html() + '</p>\n';
});
return this.el.html(feedback);
};
SRAlert.prototype.readText = function(text) {
return this.el.text(text);
};
return SRAlert;
})();
window.SR = new SRAlert;
});