From eacad2a4b8b1ca1eab2490e5995ca6174b7cd3a1 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 15 Oct 2020 17:40:58 +0200 Subject: [PATCH] fixes #1240 use a modern and customizable confirmation popins * plugins: install, restore, deactivate all, uninstall, delete * themes: delete * languages: delete * maintenance: lock gallery, purge history detail, purge history summary, purge search history and delete all sizes butto * rates: delete user rates * sites: remove a site * updates: update all extensions * users: delete batch manager now confirms deletion of derivative like deletion of photos (no more alert popin) theme manager: box styling like plugins, delete is in dropdown, with icon for activate and delete --- admin/themes/default/js/batchManagerGlobal.js | 4 +- admin/themes/default/js/common.js | 45 ++++++++- .../default/template/batch_manager_global.tpl | 28 +++++- .../default/template/configuration_sizes.tpl | 21 ++++- .../default/template/languages_installed.tpl | 19 +++- admin/themes/default/template/maintenance.tpl | 62 ++++++++++++- .../default/template/plugins_installed.tpl | 91 ++++++++++++++----- admin/themes/default/template/plugins_new.tpl | 46 +++++++--- admin/themes/default/template/rating_user.tpl | 62 ++++++++----- .../themes/default/template/site_manager.tpl | 20 +++- .../default/template/themes_installed.tpl | 32 +++++-- admin/themes/default/template/updates_ext.tpl | 49 +++++++--- admin/themes/default/template/user_list.tpl | 67 +++++++++----- admin/themes/default/theme.css | 22 ++++- language/en_UK/admin.lang.php | 18 +++- language/fr_FR/admin.lang.php | 28 ++++-- 16 files changed, 479 insertions(+), 135 deletions(-) diff --git a/admin/themes/default/js/batchManagerGlobal.js b/admin/themes/default/js/batchManagerGlobal.js index 20570f8eb..741aa8fcf 100644 --- a/admin/themes/default/js/batchManagerGlobal.js +++ b/admin/themes/default/js/batchManagerGlobal.js @@ -229,10 +229,10 @@ function selectGenerateDerivNone() { } function selectDelDerivAll() { - $("#action_delete_derivatives input[type=checkbox]").prop("checked", true).trigger("change"); + $('#action_delete_derivatives input[name="del_derivatives_type[]"]').prop("checked", true).trigger("change"); } function selectDelDerivNone() { - $("#action_delete_derivatives input[type=checkbox]").prop("checked", false).trigger("change"); + $('#action_delete_derivatives input[name="del_derivatives_type[]"]').prop("checked", false).trigger("change"); } /* sync metadatas or delete photos by blocks, with progress bar */ diff --git a/admin/themes/default/js/common.js b/admin/themes/default/js/common.js index cfda00f3e..11504da8b 100644 --- a/admin/themes/default/js/common.js +++ b/admin/themes/default/js/common.js @@ -263,7 +263,6 @@ const jConfirm_confirm_options = { draggable: false, titleClass: "jconfirmDeleteConfirm", theme: "modern", - content: "", animation: "zoom", boxWidth: '40%', useBootstrap: false, @@ -271,4 +270,48 @@ const jConfirm_confirm_options = { animateFromElement: false, backgroundDismiss: true, typeAnimated: false, +} + +const jConfirm_confirm_with_content_options = { + draggable: false, + theme: "modern", + animation: "zoom", + boxWidth: '40%', + useBootstrap: false, + type: 'red', + animateFromElement: false, + backgroundDismiss: true, + typeAnimated: false, +} + + + +jQuery.fn.pwg_jconfirm_follow_href = function({ + alert_title = "TITLE", + alert_confirm = "CONFIRM", + alert_cancel = "CANCEL", + alert_content = "" +} = {}) { + let button_href = $(this).attr('href'); + const options = alert_content === "" ? jConfirm_confirm_options : jConfirm_confirm_with_content_options + $(this).click(function() { + $.confirm({ + content: alert_content, + title: alert_title, + buttons: { + confirm: { + text: alert_confirm, + btnClass: 'btn-red', + action: function () { + window.location.href = button_href; + } + }, + cancel: { + text: alert_cancel + } + }, + ...options + }); + return (false); + }); } \ No newline at end of file diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index 9c99d0f4d..a7e6e2ca1 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -230,14 +230,23 @@ $(document).ready(function() { return false; }); + + jQuery("#action_delete_derivatives input[name=confirm_deletion]").change(function() { + jQuery("#action_delete_derivatives span.errors").hide(); + }); + jQuery('#applyAction').click(function() { var action = jQuery('[name="selectAction"]').val(); if (action == 'delete_derivatives') { - var d_count = $('#action_delete_derivatives input[type=checkbox]').filter(':checked').length - , e_count = $('input[name="setSelected"]').is(':checked') ? nb_thumbs_set : $('.thumbnails input[type=checkbox]').filter(':checked').length; - if (d_count*e_count > 500) - return confirm(lang.AreYouSure); - } + let d_count = $('#action_delete_derivatives input[type=checkbox]').filter(':checked').length + let e_count = $('input[name="setSelected"]').is(':checked') ? nb_thumbs_set : $('.thumbnails input[type=checkbox]').filter(':checked').length; + if (!jQuery("#action_delete_derivatives input[name=confirm_deletion]").is(':checked')) { + jQuery("#action_delete_derivatives span.errors").show(); + return false; + } else { + return true; + } + } if (action != 'generate_derivatives' || derivatives.finished() ) @@ -324,6 +333,10 @@ var sliders = { {/footer_script} +{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'} +{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"} +{combine_css path="admin/themes/default/fontello/css/animation.css"} +

