From 9917fec7f6d49d784d86b75bff3aa876b951c6c2 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Wed, 3 Jan 2024 14:35:20 +0700 Subject: [PATCH 1/9] 43301 notification of unsaved changes --- dist/onoffice-unsaved-changes-warning.min.js | 1 + js/onoffice-unsaved-changes-warning.js | 54 +++++++++++++++++++ plugin/Controller/AdminViewController.php | 12 +++++ plugin/Gui/AdminPageAddressListSettings.php | 2 + plugin/Gui/AdminPageEstateDetail.php | 12 +++++ .../Gui/AdminPageEstateListSettingsBase.php | 2 + plugin/Gui/AdminPageFormSettingsBase.php | 2 + plugin/Gui/AdminPageSettingsBase.php | 10 ++++ plugin/Gui/AdminPageSimilarEstates.php | 12 +++++ 9 files changed, 107 insertions(+) create mode 100644 dist/onoffice-unsaved-changes-warning.min.js create mode 100644 js/onoffice-unsaved-changes-warning.js diff --git a/dist/onoffice-unsaved-changes-warning.min.js b/dist/onoffice-unsaved-changes-warning.min.js new file mode 100644 index 000000000..a4bb62e97 --- /dev/null +++ b/dist/onoffice-unsaved-changes-warning.min.js @@ -0,0 +1 @@ +var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_message_warnning;jQuery(document).ready((function($){let checkUnsavedChanges=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesWarning(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesWarning(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(e){return handleUnsavedChanges(e,window.location.href)};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/js/onoffice-unsaved-changes-warning.js b/js/onoffice-unsaved-changes-warning.js new file mode 100644 index 000000000..e87e04013 --- /dev/null +++ b/js/onoffice-unsaved-changes-warning.js @@ -0,0 +1,54 @@ +var onOffice = typeof onOffice_loc_settings !== 'undefined' ? onOffice_loc_settings : onOffice_message_warnning; + +jQuery(document).ready(function($){ + let checkUnsavedChanges = false; + + $('#poststuff :input, form[action="options.php"] :input').on("change", function() { + checkUnsavedChanges = true; + }); + + $('#poststuff span').on("click", function() { + checkUnsavedChanges = true; + }); + + function generateUnsavedChangesWarning(href) { + return $(` +
+

${onOffice.view_unsaved_changes_message} + ${onOffice.view_leave_without_saving_text}

+ +
+ `); + } + + function handleUnsavedChanges(e, href) { + if (checkUnsavedChanges) { + e.preventDefault(); + let appendUnsavedChangesHtml = generateUnsavedChangesWarning(href); + appendUnsavedChangesHtml.insertAfter('.wp-header-end'); + $('html, body').animate({ scrollTop: 0 }, 1000); + + return false; + } + } + + $('a[href]').on('click', function(e) { + handleUnsavedChanges(e, $(this).attr('href')); + }); + + window.onbeforeunload = function(e) { + return handleUnsavedChanges(e, window.location.href); + }; + + $('#onoffice-ajax').submit(function () { + checkUnsavedChanges = false; + }); + + $(document).on('click', '#leaveWithoutSaving, #submit', function(e) { + checkUnsavedChanges = false; + }); + + $(document).on('click', '.notice-save-view.notice-dismiss', function () { + $(this).parent().remove(); + }); +}); \ No newline at end of file diff --git a/plugin/Controller/AdminViewController.php b/plugin/Controller/AdminViewController.php index a779acbbc..74d26c7d8 100644 --- a/plugin/Controller/AdminViewController.php +++ b/plugin/Controller/AdminViewController.php @@ -93,6 +93,11 @@ class AdminViewController /** @var AdminPageFormSettingsMain */ private $_pAdminPageFormSettings = null; + /** */ + const VIEW_UNSAVED_CHANGES_MESSAGE = 'view_unsaved_changes_message'; + + /** */ + const VIEW_LEAVE_WITHOUT_SAVING_TEXT = 'view_leave_without_saving_text'; /** * @@ -333,6 +338,13 @@ public function enqueueExtraJs($hook) wp_localize_script('handle-notification-actions', 'duplicate_check_option_vars', ['ajaxurl' => admin_url('admin-ajax.php')]); wp_localize_script('handle-notification-actions', 'warning_active_plugin_vars', ['ajaxurl' => admin_url('admin-ajax.php')]); wp_enqueue_script('handle-notification-actions'); + wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'dist/onoffice-unsaved-changes-warning.min.js', + ['jquery'], '', true); + wp_enqueue_script('oo-unsaved-changes-warning'); + wp_localize_script('oo-unsaved-changes-warning', 'onOffice_message_warnning', [ + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites') + ]); if (__String::getNew($hook)->contains('onoffice')) { $pObject = $this->getObjectByHook($hook); diff --git a/plugin/Gui/AdminPageAddressListSettings.php b/plugin/Gui/AdminPageAddressListSettings.php index 3e3e9216a..6d029bba2 100644 --- a/plugin/Gui/AdminPageAddressListSettings.php +++ b/plugin/Gui/AdminPageAddressListSettings.php @@ -356,6 +356,8 @@ public function getEnqueueData(): array self::VIEW_SAVE_FAIL_MESSAGE => __('There was a problem saving the list. Please make sure the name of the list is unique.', 'onoffice-for-wp-websites'), self::ENQUEUE_DATA_MERGE => array(AdminPageSettingsBase::POST_RECORD_ID), AdminPageSettingsBase::POST_RECORD_ID => $this->getListViewId(), + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageEstateDetail.php b/plugin/Gui/AdminPageEstateDetail.php index 7f46184c1..af4217c49 100644 --- a/plugin/Gui/AdminPageEstateDetail.php +++ b/plugin/Gui/AdminPageEstateDetail.php @@ -101,6 +101,12 @@ class AdminPageEstateDetail /** */ const CUSTOM_LABELS = 'customlabels'; + /** */ + const VIEW_UNSAVED_CHANGES_MESSAGE = 'view_unsaved_changes_message'; + + /** */ + const VIEW_LEAVE_WITHOUT_SAVING_TEXT = 'view_leave_without_saving_text'; + /** * */ @@ -429,6 +435,10 @@ public function doExtraEnqueues() wp_register_style('onoffice-multiselect', plugins_url('/css/onoffice-multiselect.css', $pluginPath)); wp_enqueue_script('onoffice-multiselect'); wp_enqueue_style('onoffice-multiselect'); + + wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + ['jquery'], '', true); + wp_enqueue_script('oo-unsaved-changes-warning'); } /** @@ -459,6 +469,8 @@ public function getEnqueueData(): array self::ENQUEUE_DATA_MERGE => array(AdminPageEstate::PARAM_TAB), self::CUSTOM_LABELS => $this->readCustomLabels(), 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageEstateListSettingsBase.php b/plugin/Gui/AdminPageEstateListSettingsBase.php index ab72b7fe6..98c0b9746 100644 --- a/plugin/Gui/AdminPageEstateListSettingsBase.php +++ b/plugin/Gui/AdminPageEstateListSettingsBase.php @@ -187,6 +187,8 @@ public function getEnqueueData(): array self::CUSTOM_LABELS => $this->readCustomLabels(), 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), AdminPageSettingsBase::POST_RECORD_ID => $this->getListViewId(), + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageFormSettingsBase.php b/plugin/Gui/AdminPageFormSettingsBase.php index 7b18b6f04..16b45f793 100644 --- a/plugin/Gui/AdminPageFormSettingsBase.php +++ b/plugin/Gui/AdminPageFormSettingsBase.php @@ -327,6 +327,8 @@ public function getEnqueueData(): array 'fieldList' => $this->getFieldList(), 'installed_wp_languages' => $this->getInstalledLanguages(), 'language_native' => $pLanguage->getLocale(), + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), ]; } diff --git a/plugin/Gui/AdminPageSettingsBase.php b/plugin/Gui/AdminPageSettingsBase.php index 7d5b63766..4b9c232cd 100644 --- a/plugin/Gui/AdminPageSettingsBase.php +++ b/plugin/Gui/AdminPageSettingsBase.php @@ -84,6 +84,12 @@ abstract class AdminPageSettingsBase /** */ const VIEW_SAVE_FAIL_MESSAGE = 'view_save_fail_message'; + /** */ + const VIEW_UNSAVED_CHANGES_MESSAGE = 'view_unsaved_changes_message'; + + /** */ + const VIEW_LEAVE_WITHOUT_SAVING_TEXT = 'view_leave_without_saving_text'; + /** @var string */ private $_pageTitle = null; @@ -559,6 +565,10 @@ public function doExtraEnqueues() wp_register_script('oo-copy-shortcode', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-copycode.min.js', ['jquery'], '', true); + + wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + ['jquery'], '', true); + wp_enqueue_script('oo-unsaved-changes-warning'); } diff --git a/plugin/Gui/AdminPageSimilarEstates.php b/plugin/Gui/AdminPageSimilarEstates.php index 25b4e39b2..d1c3e2255 100644 --- a/plugin/Gui/AdminPageSimilarEstates.php +++ b/plugin/Gui/AdminPageSimilarEstates.php @@ -88,6 +88,12 @@ class AdminPageSimilarEstates /** */ const FORM_VIEW_PICTURE_TYPES = 'viewpicturetypes'; + /** */ + const VIEW_UNSAVED_CHANGES_MESSAGE = 'view_unsaved_changes_message'; + + /** */ + const VIEW_LEAVE_WITHOUT_SAVING_TEXT = 'view_leave_without_saving_text'; + /** * @throws DependencyException * @throws NotFoundException @@ -331,6 +337,10 @@ public function doExtraEnqueues() wp_register_style('onoffice-multiselect', plugins_url('/css/onoffice-multiselect.css', $pluginPath)); wp_enqueue_script('onoffice-multiselect'); wp_enqueue_style('onoffice-multiselect'); + + wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + ['jquery'], '', true); + wp_enqueue_script('oo-unsaved-changes-warning'); } /** @@ -361,6 +371,8 @@ public function getEnqueueData(): array self::ENQUEUE_DATA_MERGE => array(AdminPageEstate::PARAM_TAB), self::CUSTOM_LABELS => $this->readCustomLabels(), 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), + self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), ); } From c90b316d4cbb73668e46dbaba7c9718d655b0ef9 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Wed, 3 Jan 2024 16:56:38 +0700 Subject: [PATCH 2/9] 43301 refactor code --- dist/onoffice-unsaved-changes-message.min.js | 1 + dist/onoffice-unsaved-changes-warning.min.js | 1 - ...anges-warning.js => onoffice-unsaved-changes-message.js} | 6 +++--- plugin/Controller/AdminViewController.php | 6 +++--- plugin/Gui/AdminPageEstateDetail.php | 4 ++-- plugin/Gui/AdminPageSettingsBase.php | 4 ++-- plugin/Gui/AdminPageSimilarEstates.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 dist/onoffice-unsaved-changes-message.min.js delete mode 100644 dist/onoffice-unsaved-changes-warning.min.js rename js/{onoffice-unsaved-changes-warning.js => onoffice-unsaved-changes-message.js} (89%) diff --git a/dist/onoffice-unsaved-changes-message.min.js b/dist/onoffice-unsaved-changes-message.min.js new file mode 100644 index 000000000..efdc29e6b --- /dev/null +++ b/dist/onoffice-unsaved-changes-message.min.js @@ -0,0 +1 @@ +var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(e){return handleUnsavedChanges(e,window.location.href)};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/dist/onoffice-unsaved-changes-warning.min.js b/dist/onoffice-unsaved-changes-warning.min.js deleted file mode 100644 index a4bb62e97..000000000 --- a/dist/onoffice-unsaved-changes-warning.min.js +++ /dev/null @@ -1 +0,0 @@ -var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_message_warnning;jQuery(document).ready((function($){let checkUnsavedChanges=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesWarning(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesWarning(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(e){return handleUnsavedChanges(e,window.location.href)};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/js/onoffice-unsaved-changes-warning.js b/js/onoffice-unsaved-changes-message.js similarity index 89% rename from js/onoffice-unsaved-changes-warning.js rename to js/onoffice-unsaved-changes-message.js index e87e04013..19a2e91d1 100644 --- a/js/onoffice-unsaved-changes-warning.js +++ b/js/onoffice-unsaved-changes-message.js @@ -1,4 +1,4 @@ -var onOffice = typeof onOffice_loc_settings !== 'undefined' ? onOffice_loc_settings : onOffice_message_warnning; +var onOffice = typeof onOffice_loc_settings !== 'undefined' ? onOffice_loc_settings : onOffice_unsaved_changes_message; jQuery(document).ready(function($){ let checkUnsavedChanges = false; @@ -11,7 +11,7 @@ jQuery(document).ready(function($){ checkUnsavedChanges = true; }); - function generateUnsavedChangesWarning(href) { + function generateUnsavedChangesMessage(href) { return $(`

${onOffice.view_unsaved_changes_message} @@ -24,7 +24,7 @@ jQuery(document).ready(function($){ function handleUnsavedChanges(e, href) { if (checkUnsavedChanges) { e.preventDefault(); - let appendUnsavedChangesHtml = generateUnsavedChangesWarning(href); + let appendUnsavedChangesHtml = generateUnsavedChangesMessage(href); appendUnsavedChangesHtml.insertAfter('.wp-header-end'); $('html, body').animate({ scrollTop: 0 }, 1000); diff --git a/plugin/Controller/AdminViewController.php b/plugin/Controller/AdminViewController.php index 74d26c7d8..c31831895 100644 --- a/plugin/Controller/AdminViewController.php +++ b/plugin/Controller/AdminViewController.php @@ -338,10 +338,10 @@ public function enqueueExtraJs($hook) wp_localize_script('handle-notification-actions', 'duplicate_check_option_vars', ['ajaxurl' => admin_url('admin-ajax.php')]); wp_localize_script('handle-notification-actions', 'warning_active_plugin_vars', ['ajaxurl' => admin_url('admin-ajax.php')]); wp_enqueue_script('handle-notification-actions'); - wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'dist/onoffice-unsaved-changes-warning.min.js', + wp_register_script('oo-unsaved-changes-message', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'dist/onoffice-unsaved-changes-message.min.js', ['jquery'], '', true); - wp_enqueue_script('oo-unsaved-changes-warning'); - wp_localize_script('oo-unsaved-changes-warning', 'onOffice_message_warnning', [ + wp_enqueue_script('oo-unsaved-changes-message'); + wp_localize_script('oo-unsaved-changes-message', 'onOffice_unsaved_changes_message', [ self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites') ]); diff --git a/plugin/Gui/AdminPageEstateDetail.php b/plugin/Gui/AdminPageEstateDetail.php index af4217c49..1f44e05ea 100644 --- a/plugin/Gui/AdminPageEstateDetail.php +++ b/plugin/Gui/AdminPageEstateDetail.php @@ -436,9 +436,9 @@ public function doExtraEnqueues() wp_enqueue_script('onoffice-multiselect'); wp_enqueue_style('onoffice-multiselect'); - wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + wp_register_script('oo-unsaved-changes-message', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-message.min.js', ['jquery'], '', true); - wp_enqueue_script('oo-unsaved-changes-warning'); + wp_enqueue_script('oo-unsaved-changes-message'); } /** diff --git a/plugin/Gui/AdminPageSettingsBase.php b/plugin/Gui/AdminPageSettingsBase.php index 4b9c232cd..fbe474311 100644 --- a/plugin/Gui/AdminPageSettingsBase.php +++ b/plugin/Gui/AdminPageSettingsBase.php @@ -566,9 +566,9 @@ public function doExtraEnqueues() plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-copycode.min.js', ['jquery'], '', true); - wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + wp_register_script('oo-unsaved-changes-message', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-message.min.js', ['jquery'], '', true); - wp_enqueue_script('oo-unsaved-changes-warning'); + wp_enqueue_script('oo-unsaved-changes-message'); } diff --git a/plugin/Gui/AdminPageSimilarEstates.php b/plugin/Gui/AdminPageSimilarEstates.php index d1c3e2255..bf1f027b7 100644 --- a/plugin/Gui/AdminPageSimilarEstates.php +++ b/plugin/Gui/AdminPageSimilarEstates.php @@ -338,9 +338,9 @@ public function doExtraEnqueues() wp_enqueue_script('onoffice-multiselect'); wp_enqueue_style('onoffice-multiselect'); - wp_register_script('oo-unsaved-changes-warning', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-warning.min.js', + wp_register_script('oo-unsaved-changes-message', plugin_dir_url(ONOFFICE_PLUGIN_DIR.'/index.php').'/dist/onoffice-unsaved-changes-message.min.js', ['jquery'], '', true); - wp_enqueue_script('oo-unsaved-changes-warning'); + wp_enqueue_script('oo-unsaved-changes-message'); } /** From 209bf08fa41f370e60279a56957f8be3af9b280a Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Thu, 4 Jan 2024 17:25:45 +0700 Subject: [PATCH 3/9] 43301 update unit test --- tests/TestClassAdminViewController.php | 4 ++-- tests/TestClassFormPostOwner.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/TestClassAdminViewController.php b/tests/TestClassAdminViewController.php index 942cb7b4a..4ef430bed 100644 --- a/tests/TestClassAdminViewController.php +++ b/tests/TestClassAdminViewController.php @@ -173,7 +173,7 @@ public function testEnqueueExtraJs(AdminViewController $pAdminViewController) $adminPage = new AdminPageEstateDetail('admin_page_onoffice-editlistview'); $pWpHook->callbacks = [[['function' => [$adminPage]]]]; $pAdminViewController->enqueueExtraJs("admin_page_onoffice-editlistview"); - $this->assertEquals(['handle-notification-actions', 'admin-js', 'oo-copy-shortcode','onoffice-custom-form-label-js','onoffice-multiselect'], wp_scripts()->queue); + $this->assertEquals(['handle-notification-actions', 'oo-unsaved-changes-message', 'admin-js', 'oo-copy-shortcode','onoffice-custom-form-label-js','onoffice-multiselect'], wp_scripts()->queue); } /** @@ -191,7 +191,7 @@ public function testEnqueueExtraJsWithNullHook(AdminViewController $pAdminViewCo $pWpHook = $wp_filter['admin_page_onoffice-editlistview']; $pWpHook->callbacks = [[['function' => ['a']]]]; $pAdminViewController->enqueueExtraJs("admin_onoffice_test"); - $this->assertCount(1, wp_scripts()->queue); + $this->assertCount(2, wp_scripts()->queue); } public function testAdminPageAjax() diff --git a/tests/TestClassFormPostOwner.php b/tests/TestClassFormPostOwner.php index a30269ab5..9d1e3d051 100644 --- a/tests/TestClassFormPostOwner.php +++ b/tests/TestClassFormPostOwner.php @@ -117,24 +117,29 @@ public function prepare() $FieldObjektart = new Field('objektart', onOfficeSDK::MODULE_ESTATE); $FieldObjektart->setPermittedvalues(['haus' => 'Haus', 'wohnung' => 'Wohnung']); $FieldObjektart->setType(FieldTypes::FIELD_TYPE_SINGLESELECT); + $FieldObjektart->setLabel('Objektart'); $pFieldsCollection->addField($FieldObjektart); $FieldObjekttyp = new Field('objekttyp', onOfficeSDK::MODULE_ESTATE); $FieldObjekttyp->setPermittedvalues(['stadthaus' => 'Stadthaus', 'reihenhaus' => 'Reihenhaus']); $FieldObjekttyp->setType(FieldTypes::FIELD_TYPE_SINGLESELECT); + $FieldObjekttyp->setLabel('Objekttyp'); $pFieldsCollection->addField($FieldObjekttyp); $pFieldEnergieausweistyp = new Field('energieausweistyp', onOfficeSDK::MODULE_ESTATE); $pFieldEnergieausweistyp->setType(FieldTypes::FIELD_TYPE_SINGLESELECT); + $pFieldEnergieausweistyp->setLabel('Energieausweistyp'); $pFieldEnergieausweistyp->setPermittedvalues(['Bedarfsausweis' => 'Bedarfsausweis']); $pFieldsCollection->addField($pFieldEnergieausweistyp); $pFieldWohnfl = new Field('wohnflaeche', onOfficeSDK::MODULE_ESTATE); $pFieldWohnfl->setType(FieldTypes::FIELD_TYPE_FLOAT); + $pFieldWohnfl->setLabel('Wohnflaeche'); $pFieldsCollection->addField($pFieldWohnfl); $pFieldKabelSatTv = new Field('kabel_sat_tv', onOfficeSDK::MODULE_ESTATE); $pFieldKabelSatTv->setType(FieldTypes::FIELD_TYPE_BOOLEAN); + $pFieldKabelSatTv->setLabel('Kabel_sat_tv'); $pFieldsCollection->addField($pFieldKabelSatTv); $pFieldGDPRCheckBox = new Field('gdprcheckbox', onOfficeSDK::MODULE_ADDRESS); @@ -143,6 +148,7 @@ public function prepare() $pFieldBad = new Field('bad', onOfficeSDK::MODULE_ESTATE); $pFieldBad->setType(FieldTypes::FIELD_TYPE_MULTISELECT); + $pFieldBad->setLabel('Bad'); $pFieldsCollection->addField($pFieldBad); return $this->_pFieldsCollectionBuilderShort; @@ -711,7 +717,7 @@ private function prepareMockerForContactSuccessUsingArrayInputEstate() . 'Objekttyp: Stadthaus' . "\n" . 'Energieausweistyp: Bedarfsausweis' . "\n" . 'Wohnflaeche: 800' . "\n" - . 'Kabel_sat_tv: 1' . "\n" + . 'Kabel_sat_tv: Yes' . "\n" . 'Bad: Bidet, Urinal, Bathtub', 'estatedata' => ['objektart', 'objekttyp', 'energieausweistyp', 'wohnflaeche', 'kabel_sat_tv', 'bad'], 'recipient' => 'test@my-onoffice.com' @@ -746,4 +752,4 @@ private function prepareMockerForContactSuccessUsingArrayInputEstate() $this->_pSDKWrapperMocker->addResponseByParameters(onOfficeSDK::ACTION_ID_DO, 'contactaddress', '', $parameters, null, $response); } -} +} \ No newline at end of file From cfd8f76a9704cef32161630aabbcd95e08636b12 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Tue, 23 Apr 2024 14:08:28 +0700 Subject: [PATCH 4/9] 43301 update unit test --- tests/TestClassAdminViewController.php | 2 +- tests/TestClassFormPostOwner.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestClassAdminViewController.php b/tests/TestClassAdminViewController.php index fae95f308..899e7a614 100644 --- a/tests/TestClassAdminViewController.php +++ b/tests/TestClassAdminViewController.php @@ -352,6 +352,6 @@ public function testEnqueueExtraJsWithHandleRecaptcha(AdminViewController $pAdmi $adminPage = new AdminPageApiSettings('admin_page_onoffice-settings'); $pWpHook->callbacks = [[['function' => [$adminPage]]]]; $pAdminViewController->enqueueExtraJs("admin_page_onoffice-settings"); - $this->assertEquals(['handle-notification-actions', 'handle-visibility-google-recaptcha-keys'], wp_scripts()->queue); + $this->assertEquals(['handle-notification-actions', 'oo-unsaved-changes-message', 'handle-visibility-google-recaptcha-keys'], wp_scripts()->queue); } } diff --git a/tests/TestClassFormPostOwner.php b/tests/TestClassFormPostOwner.php index c06693eb4..0a1579421 100644 --- a/tests/TestClassFormPostOwner.php +++ b/tests/TestClassFormPostOwner.php @@ -753,4 +753,4 @@ private function prepareMockerForContactSuccessUsingArrayInputEstate() $this->_pSDKWrapperMocker->addResponseByParameters(onOfficeSDK::ACTION_ID_DO, 'contactaddress', '', $parameters, null, $response); } -} \ No newline at end of file +} From cc4016c6ff50bea7088abecff7ee7ef8d4bdc252 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Mon, 6 May 2024 15:18:03 +0700 Subject: [PATCH 5/9] 43301 notification of unsaved changes --- dist/onoffice-unsaved-changes-message.min.js | 2 +- js/onoffice-unsaved-changes-message.js | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dist/onoffice-unsaved-changes-message.min.js b/dist/onoffice-unsaved-changes-message.min.js index efdc29e6b..fc7b2d0e3 100644 --- a/dist/onoffice-unsaved-changes-message.min.js +++ b/dist/onoffice-unsaved-changes-message.min.js @@ -1 +1 @@ -var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesMessage(href){return $(`\n\t\t\t

\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(e){return handleUnsavedChanges(e,window.location.href)};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file +var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;let checkNavigationTriggered=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){$(".notice-unsaved-changes-message").remove();e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){if(!$(this).closest("#adminmenu").length){checkNavigationTriggered=true}}));$("#adminmenu a[href]").on("click",(function(e){if($(this).attr("target")==="_blank"){return}handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(){if(checkUnsavedChanges&&!checkNavigationTriggered){return onOffice.view_unsaved_changes_message}};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/js/onoffice-unsaved-changes-message.js b/js/onoffice-unsaved-changes-message.js index 19a2e91d1..e40674cfd 100644 --- a/js/onoffice-unsaved-changes-message.js +++ b/js/onoffice-unsaved-changes-message.js @@ -2,6 +2,7 @@ var onOffice = typeof onOffice_loc_settings !== 'undefined' ? onOffice_loc_setti jQuery(document).ready(function($){ let checkUnsavedChanges = false; + let checkNavigationTriggered = false; $('#poststuff :input, form[action="options.php"] :input').on("change", function() { checkUnsavedChanges = true; @@ -13,7 +14,7 @@ jQuery(document).ready(function($){ function generateUnsavedChangesMessage(href) { return $(` -
+

${onOffice.view_unsaved_changes_message} ${onOffice.view_leave_without_saving_text}

@@ -23,6 +24,7 @@ jQuery(document).ready(function($){ function handleUnsavedChanges(e, href) { if (checkUnsavedChanges) { + $('.notice-unsaved-changes-message').remove(); e.preventDefault(); let appendUnsavedChangesHtml = generateUnsavedChangesMessage(href); appendUnsavedChangesHtml.insertAfter('.wp-header-end'); @@ -33,11 +35,22 @@ jQuery(document).ready(function($){ } $('a[href]').on('click', function(e) { + if (!$(this).closest('#adminmenu').length) { + checkNavigationTriggered = true; + } + }); + + $('#adminmenu a[href]').on('click', function(e) { + if ($(this).attr('target') === '_blank') { + return; + } handleUnsavedChanges(e, $(this).attr('href')); }); - window.onbeforeunload = function(e) { - return handleUnsavedChanges(e, window.location.href); + window.onbeforeunload = function() { + if (checkUnsavedChanges && !checkNavigationTriggered) { + return onOffice.view_unsaved_changes_message; + } }; $('#onoffice-ajax').submit(function () { From a3536baa7a602aa7b8832eb6a0d20b9f8ad8e6fc Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Mon, 6 May 2024 15:57:20 +0700 Subject: [PATCH 6/9] 43301 add change detection for sortable list items --- dist/onoffice-unsaved-changes-message.min.js | 2 +- js/onoffice-unsaved-changes-message.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/onoffice-unsaved-changes-message.min.js b/dist/onoffice-unsaved-changes-message.min.js index fc7b2d0e3..aa3a69ac8 100644 --- a/dist/onoffice-unsaved-changes-message.min.js +++ b/dist/onoffice-unsaved-changes-message.min.js @@ -1 +1 @@ -var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;let checkNavigationTriggered=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span").on("click",(function(){checkUnsavedChanges=true}));function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){$(".notice-unsaved-changes-message").remove();e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){if(!$(this).closest("#adminmenu").length){checkNavigationTriggered=true}}));$("#adminmenu a[href]").on("click",(function(e){if($(this).attr("target")==="_blank"){return}handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(){if(checkUnsavedChanges&&!checkNavigationTriggered){return onOffice.view_unsaved_changes_message}};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file +var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;let checkNavigationTriggered=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span, #poststuff li").on("click",(function(){checkUnsavedChanges=true}));$(".filter-fields-list").sortable({update:function(){checkUnsavedChanges=true}});function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){$(".notice-unsaved-changes-message").remove();e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){if(!$(this).closest("#adminmenu").length){checkNavigationTriggered=true}}));$("#adminmenu a[href]").on("click",(function(e){if($(this).attr("target")==="_blank"){return}handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(){if(checkUnsavedChanges&&!checkNavigationTriggered){return onOffice.view_unsaved_changes_message}};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/js/onoffice-unsaved-changes-message.js b/js/onoffice-unsaved-changes-message.js index e40674cfd..78b47b4b1 100644 --- a/js/onoffice-unsaved-changes-message.js +++ b/js/onoffice-unsaved-changes-message.js @@ -8,10 +8,16 @@ jQuery(document).ready(function($){ checkUnsavedChanges = true; }); - $('#poststuff span').on("click", function() { + $('#poststuff span, #poststuff li').on("click", function() { checkUnsavedChanges = true; }); + $('.filter-fields-list').sortable({ + update: function() { + checkUnsavedChanges = true; + } + }); + function generateUnsavedChangesMessage(href) { return $(`
From 22a13c54d0d95338d8aa1f285052e6d6744a7844 Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Mon, 6 May 2024 17:23:17 +0700 Subject: [PATCH 7/9] 43301 format code --- js/onoffice-unsaved-changes-message.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/onoffice-unsaved-changes-message.js b/js/onoffice-unsaved-changes-message.js index 78b47b4b1..903994172 100644 --- a/js/onoffice-unsaved-changes-message.js +++ b/js/onoffice-unsaved-changes-message.js @@ -12,11 +12,11 @@ jQuery(document).ready(function($){ checkUnsavedChanges = true; }); - $('.filter-fields-list').sortable({ - update: function() { - checkUnsavedChanges = true; - } - }); + $('.filter-fields-list').sortable({ + update: function() { + checkUnsavedChanges = true; + } + }); function generateUnsavedChangesMessage(href) { return $(` From 91906dbaaa5d624d19c1baf8800dcbec25d0f71b Mon Sep 17 00:00:00 2001 From: "dai.trinh" Date: Tue, 7 May 2024 14:24:33 +0700 Subject: [PATCH 8/9] 43301 update notification of unsaved changes when using the admin-bar --- dist/onoffice-unsaved-changes-message.min.js | 2 +- js/onoffice-unsaved-changes-message.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/onoffice-unsaved-changes-message.min.js b/dist/onoffice-unsaved-changes-message.min.js index aa3a69ac8..ba27c28b0 100644 --- a/dist/onoffice-unsaved-changes-message.min.js +++ b/dist/onoffice-unsaved-changes-message.min.js @@ -1 +1 @@ -var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;let checkNavigationTriggered=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span, #poststuff li").on("click",(function(){checkUnsavedChanges=true}));$(".filter-fields-list").sortable({update:function(){checkUnsavedChanges=true}});function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){$(".notice-unsaved-changes-message").remove();e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){if(!$(this).closest("#adminmenu").length){checkNavigationTriggered=true}}));$("#adminmenu a[href]").on("click",(function(e){if($(this).attr("target")==="_blank"){return}handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(){if(checkUnsavedChanges&&!checkNavigationTriggered){return onOffice.view_unsaved_changes_message}};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file +var onOffice=typeof onOffice_loc_settings!=="undefined"?onOffice_loc_settings:onOffice_unsaved_changes_message;jQuery(document).ready((function($){let checkUnsavedChanges=false;let checkNavigationTriggered=false;$('#poststuff :input, form[action="options.php"] :input').on("change",(function(){checkUnsavedChanges=true}));$("#poststuff span, #poststuff li").on("click",(function(){checkUnsavedChanges=true}));$(".filter-fields-list").sortable({update:function(){checkUnsavedChanges=true}});function generateUnsavedChangesMessage(href){return $(`\n\t\t\t
\n\t\t\t\t

${onOffice.view_unsaved_changes_message} \n\t\t\t\t${onOffice.view_leave_without_saving_text}

\n\t\t\t\t\n\t\t\t
\n\t\t`)}function handleUnsavedChanges(e,href){if(checkUnsavedChanges){$(".notice-unsaved-changes-message").remove();e.preventDefault();let appendUnsavedChangesHtml=generateUnsavedChangesMessage(href);appendUnsavedChangesHtml.insertAfter(".wp-header-end");$("html, body").animate({scrollTop:0},1e3);return false}}$("a[href]").on("click",(function(e){if(!$(this).closest("#adminmenu, #wpadminbar").length){checkNavigationTriggered=true}}));$("#adminmenu a[href], #wpadminbar a[href]").on("click",(function(e){if($(this).attr("target")==="_blank"){return}handleUnsavedChanges(e,$(this).attr("href"))}));window.onbeforeunload=function(){if(checkUnsavedChanges&&!checkNavigationTriggered){return onOffice.view_unsaved_changes_message}};$("#onoffice-ajax").submit((function(){checkUnsavedChanges=false}));$(document).on("click","#leaveWithoutSaving, #submit",(function(e){checkUnsavedChanges=false}));$(document).on("click",".notice-save-view.notice-dismiss",(function(){$(this).parent().remove()}))})); \ No newline at end of file diff --git a/js/onoffice-unsaved-changes-message.js b/js/onoffice-unsaved-changes-message.js index 903994172..19eed05a1 100644 --- a/js/onoffice-unsaved-changes-message.js +++ b/js/onoffice-unsaved-changes-message.js @@ -41,12 +41,12 @@ jQuery(document).ready(function($){ } $('a[href]').on('click', function(e) { - if (!$(this).closest('#adminmenu').length) { + if (!$(this).closest('#adminmenu, #wpadminbar').length) { checkNavigationTriggered = true; } }); - $('#adminmenu a[href]').on('click', function(e) { + $('#adminmenu a[href], #wpadminbar a[href]').on('click', function(e) { if ($(this).attr('target') === '_blank') { return; } From 9945b7838e8de6a8e980879d0753c7c7929a8a73 Mon Sep 17 00:00:00 2001 From: andernath Date: Wed, 8 May 2024 06:46:00 +0200 Subject: [PATCH 9/9] Fix typo --- plugin/Controller/AdminViewController.php | 2 +- plugin/Gui/AdminPageAddressListSettings.php | 2 +- plugin/Gui/AdminPageEstateDetail.php | 2 +- plugin/Gui/AdminPageEstateListSettingsBase.php | 2 +- plugin/Gui/AdminPageFormSettingsBase.php | 2 +- plugin/Gui/AdminPageSimilarEstates.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/Controller/AdminViewController.php b/plugin/Controller/AdminViewController.php index bdee31e34..4c1de1a52 100644 --- a/plugin/Controller/AdminViewController.php +++ b/plugin/Controller/AdminViewController.php @@ -346,7 +346,7 @@ public function enqueueExtraJs($hook) wp_enqueue_script('oo-unsaved-changes-message'); wp_localize_script('oo-unsaved-changes-message', 'onOffice_unsaved_changes_message', [ self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites') + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites') ]); if (__String::getNew($hook)->contains($this->_pageSlug.'-settings')) { diff --git a/plugin/Gui/AdminPageAddressListSettings.php b/plugin/Gui/AdminPageAddressListSettings.php index b1e1e71db..1e9952dd8 100644 --- a/plugin/Gui/AdminPageAddressListSettings.php +++ b/plugin/Gui/AdminPageAddressListSettings.php @@ -358,7 +358,7 @@ public function getEnqueueData(): array self::ENQUEUE_DATA_MERGE => array(AdminPageSettingsBase::POST_RECORD_ID), AdminPageSettingsBase::POST_RECORD_ID => $this->getListViewId(), self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageEstateDetail.php b/plugin/Gui/AdminPageEstateDetail.php index 8b5d74486..0d1596fac 100644 --- a/plugin/Gui/AdminPageEstateDetail.php +++ b/plugin/Gui/AdminPageEstateDetail.php @@ -478,7 +478,7 @@ public function getEnqueueData(): array self::CUSTOM_LABELS => $this->readCustomLabels(), 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageEstateListSettingsBase.php b/plugin/Gui/AdminPageEstateListSettingsBase.php index 496cf4fa4..a57103c7d 100644 --- a/plugin/Gui/AdminPageEstateListSettingsBase.php +++ b/plugin/Gui/AdminPageEstateListSettingsBase.php @@ -188,7 +188,7 @@ public function getEnqueueData(): array 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), AdminPageSettingsBase::POST_RECORD_ID => $this->getListViewId(), self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites'), ); } diff --git a/plugin/Gui/AdminPageFormSettingsBase.php b/plugin/Gui/AdminPageFormSettingsBase.php index 30f59337d..05a73676a 100644 --- a/plugin/Gui/AdminPageFormSettingsBase.php +++ b/plugin/Gui/AdminPageFormSettingsBase.php @@ -328,7 +328,7 @@ public function getEnqueueData(): array 'installed_wp_languages' => $this->getInstalledLanguages(), 'language_native' => $pLanguage->getLocale(), self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites'), ]; } diff --git a/plugin/Gui/AdminPageSimilarEstates.php b/plugin/Gui/AdminPageSimilarEstates.php index b3df3ac4f..801f019a5 100644 --- a/plugin/Gui/AdminPageSimilarEstates.php +++ b/plugin/Gui/AdminPageSimilarEstates.php @@ -378,7 +378,7 @@ public function getEnqueueData(): array self::CUSTOM_LABELS => $this->readCustomLabels(), 'label_custom_label' => __('Custom Label: %s', 'onoffice-for-wp-websites'), self::VIEW_UNSAVED_CHANGES_MESSAGE => __('Your changes have not been saved yet! Do you want to leave the page without saving?', 'onoffice-for-wp-websites'), - self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('leave without saving', 'onoffice-for-wp-websites'), + self::VIEW_LEAVE_WITHOUT_SAVING_TEXT => __('Leave without saving', 'onoffice-for-wp-websites'), ); }