Skip to content

Commit

Permalink
Add attribute data-modal-focus-id
Browse files Browse the repository at this point in the history
As kindly suggested by @jpyrat. 

Closed #20
  • Loading branch information
nico3333fr authored Jun 8, 2017
1 parent 06538d5 commit 7d05030
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions jquery-accessible-modal-window-aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jQuery(document).ready(function($) {

/*
* jQuery simple and accessible modal window, using ARIA
* @version v1.7.5
* @version v1.8.0
* Website: https://a11y.nicolas-hoffmann.net/modal/
* License MIT: https://github.com/nico3333fr/jquery-accessible-modal-window-aria/blob/master/LICENSE
*/
Expand All @@ -18,7 +18,7 @@ jQuery(document).ready(function($) {

$this.attr({
'id': 'label_modal_' + index_lisible,
'aria-haspopup' : 'dialog'
'aria-haspopup': 'dialog'
});

});
Expand All @@ -44,6 +44,7 @@ jQuery(document).ready(function($) {
$modal_close_title = options.modalCloseTitle || options.modalCloseText,
$modal_close_img = options.modalCloseImg || '',
$modal_background_click = options.modalBackgroundClick || '',
$modal_focus_id = options.modalFocusId || '',
$modal_code,
$modal_overlay,
$page = $('#js-modal-page');
Expand Down Expand Up @@ -81,15 +82,20 @@ jQuery(document).ready(function($) {
$page.attr('aria-hidden', 'true');

// add overlay
if ($modal_background_click != 'disabled') {
if ($modal_background_click !== 'disabled') {
$modal_overlay = '<span id="js-modal-overlay" class="' + $modal_prefix_classes + 'modal-overlay" title="' + $modal_close_title + '" data-background-click="enabled"><span class="invisible">' + $modal_close_text + '</span></span>';
} else {
$modal_overlay = '<span id="js-modal-overlay" class="' + $modal_prefix_classes + 'modal-overlay" data-background-click="disabled"></span>';
}

$($modal_overlay).insertAfter($('#js-modal'));

$('#js-modal-close').focus();
if ($modal_focus_id !== '') {
$('#' + $modal_focus_id).focus();
} else {
$('#js-modal-close').focus();
}


event.preventDefault();

Expand Down

0 comments on commit 7d05030

Please sign in to comment.