{'Batch Manager'|@translate}

@@ -737,6 +750,11 @@ UL.thumbnails SPAN.wrap2 {ldelim}
+ +
{'All'|@translate} {'None'|@translate} diff --git a/admin/themes/default/template/configuration_sizes.tpl b/admin/themes/default/template/configuration_sizes.tpl index d4c44e2f6..da67476fa 100644 --- a/admin/themes/default/template/configuration_sizes.tpl +++ b/admin/themes/default/template/configuration_sizes.tpl @@ -1,6 +1,21 @@ {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} - +{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'} +{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"} {footer_script} + + +const title_msg = '{'Are you sure you want to restore to default settings?'|@translate|@escape}'; +const confirm_msg = '{'Yes, I am sure'|@translate|@escape}'; +const cancel_msg = '{'No, I have changed my mind'|@translate|@escape}'; + +$(".restore-settings-button").each(function() { + $(this).pwg_jconfirm_follow_href({ + alert_title: title_msg, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); + (function(){ var labelMaxWidth = "{'Maximum width'|translate}", labelWidth = "{'Width'|translate}", @@ -50,7 +65,7 @@ jQuery(this).css("visibility", "hidden"); return false; }); -}()); +})(); {/footer_script} {html_style} @@ -201,7 +216,7 @@ {if isset($ferrors.resize_quality)}!{/if}

- {'Reset to default values'|translate} + {'Reset to default values'|translate}

{if !empty($custom_derivatives)} diff --git a/admin/themes/default/template/languages_installed.tpl b/admin/themes/default/template/languages_installed.tpl index 192cfcc61..c7068d441 100644 --- a/admin/themes/default/template/languages_installed.tpl +++ b/admin/themes/default/template/languages_installed.tpl @@ -1,3 +1,20 @@ +{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} +{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'} +{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"} +{footer_script} +$(".delete-lang-button").each(function() { + let title_msg = '{'Are you sure you want to delete the language "%s"?'|@translate|@escape:'javascript'}'; + const confirm_msg = '{"Yes, I am sure"|@translate}'; + const cancel_msg = '{"No, I have changed my mind"|@translate|@escape:'javascript'}'; + let lang_name = $(this).closest(".languageBox").find('.languageName').html(); + $(this).pwg_jconfirm_follow_href({ + alert_title: title_msg.replace("%s", lang_name), + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); +{/footer_script} +

{'Installed Languages'|@translate}

@@ -34,7 +51,7 @@ {if $language_state == 'inactive'} {'Activate'|@translate} - | {'Delete'|@translate} + | {'Delete'|@translate} {/if}
diff --git a/admin/themes/default/template/maintenance.tpl b/admin/themes/default/template/maintenance.tpl index 040653261..1331bb1c9 100644 --- a/admin/themes/default/template/maintenance.tpl +++ b/admin/themes/default/template/maintenance.tpl @@ -1,10 +1,61 @@ +{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} +{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'} +{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"} +{footer_script} +const confirm_msg = '{"Yes, I am sure"|@translate}'; +const cancel_msg = "{"No, I have changed my mind"|@translate}"; +$(".lock-gallery-button").each(function() { + const gallery_tip = '{"A locked gallery is only visible to administrators"|@translate|@escape:'javascript'}'; + let title = '{"Are you sure you want to lock the gallery?"|@translate}'; + let confirm_msg_gallery = '{"Yes, I want to lock the gallery"|@translate}'; + let cancel_msg_gallery = '{"Keep it unlocked"|@translate}'; + $(this).pwg_jconfirm_follow_href({ + alert_title: title, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg, + alert_content: gallery_tip + }); +}); +$(".purge-history-detail-button").each(function() { + const title = '{"Purge history detail"|@translate|@escape:'javascript'}'; + $(this).pwg_jconfirm_follow_href({ + alert_title: title, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); +$(".purge-history-summary-button").each(function() { + const title = '{"Purge history summary"|@translate|@escape:'javascript'}'; + $(this).pwg_jconfirm_follow_href({ + alert_title: title, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); +$(".purge-search-history-button").each(function() { + const title = '{"Purge search history"|@translate|@escape:'javascript'}'; + $(this).pwg_jconfirm_follow_href({ + alert_title: title, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); +$(".delete-all-sizes-button").each(function() { + const title = '{"Are you sure you want to delete all sizes?"|@translate|@escape:'javascript'}'; + $(this).pwg_jconfirm_follow_href({ + alert_title: title, + alert_confirm: confirm_msg, + alert_cancel: cancel_msg + }); +}); +{/footer_script}

{'Maintenance'|@translate}