From 53c8403062623550d28663bab17ae98d916a94c6 Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:52:32 +0100 Subject: [PATCH] patch --- www/public/resources/js/functions.js | 19 ++++++++++++++++++- www/public/resources/js/motion.js | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/www/public/resources/js/functions.js b/www/public/resources/js/functions.js index 693dbb26..cd7d99f6 100644 --- a/www/public/resources/js/functions.js +++ b/www/public/resources/js/functions.js @@ -91,8 +91,20 @@ function printAlert(message, type = null, timeout = 3000) * @param {*} confirmBoxFunction2 * @param {*} confirmBtn2 */ -function confirmBox(message = '', confirmBoxFunction1, confirmBtn1 = 'Delete', confirmBoxFunction2 = null, confirmBtn2 = null) +function confirmBox(message = '', confirmBoxFunction1, confirmBtn1 = 'Delete', confirmBoxFunction2 = null, confirmBtn2 = null, confirmBoxId = null) { + /** + * If there is already a confirm box with the same id, do nothing + * The Id is used to prevent a same confirm box from being re-opened + */ + if (confirmBoxId != null) { + if ($('#confirm-box').length > 0) { + if ($('#confirm-box').attr('confirm-box-id') == confirmBoxId) { + return; + } + } + } + // Remove any existing confirm box $("#confirm-box").remove(); @@ -126,6 +138,11 @@ function confirmBox(message = '', confirmBoxFunction1, confirmBtn1 = 'Delete', c // Append html to footer $('footer').append(html); + // Set confirm box id if specified + if (confirmBoxId != null) { + $('#confirm-box').attr('confirm-box-id', confirmBoxId); + } + // Show confirm box $('#confirm-box').css({ visibility: 'visible' diff --git a/www/public/resources/js/motion.js b/www/public/resources/js/motion.js index 470c49ba..00c49245 100644 --- a/www/public/resources/js/motion.js +++ b/www/public/resources/js/motion.js @@ -304,13 +304,14 @@ $(document).on('click','input[class=event-media-checkbox]',function () { * Print confirm box to delete selected medias */ confirmBox( - '', + 'Delete or download selected media(s)', function () { deleteMedia(); }, 'Delete', function () { downloadMedia(); }, - 'Download' + 'Download', + 'select-media-confirm' ); /**