From f166feb32f7bef4863805a15b089c8995ba309b0 Mon Sep 17 00:00:00 2001 From: alext Date: Sat, 23 Sep 2017 03:49:46 +0200 Subject: [PATCH] Avoid translation conflicts by setting the interal text value of message dialog butons. --- .../js/backend_calendar_default_view.js | 6 +- src/assets/js/backend_calendar_table_view.js | 87 +++++++++++-------- src/assets/js/frontend_book.js | 32 ++++--- 3 files changed, 73 insertions(+), 52 deletions(-) diff --git a/src/assets/js/backend_calendar_default_view.js b/src/assets/js/backend_calendar_default_view.js index 77985f13..999a3ff3 100644 --- a/src/assets/js/backend_calendar_default_view.js +++ b/src/assets/js/backend_calendar_default_view.js @@ -459,13 +459,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; .add({ minutes: -minuteDelta }) .toString('yyyy-MM-dd HH:mm:ss'); - var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable'; - var postData = { + var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable'; + var data = { csrfToken: GlobalVariables.csrfToken, unavailable: JSON.stringify(unavailable) }; - $.post(postUrl, postData, function(response) { + $.post(url, data, function(response) { $('#notification').hide('blind'); revertFunc(); }, 'json').fail(GeneralFunctions.ajaxFailureHandler); diff --git a/src/assets/js/backend_calendar_table_view.js b/src/assets/js/backend_calendar_table_view.js index 1d611ca3..166b7415 100644 --- a/src/assets/js/backend_calendar_table_view.js +++ b/src/assets/js/backend_calendar_table_view.js @@ -318,56 +318,71 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {}; $(this).parents().eq(2).popover('destroy'); // Hide the popover if (lastFocusedEventData.is_unavailable == false) { - var messageButtons = {}; - messageButtons['OK'] = function() { - var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment'; - var postData = { - csrfToken: GlobalVariables.csrfToken, - appointment_id : lastFocusedEventData['id'], - delete_reason: $('#delete-reason').val() - }; + var buttons = [ + { + text: 'OK', + click: function() { + var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment'; + var postData = { + csrfToken: GlobalVariables.csrfToken, + appointment_id : lastFocusedEventData['id'], + delete_reason: $('#delete-reason').val() + }; - $.post(postUrl, postData, function(response) { - $('#message_box').dialog('close'); + $.post(postUrl, postData, function(response) { + $('#message_box').dialog('close'); - if (response.exceptions) { - response.exceptions = GeneralFunctions.parseExceptions(response.exceptions); - GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, - GeneralFunctions.EXCEPTIONS_MESSAGE); - $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions)); - return; + if (response.exceptions) { + response.exceptions = GeneralFunctions.parseExceptions(response.exceptions); + GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, + GeneralFunctions.EXCEPTIONS_MESSAGE); + $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions)); + return; + } + + if (response.warnings) { + response.warnings = GeneralFunctions.parseExceptions(response.warnings); + GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE, + GeneralFunctions.WARNINGS_MESSAGE); + $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings)); + } + + // Refresh calendar event items. + $('#select-filter-item').trigger('change'); + }, 'json').fail(GeneralFunctions.ajaxFailureHandler); } + }, - if (response.warnings) { - response.warnings = GeneralFunctions.parseExceptions(response.warnings); - GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE, - GeneralFunctions.WARNINGS_MESSAGE); - $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings)); + { + text: EALang.cancel, + click: function() { + $('#message_box').dialog('close'); } - - // Refresh calendar event items. - $('#select-filter-item').trigger('change'); - }, 'json').fail(GeneralFunctions.ajaxFailureHandler); - }; - - messageButtons[EALang.cancel] = function() { - $('#message_box').dialog('close'); - }; + } + ]; GeneralFunctions.displayMessageBox(EALang.delete_appointment_title, - EALang.write_appointment_removal_reason, messageButtons); + EALang.write_appointment_removal_reason, buttons); - $('#message_box').append(''); - $('#delete-reason').css('width', '100%'); + var $formGroup = $('
', { + 'class': 'form-group' + }) + .appendTo('#message_box'); + + $(''); $('#cancel-reason').css('width', '100%');