Skip to content

Commit

Permalink
added simple ARIA screen reader support
Browse files Browse the repository at this point in the history
  • Loading branch information
Greta Krafsig committed Jan 14, 2014
1 parent 0ad3ca3 commit 45c6362
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
*
* Author: John Papa and Hans Fjällemark
* ARIA Support: Greta Krafsig
* Project: https://github.com/CodeSeven/toastr
*/
; (function (define) {
Expand All @@ -25,6 +26,7 @@

var toastr = {
clear: clear,
remove: remove,
error: error,
getContainer: getContainer,
info: info,
Expand Down Expand Up @@ -101,6 +103,18 @@
});
}
}

function remove($toastElement) {
var options = getOptions();
if (!$container) { getContainer(options); }
if ($toastElement && $(':focus', $toastElement).length === 0) {
removeToast($toastElement);
return;
}
if ($container.children().length) {
$container.remove();
}
}
//#endregion

//#region Internal Methods
Expand Down Expand Up @@ -188,7 +202,7 @@
}

if (options.closeButton) {
$closeElement.addClass('toast-close-button');
$closeElement.addClass('toast-close-button').attr("role", "button");
$toastElement.prepend($closeElement);
}

Expand Down Expand Up @@ -277,7 +291,10 @@
}
$container = $('<div/>')
.attr('id', options.containerId)
.addClass(options.positionClass);
.addClass(options.positionClass)
.attr('aria-live', 'polite')
.attr('role', 'alert');

$container.appendTo($(options.target));
return $container;
}
Expand Down Expand Up @@ -307,4 +324,4 @@
} else {
window['toastr'] = factory(window['jQuery']);
}
}));
}));

0 comments on commit 45c6362

Please sign in to comment.