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'); + + $('', { + 'id': 'delete-reason', + 'class': 'form-control' + }) + .appendTo($formGroup); } else { // Do not display confirmation promt. - var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable'; - var postData = { + var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable'; + var data = { csrfToken: GlobalVariables.csrfToken, unavailable_id : lastFocusedEventData.id }; - $.post(postUrl, postData, function(response) { + $.post(url, data, function(response) { $('#message_box').dialog('close'); if (response.exceptions) { diff --git a/src/assets/js/frontend_book.js b/src/assets/js/frontend_book.js index dcbdc5e0..2b2634d2 100644 --- a/src/assets/js/frontend_book.js +++ b/src/assets/js/frontend_book.js @@ -279,22 +279,28 @@ window.FrontendBook = window.FrontendBook || {}; * @param {jQuery.Event} event */ $('#cancel-appointment').click(function(event) { - var dialogButtons = {}; - dialogButtons['OK'] = function() { - if ($('#cancel-reason').val() === '') { - $('#cancel-reason').css('border', '2px solid red'); - return; + var buttons = [ + { + text: 'OK', + click: function() { + if ($('#cancel-reason').val() === '') { + $('#cancel-reason').css('border', '2px solid red'); + return; + } + $('#cancel-appointment-form textarea').val($('#cancel-reason').val()); + $('#cancel-appointment-form').submit(); + } + }, + { + text: EALang.cancel, + click: function() { + $('#message_box').dialog('close'); + } } - $('#cancel-appointment-form textarea').val($('#cancel-reason').val()); - $('#cancel-appointment-form').submit(); - }; - - dialogButtons[EALang.cancel] = function() { - $('#message_box').dialog('close'); - }; + ]; GeneralFunctions.displayMessageBox(EALang.cancel_appointment_title, - EALang.write_appointment_removal_reason, dialogButtons); + EALang.write_appointment_removal_reason, buttons); $('#message_box').append(''); $('#cancel-reason').css('width', '100%');