parent
e10594fb49
commit
51851f14c3
|
@ -17,6 +17,10 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
|||
EventDispatcher.call(this);
|
||||
var self = this;
|
||||
|
||||
// Make sure confirmation dialogs have unique id
|
||||
H5P.ConfirmationDialog.uniqueId += 1;
|
||||
var uniqueId = H5P.ConfirmationDialog.uniqueId;
|
||||
|
||||
// Default options
|
||||
options = options || {};
|
||||
options.headerText = options.headerText || H5P.t('confirmDialogHeader');
|
||||
|
@ -70,6 +74,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
|||
var popup = document.createElement('div');
|
||||
popup.classList.add('h5p-confirmation-dialog-popup', 'hidden');
|
||||
popup.setAttribute('role', 'dialog');
|
||||
popup.setAttribute('aria-labelledby', 'h5p-confirmation-dialog-dialog-text-' + uniqueId);
|
||||
popupBackground.appendChild(popup);
|
||||
popup.addEventListener('keydown', function (e) {
|
||||
if (e.which === 27) {// Esc key
|
||||
|
@ -97,8 +102,8 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
|||
// Popup text
|
||||
var text = document.createElement('div');
|
||||
text.classList.add('h5p-confirmation-dialog-text');
|
||||
text.setAttribute('role', 'alert');
|
||||
text.innerHTML = options.dialogText;
|
||||
text.id = 'h5p-confirmation-dialog-dialog-text-' + uniqueId;
|
||||
body.appendChild(text);
|
||||
|
||||
// Popup buttons
|
||||
|
@ -346,3 +351,5 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
|||
return ConfirmationDialog;
|
||||
|
||||
}(H5P.EventDispatcher));
|
||||
|
||||
H5P.ConfirmationDialog.uniqueId = -1;
|
||||
|
|
Loading…
Reference in New Issue