From 10e1a7ba65957792a71030b1917d79ecb1f41e26 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 7 Jun 2016 15:09:59 +0200 Subject: [PATCH] Use DOM Level 2 events. HFJ-1999 --- js/h5p-confirmation-dialog.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index cb326c6..3c16214 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -71,12 +71,12 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { popup.classList.add('h5p-confirmation-dialog-popup', 'hidden'); popup.setAttribute('role', 'dialog'); popupBackground.appendChild(popup); - popup.onkeydown = function (e) { + popup.addEventListener('keydown', function (e) { if (e.which === 27) {// Esc key // Exit dialog dialogCanceled(e); } - }; + }); // Popup header var header = document.createElement('div'); @@ -123,36 +123,36 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { exitButton.title = options.cancelText; // Cancel handler - cancelButton.onclick = dialogCanceled; - cancelButton.onkeydown = function (e) { + cancelButton.addEventListener('click', dialogCanceled); + cancelButton.addEventListener('keydown', function (e) { if (e.which === 32) { // Space dialogCanceled(e); } else if (e.which === 9 && e.shiftKey) { // Shift-tab flowTo(exitButton, e); } - }; + }); buttons.appendChild(cancelButton); // Confirm handler - confirmButton.onclick = dialogConfirmed; - confirmButton.onkeydown = function (e) { + confirmButton.addEventListener('click', dialogConfirmed); + confirmButton.addEventListener('keydown', function (e) { if (e.which === 32) { // Space dialogConfirmed(e); } - }; + }); buttons.appendChild(confirmButton); // Exit handler - exitButton.onclick = dialogCanceled; - exitButton.onkeydown = function (e) { + exitButton.addEventListener('click', dialogCanceled); + exitButton.addEventListener('keydown', function (e) { if (e.which === 32) { // Space dialogCanceled(e); } else if (e.which === 9 && !e.shiftKey) { // Tab flowTo(cancelButton, e); } - }; + }); popup.appendChild(exitButton); // Wrapper element