diff --git a/language/ar.js b/language/ar.js index a96cac559a8a15dfaec880d4a65f9382aad872b7..9fa5fdbb6671488e689a3975e08df5ce99ea0f27 100644 --- a/language/ar.js +++ b/language/ar.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/bs.js b/language/bs.js index 300eeb9a72647f11cd1c52695537ad73033c8e3e..a7d6bb46ab743ef55ab8c54ec4aab2f7fe961597 100644 --- a/language/bs.js +++ b/language/bs.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/cs.js b/language/cs.js index d73c30bbee1c750f181775dd3f6eb3f36b07c48e..524a3e546a28d84676f25b7ec5a72d56c47da0f7 100644 --- a/language/cs.js +++ b/language/cs.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { enterFullscreenButtonLabel: 'Přejít na celou obrazovku', exitFullscreenButtonLabel: 'Ukončit celou obrazovku', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/de.js b/language/de.js index 2f5c6968cca138bb5044a3f569a34b1b83af9738..0950d4206e80ae983f1244acae8b4c9d04de535f 100644 --- a/language/de.js +++ b/language/de.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/el.js b/language/el.js index c31e15d356cf1cc72bec5d4a091cd15b97dce415..6596f282c4f631ef51a0b2921ca6b772003bb1a4 100644 --- a/language/el.js +++ b/language/el.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/en.js b/language/en.js index d9dc5c6bfb8f4275b76a9c7218576451ae117be7..b2e9051eb7417f09a612111995cf460478e7a2c5 100644 --- a/language/en.js +++ b/language/en.js @@ -292,4 +292,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/es-cr.js b/language/es-cr.js index 48d3115c75d01899a471fdc22c4c1edbff38b887..05e7f5a6ace051c4268cce94d36969e5e0e7cb66 100644 --- a/language/es-cr.js +++ b/language/es-cr.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/es-mx.js b/language/es-mx.js index 8377e7682b7ee2ddbd0fc1c4daae373eff6f0e45..9b52afff299e9d3b88b4edfabe5cb3c7f7c4bd1c 100644 --- a/language/es-mx.js +++ b/language/es-mx.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/es.js b/language/es.js index 7d03b54d80e595b89d55e1182c6d9360b0861ce3..a12ebff284b1d1114630ca502cdbc308d26137bb 100644 --- a/language/es.js +++ b/language/es.js @@ -219,4 +219,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/et.js b/language/et.js index 6c8340e1452e783b5e1d4e22bdf754dfbbe3ce27..69b625284bf26f0440da23ac272ae060caf6e65b 100644 --- a/language/et.js +++ b/language/et.js @@ -219,4 +219,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/eu.js b/language/eu.js index f70044b00656653ef7f10f28a1753f272bd694d4..39b368b6c171f4603ce4c3762a55a473068356de 100644 --- a/language/eu.js +++ b/language/eu.js @@ -219,4 +219,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/fi.js b/language/fi.js index ede2bb0714238010513f4c4e43483c1ac6f63fbb..4d41f51d7fc707c15999f081e1055192dd7007fb 100644 --- a/language/fi.js +++ b/language/fi.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/fr.js b/language/fr.js index d6edc5fc0ac4367bf0be15996fa903dd73b29209..1f2dabe6b95b0f2b8088f896ce99ed6dd8c2974f 100644 --- a/language/fr.js +++ b/language/fr.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/it.js b/language/it.js index 8da641cfb79ca47d8acf5cd9df82e2752b6c1ea3..f0f755f1dfa3470a6b825ab3ecc9fe33f9ebb4f9 100644 --- a/language/it.js +++ b/language/it.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/ko.js b/language/ko.js index 660228b7a36a9bd676b506dcc6718b24693211d3..9c26891462c663852d4331efb9f70f3fee425ea0 100644 --- a/language/ko.js +++ b/language/ko.js @@ -291,5 +291,8 @@ H5PEditor.language.core = { navigateToParent: '상위 탐색', a11yTitleShowLabel: 'AT 에 대한 라벨 표시', a11yTitleHideLabel: 'AT 에 대한 레이블 숨기기', - reuseSuccess: ':title was successfully imported from the H5P Hub.' + reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/nb.js b/language/nb.js index 2c6fc930ef229b85850bce5263e42fa021b1664b..e80336e4ca2e77a42c1f12f51e2f0c7c879e1e04 100644 --- a/language/nb.js +++ b/language/nb.js @@ -290,4 +290,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/nl.js b/language/nl.js index 4f0c0844b0d0a31d131f25ce8bd41cdd92cf129e..6dedb74573ddbd54c08d79de4199fa241689697b 100644 --- a/language/nl.js +++ b/language/nl.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Toon label voor AT', a11yTitleHideLabel: 'Verberg label voor AT', reuseSuccess: ':title is met succes geïmporteerd van de H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/nn.js b/language/nn.js index 59a3b8adc18c3d17fb034e8e9cc1c6de441d05ce..9daa6a540877d373d4219b50920d9c125bdf8ba7 100644 --- a/language/nn.js +++ b/language/nn.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/pl.js b/language/pl.js index e70457eaca369b9c5d5eef20d60a2bde621d8ac3..a342c05bbd078bedc05c9ca5c26884bd04b44b73 100644 --- a/language/pl.js +++ b/language/pl.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/pt-br.js b/language/pt-br.js index bcede23d2c3497d22d43d4f7dc844c65be3e68b9..d24b775f7cc0d628b721ce41e7ebccce4f0e0f3c 100644 --- a/language/pt-br.js +++ b/language/pt-br.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/pt.js b/language/pt.js index 730a4c4e181f2387557f01cc301fdd32d2b6595d..b90d8aa7223830b614b88449fb0fa45b833ce9de 100644 --- a/language/pt.js +++ b/language/pt.js @@ -216,5 +216,8 @@ H5PEditor.language.core = { exitFullscreenButtonLabel: 'Sair de ecrã inteiro', a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', - reuseSuccess: ':title was successfully imported from the H5P Hub.' + reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/ru.js b/language/ru.js index 5b7cbc46d9620826a8784b08a32c445d03a1ff29..2c224321448f0c246ce88c3b040631657bea2b94 100644 --- a/language/ru.js +++ b/language/ru.js @@ -219,4 +219,7 @@ H5PEditor.language.core = { a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/sl.js b/language/sl.js index 8d1b617ba3d4d3eae1c2fd70e33ef9251bdf138d..4ff9d2b743836e8b570848ea5ac74825ceb59c02 100644 --- a/language/sl.js +++ b/language/sl.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { enterFullscreenButtonLabel: 'Vklopi celozaslonski način', exitFullscreenButtonLabel: 'Izklopi celozaslonski način', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/sv.js b/language/sv.js index f2bc093911e7987a85ff640e1c6e80ad2c6a28b0..9e5e7c24e87a0bd21555aab5b5fccb01132872b8 100644 --- a/language/sv.js +++ b/language/sv.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { enterFullscreenButtonLabel: 'Helskärmsläge', exitFullscreenButtonLabel: 'Avsluta helskärm', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/tr.js b/language/tr.js index d5c43c25b9f53fe30d9d32cd2777843a371f5642..bbdb592b7ea57709bce750ccbdc4a4aa9b4f4d56 100644 --- a/language/tr.js +++ b/language/tr.js @@ -216,5 +216,8 @@ H5PEditor.language.core = { exitFullscreenButtonLabel: 'Tam ekrandan çık', a11yTitleShowLabel: 'Show label for AT', a11yTitleHideLabel: 'Hide label for AT', - reuseSuccess: ':title was successfully imported from the H5P Hub.' + reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/language/zh-cn.js b/language/zh-cn.js index a5f2cf6669a115dd1d5dac068cf7459ef64f7e8d..dc77515bbce5db8ae55b10b9002083fad48678ea 100644 --- a/language/zh-cn.js +++ b/language/zh-cn.js @@ -217,4 +217,7 @@ H5PEditor.language.core = { enterFullscreenButtonLabel: '进入全屏', exitFullscreenButtonLabel: '退出全屏', reuseSuccess: ':title was successfully imported from the H5P Hub.', + deleteAuthorTitle: 'Deleting author', + deleteAuthorChangeLogTitle: 'Deleting changelog', + confirm: 'Confirm' }; diff --git a/scripts/h5peditor-metadata-author-widget.js b/scripts/h5peditor-metadata-author-widget.js index 3cdc6dcc4b87f71a6710d036762c15ad9ef5fc10..28193994877e735c7a3a15cdf7fd56c89b755f43 100644 --- a/scripts/h5peditor-metadata-author-widget.js +++ b/scripts/h5peditor-metadata-author-widget.js @@ -140,9 +140,12 @@ H5PEditor.metadataAuthorWidget = function (semantics, params, $wrapper, parent) type: 'button', 'class': 'h5p-metadata-icon-button', click: function () { - if (confirm(H5PEditor.t('core', 'confirmRemoveAuthor'))) { - removeAuthor(author); - } + showConfirmationDialog({ + headerText: H5PEditor.t('core', 'deleteAuthorTitle'), + dialogText: H5PEditor.t('core', 'confirmRemoveAuthor'), + cancelText: H5PEditor.t('core', 'cancel'), + confirmText: H5PEditor.t('core', 'confirm'), + }, handleFormDiaologActions); } }).appendTo(listItem); @@ -152,6 +155,40 @@ H5PEditor.metadataAuthorWidget = function (semantics, params, $wrapper, parent) wrapper.append(authorList); } + /** + * Callback confirm/cancel action + * @param {boolean} [confirmFlag] Which button is clicked + */ + function handleFormDiaologActions(confirmFlag) { + if (confirmFlag) { + removeAuthor(author); + } + } + + /** + * Add confirmation dialog to button. + * @param {object} dialogOptions Dialog options. + * @param {function} handleActions Handle both actions Confirmed and Canceled. + */ + function showConfirmationDialog(dialogOptions, handleActions) { + const confirmationDialog = new H5P.ConfirmationDialog(dialogOptions) + .appendTo(document.body); + + confirmationDialog.on('confirmed', () => { + if (handleActions) { + handleActions(true); + } + }); + + confirmationDialog.on('canceled', () => { + if (handleActions) { + handleActions(false); + } + }); + + confirmationDialog.show(); + } + return { addAuthor: addAuthor, addDefaultAuthor: addDefaultAuthor diff --git a/scripts/h5peditor-metadata-changelog-widget.js b/scripts/h5peditor-metadata-changelog-widget.js index e664dbe281abd67937490416d52661e06612a6c0..b65772ce3d99cac5924fb80f806bc62b878528aa 100644 --- a/scripts/h5peditor-metadata-changelog-widget.js +++ b/scripts/h5peditor-metadata-changelog-widget.js @@ -169,11 +169,12 @@ H5PEditor.metadataChangelogWidget = function (semantics, params, $wrapper, paren logButtons.find('.h5p-metadata-delete').click(function () { // Ask for confirmation - if (confirm(H5PEditor.t('core', 'confirmDeleteChangeLog'))) { - var wrapper = $(this).closest('.h5p-metadata-log'); - var index = $(wrapper).data('index'); - deleteLog(index); - } + showConfirmationDialog({ + headerText: H5PEditor.t('core', 'deleteAuthorChangeLogTitle'), + dialogText: H5PEditor.t('core', 'confirmDeleteChangeLog'), + cancelText: H5PEditor.t('core', 'cancel'), + confirmText: H5PEditor.t('core', 'confirm'), + }, handleFormDiaologActions); }); logButtons.find('.h5p-metadata-edit').click(function () { @@ -196,6 +197,18 @@ H5PEditor.metadataChangelogWidget = function (semantics, params, $wrapper, paren } } + /** + * Callback confirm/cancel action + * @param {boolean} [confirmFlag] Which button is clicked + */ + function handleFormDiaologActions (confirmFlag) { + if (confirmFlag) { + var wrapper = $(this).closest('.h5p-metadata-log'); + var index = $(wrapper).data('index'); + deleteLog(index); + } + } + function editLog(index) { state.editing = true; state.currentLog = index; @@ -271,4 +284,28 @@ H5PEditor.metadataChangelogWidget = function (semantics, params, $wrapper, paren async: true }); } + + /** + * Add confirmation dialog to button. + * @param {object} dialogOptions Dialog options. + * @param {function} handleActions Handle both actions Confirmed and Canceled. + */ + function showConfirmationDialog (dialogOptions, handleActions) { + const confirmationDialog = new H5P.ConfirmationDialog(dialogOptions) + .appendTo(document.body); + + confirmationDialog.on('confirmed', () => { + if (handleActions) { + handleActions(true); + } + }); + + confirmationDialog.on('canceled', () => { + if (handleActions) { + handleActions(false); + } + }); + + confirmationDialog.show(); + } };