diff --git a/js/h5p.js b/js/h5p.js index 5a1c9e1..5de66e2 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -122,13 +122,15 @@ H5P.init = function (target) { delete contentData.contentUserData; var dialog = new H5P.Dialog('content-user-data-reset', 'Data Reset', '
' + H5P.t('contentChanged') + '
' + H5P.t('startingOver') + '
', $container); H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) { - $dialog.find('.h5p-dialog-ok-button').click(function () { - dialog.close(); - }).keypress(function (event) { - if (event.which === 32) { + + var closeDialog = function (event) { + if (event.type === 'click' || event.which === 32) { dialog.close(); + H5P.deleteUserData(contentId, 'state', 0); } - }); + }; + + $dialog.find('.h5p-dialog-ok-button').click(closeDialog).keypress(closeDialog); }); dialog.open(); }