Replace the global App.Lang with the "lang" helper method, which is more appropriate due to the dynamic load of script translation strings.

This commit is contained in:
Alex Tselegidis 2022-01-18 08:22:25 +01:00
parent e93565500d
commit 8dad2d9624
28 changed files with 663 additions and 655 deletions

View file

@ -4,6 +4,16 @@
*/ */
?> ?>
<script <?= $attributes ?>> <script <?= $attributes ?>>
window.App.Lang = <?= json_encode($this->lang->language) ?> window.lang = (function () {
const lang = <?= json_encode($this->lang->language) ?>;
return (key) => {
if (!key) {
return lang;
}
return lang[key] || undefined;
};
})();
</script> </script>

View file

@ -1,7 +1,6 @@
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler * Easy!Appointments - Open Source Web Scheduler
* *
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com> * @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis * @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3 * @license https://opensource.org/licenses/GPL-3.0 - GPLv3
@ -18,7 +17,6 @@ window.App = (function () {
return { return {
Components: {}, Components: {},
Http: {}, Http: {},
Lang: {},
Layouts: {}, Layouts: {},
Pages: {}, Pages: {},
Utils: {} Utils: {}

View file

@ -113,7 +113,7 @@ App.Components.AppointmentsModal = (function () {
// Define success callback. // Define success callback.
const successCallback = () => { const successCallback = () => {
// Display success message to the user. // Display success message to the user.
App.Layouts.Backend.displayNotification(App.Lang.appointment_saved); App.Layouts.Backend.displayNotification(lang('appointment_saved'));
// Close the modal dialog and refresh the calendar appointments. // Close the modal dialog and refresh the calendar appointments.
$appointmentsModal.find('.alert').addClass('d-none'); $appointmentsModal.find('.alert').addClass('d-none');
@ -123,7 +123,7 @@ App.Components.AppointmentsModal = (function () {
// Define error callback. // Define error callback.
const errorCallback = () => { const errorCallback = () => {
$appointmentsModal.find('.modal-message').text(App.Lang.service_communication_error); $appointmentsModal.find('.modal-message').text(lang('service_communication_error'));
$appointmentsModal.find('.modal-message').addClass('alert-danger').removeClass('d-none'); $appointmentsModal.find('.modal-message').addClass('alert-danger').removeClass('d-none');
$appointmentsModal.find('.modal-body').scrollTop(0); $appointmentsModal.find('.modal-body').scrollTop(0);
}; };
@ -197,7 +197,7 @@ App.Components.AppointmentsModal = (function () {
); );
// Display modal form. // Display modal form.
$appointmentsModal.find('.modal-header h3').text(App.Lang.new_appointment_title); $appointmentsModal.find('.modal-header h3').text(lang('new_appointment_title'));
$appointmentsModal.modal('show'); $appointmentsModal.modal('show');
}); });
@ -209,7 +209,7 @@ App.Components.AppointmentsModal = (function () {
*/ */
$selectCustomer.on('click', (event) => { $selectCustomer.on('click', (event) => {
if (!$existingCustomersList.is(':visible')) { if (!$existingCustomersList.is(':visible')) {
$(event.target).find('span').text(App.Lang.hide); $(event.target).find('span').text(lang('hide'));
$existingCustomersList.empty(); $existingCustomersList.empty();
$existingCustomersList.slideDown('slow'); $existingCustomersList.slideDown('slow');
$filterExistingCustomers.fadeIn('slow').val(''); $filterExistingCustomers.fadeIn('slow').val('');
@ -222,7 +222,7 @@ App.Components.AppointmentsModal = (function () {
} else { } else {
$existingCustomersList.slideUp('slow'); $existingCustomersList.slideUp('slow');
$filterExistingCustomers.fadeOut('slow'); $filterExistingCustomers.fadeOut('slow');
$(event.target).find('span').text(App.Lang.select); $(event.target).find('span').text(lang('select'));
} }
}); });
@ -420,7 +420,7 @@ App.Components.AppointmentsModal = (function () {
// Close existing customers-filter frame. // Close existing customers-filter frame.
$existingCustomersList.slideUp('slow'); $existingCustomersList.slideUp('slow');
$filterExistingCustomers.fadeOut('slow'); $filterExistingCustomers.fadeOut('slow');
$selectCustomer.find('span').text(App.Lang.select); $selectCustomer.find('span').text(lang('select'));
// Setup start and datetimepickers. // Setup start and datetimepickers.
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime. // Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
@ -458,54 +458,54 @@ App.Components.AppointmentsModal = (function () {
// Translation // Translation
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes, minuteText: lang('minutes'),
firstDay: firstWeekDayNumber, firstDay: firstWeekDayNumber,
onClose: function () { onClose: function () {
const serviceId = $selectService.val(); const serviceId = $selectService.val();
@ -527,54 +527,54 @@ App.Components.AppointmentsModal = (function () {
// Translation // Translation
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes, minuteText: lang('minutes'),
firstDay: firstWeekDayNumber firstDay: firstWeekDayNumber
}); });
$endDatetime.datetimepicker('setDate', endDatetime); $endDatetime.datetimepicker('setDate', endDatetime);
@ -604,13 +604,13 @@ App.Components.AppointmentsModal = (function () {
}); });
if (missingRequiredField) { if (missingRequiredField) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Check email address. // Check email address.
if (!App.Utils.Validation.email($appointmentsModal.find('#email').val())) { if (!App.Utils.Validation.email($appointmentsModal.find('#email').val())) {
$appointmentsModal.find('#email').addClass('is-invalid'); $appointmentsModal.find('#email').addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
// Check appointment start and end time. // Check appointment start and end time.
@ -619,7 +619,7 @@ App.Components.AppointmentsModal = (function () {
if (start > end) { if (start > end) {
$startDatetime.addClass('is-invalid'); $startDatetime.addClass('is-invalid');
$endDatetime.addClass('is-invalid'); $endDatetime.addClass('is-invalid');
throw new Error(App.Lang.start_date_before_end_error); throw new Error(lang('start_date_before_end_error'));
} }
return true; return true;

View file

@ -59,7 +59,7 @@ App.Components.UnavailabilitiesModal = (function () {
// Start time is after end time - display message to user. // Start time is after end time - display message to user.
$unavailabilitiesModal $unavailabilitiesModal
.find('.modal-message') .find('.modal-message')
.text(App.Lang.start_date_before_end_error) .text(lang('start_date_before_end_error'))
.addClass('alert-danger') .addClass('alert-danger')
.removeClass('d-none'); .removeClass('d-none');
@ -85,7 +85,7 @@ App.Components.UnavailabilitiesModal = (function () {
const successCallback = () => { const successCallback = () => {
// Display success message to the user. // Display success message to the user.
App.Layouts.Backend.displayNotification(App.Lang.unavailable_saved); App.Layouts.Backend.displayNotification(lang('unavailable_saved'));
// Close the modal dialog and refresh the calendar appointments. // Close the modal dialog and refresh the calendar appointments.
$unavailabilitiesModal.find('.alert').addClass('d-none'); $unavailabilitiesModal.find('.alert').addClass('d-none');
@ -139,7 +139,7 @@ App.Components.UnavailabilitiesModal = (function () {
true true
) )
); );
$dialog.find('.modal-header h3').text(App.Lang.new_unavailable_title); $dialog.find('.modal-header h3').text(lang('new_unavailable_title'));
$dialog.modal('show'); $dialog.modal('show');
}); });
} }
@ -187,54 +187,54 @@ App.Components.UnavailabilitiesModal = (function () {
// Translation // Translation
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes, minuteText: lang('minutes'),
firstDay: firstWeekdayId firstDay: firstWeekdayId
}); });
$unavailabilityStart.val(start); $unavailabilityStart.val(start);
@ -245,54 +245,54 @@ App.Components.UnavailabilitiesModal = (function () {
// Translation // Translation
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes, minuteText: lang('minutes'),
firstDay: firstWeekdayId firstDay: firstWeekdayId
}); });
$unavailabilityEnd.val(end); $unavailabilityEnd.val(end);

View file

@ -151,12 +151,12 @@ App.Components.WorkingPlanExceptionsModal = (function () {
submit: $('<button/>', { submit: $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'd-none submit-editable', 'class': 'd-none submit-editable',
'text': App.Lang.save 'text': lang('save')
}).get(0).outerHTML, }).get(0).outerHTML,
cancel: $('<button/>', { cancel: $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'd-none cancel-editable', 'class': 'd-none cancel-editable',
'text': App.Lang.cancel 'text': lang('cancel')
}).get(0).outerHTML, }).get(0).outerHTML,
onblur: 'ignore', onblur: 'ignore',
onreset: function () { onreset: function () {
@ -243,7 +243,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm me-2 working-plan-exceptions-edit-break', 'class': 'btn btn-outline-secondary btn-sm me-2 working-plan-exceptions-edit-break',
'title': App.Lang.edit, 'title': lang('edit'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-edit' 'class': 'fas fa-edit'
@ -253,7 +253,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-delete-break', 'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-delete-break',
'title': App.Lang.delete, 'title': lang('delete'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-trash-alt' 'class': 'fas fa-trash-alt'
@ -263,7 +263,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm me-2 working-plan-exceptions-save-break d-none', 'class': 'btn btn-outline-secondary btn-sm me-2 working-plan-exceptions-save-break d-none',
'title': App.Lang.save, 'title': lang('save'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-check-circle' 'class': 'fas fa-check-circle'
@ -273,7 +273,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-cancel-break d-none', 'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-cancel-break d-none',
'title': App.Lang.cancel, 'title': lang('cancel'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-ban' 'class': 'fas fa-ban'
@ -417,50 +417,50 @@ App.Components.WorkingPlanExceptionsModal = (function () {
minDate: 0, minDate: 0,
defaultDate: moment().toDate(), defaultDate: moment().toDate(),
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close closeText: lang('close')
}); });
} }
@ -472,12 +472,12 @@ App.Components.WorkingPlanExceptionsModal = (function () {
function initializeTimepicker($target) { function initializeTimepicker($target) {
$target.timepicker({ $target.timepicker({
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm', timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes minuteText: lang('minutes')
}); });
} }

View file

@ -133,7 +133,7 @@ App.Http.Booking = (function () {
} }
if (!$availableHours.find('.available-hour').length) { if (!$availableHours.find('.available-hour').length) {
$availableHours.text(App.Lang.no_available_hours); $availableHours.text(lang('no_available_hours'));
} }
}); });
} }
@ -193,7 +193,7 @@ App.Http.Booking = (function () {
}) })
.done((response) => { .done((response) => {
if (response.captcha_verification === false) { if (response.captcha_verification === false) {
$captchaHint.text(App.Lang.captcha_is_wrong).fadeTo(400, 1); $captchaHint.text(lang('captcha_is_wrong')).fadeTo(400, 1);
setTimeout(() => { setTimeout(() => {
$captchaHint.fadeTo(400, 0); $captchaHint.fadeTo(400, 0);
@ -288,7 +288,7 @@ App.Http.Booking = (function () {
// If all the days are unavailable then hide the appointments hours. // If all the days are unavailable then hide the appointments hours.
if (unavailableDates.length === numberOfDays) { if (unavailableDates.length === numberOfDays) {
$availableHours.text(App.Lang.no_available_hours); $availableHours.text(lang('no_available_hours'));
} }
// Grey out unavailable dates. // Grey out unavailable dates.

View file

@ -58,7 +58,7 @@ App.Pages.Account = (function () {
}); });
if (missingRequiredFields) { if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Validate passwords (if values provided). // Validate passwords (if values provided).
@ -66,7 +66,7 @@ App.Pages.Account = (function () {
if ($password.val() && $password.val() !== $retypePassword.val()) { if ($password.val() && $password.val() !== $retypePassword.val()) {
$password.addClass('is-invalid'); $password.addClass('is-invalid');
$retypePassword.addClass('is-invalid'); $retypePassword.addClass('is-invalid');
throw new Error(App.Lang.passwords_mismatch); throw new Error(lang('passwords_mismatch'));
} }
// Validate user email. // Validate user email.
@ -75,11 +75,11 @@ App.Pages.Account = (function () {
if (!App.Utils.Validation.email(emailValue)) { if (!App.Utils.Validation.email(emailValue)) {
$email.addClass('is-invalid'); $email.addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
if ($username.hasClass('is-invalid')) { if ($username.hasClass('is-invalid')) {
throw new Error(App.Lang.username_already_exists); throw new Error(lang('username_already_exists'));
} }
return false; return false;
@ -147,7 +147,7 @@ App.Pages.Account = (function () {
*/ */
function onSaveSettingsClick() { function onSaveSettingsClick() {
if (isInvalid()) { if (isInvalid()) {
App.Layouts.Backend.displayNotification(App.Lang.user_settings_are_invalid); App.Layouts.Backend.displayNotification(lang('user_settings_are_invalid'));
return; return;
} }
@ -155,7 +155,7 @@ App.Pages.Account = (function () {
const account = serialize(); const account = serialize();
App.Http.Account.save(account).done(() => { App.Http.Account.save(account).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.settings_saved); App.Layouts.Backend.displayNotification(lang('settings_saved'));
$footerUserDisplayName.text('Hello, ' + $firstName.val() + ' ' + $lastName.val() + '!'); $footerUserDisplayName.text('Hello, ' + $firstName.val() + ' ' + $lastName.val() + '!');
}); });
@ -171,7 +171,7 @@ App.Pages.Account = (function () {
const isValid = response.is_valid; const isValid = response.is_valid;
$username.toggleClass('is-invalid', !isValid); $username.toggleClass('is-invalid', !isValid);
if (!isValid) { if (!isValid) {
App.Layouts.Backend.displayNotification(App.Lang.username_already_exists); App.Layouts.Backend.displayNotification(lang('username_already_exists'));
} }
}); });
} }

View file

@ -66,12 +66,12 @@ App.Pages.Admins = (function () {
if (response.is_valid === 'false') { if (response.is_valid === 'false') {
$input.addClass('is-invalid'); $input.addClass('is-invalid');
$input.attr('already-exists', 'true'); $input.attr('already-exists', 'true');
$input.parents().eq(3).find('.form-message').text(App.Lang.username_already_exists); $input.parents().eq(3).find('.form-message').text(lang('username_already_exists'));
$input.parents().eq(3).find('.form-message').show(); $input.parents().eq(3).find('.form-message').show();
} else { } else {
$input.removeClass('is-invalid'); $input.removeClass('is-invalid');
$input.attr('already-exists', 'false'); $input.attr('already-exists', 'false');
if ($input.parents().eq(3).find('.form-message').text() === App.Lang.username_already_exists) { if ($input.parents().eq(3).find('.form-message').text() === lang('username_already_exists')) {
$input.parents().eq(3).find('.form-message').hide(); $input.parents().eq(3).find('.form-message').hide();
} }
} }
@ -151,13 +151,13 @@ App.Pages.Admins = (function () {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: function () { click: function () {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: function () { click: function () {
remove(adminId); remove(adminId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -165,7 +165,7 @@ App.Pages.Admins = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_admin, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_admin'), lang('delete_record_prompt'), buttons);
}); });
/** /**
@ -232,7 +232,7 @@ App.Pages.Admins = (function () {
*/ */
function save(admin) { function save(admin) {
App.Http.Admins.save(admin).then((response) => { App.Http.Admins.save(admin).then((response) => {
App.Layouts.Backend.displayNotification(App.Lang.admin_saved); App.Layouts.Backend.displayNotification(lang('admin_saved'));
resetForm(); resetForm();
$('#filter-admins .key').val(''); $('#filter-admins .key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -246,7 +246,7 @@ App.Pages.Admins = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Admins.destroy(id).then(() => { App.Http.Admins.destroy(id).then(() => {
App.Layouts.Backend.displayNotification(App.Lang.admin_deleted); App.Layouts.Backend.displayNotification(lang('admin_deleted'));
resetForm(); resetForm();
filter($('#filter-admins .key').val()); filter($('#filter-admins .key').val());
}); });
@ -278,24 +278,24 @@ App.Pages.Admins = (function () {
// Validate passwords. // Validate passwords.
if ($password.val() !== $passwordConfirmation.val()) { if ($password.val() !== $passwordConfirmation.val()) {
$('#admin-password, #admin-password-confirm').addClass('is-invalid'); $('#admin-password, #admin-password-confirm').addClass('is-invalid');
throw new Error(App.Lang.passwords_mismatch); throw new Error(lang('passwords_mismatch'));
} }
if ($password.val().length < vars('min_password_length') && $password.val() !== '') { if ($password.val().length < vars('min_password_length') && $password.val() !== '') {
$('#admin-password, #admin-password-confirm').addClass('is-invalid'); $('#admin-password, #admin-password-confirm').addClass('is-invalid');
throw new Error(App.Lang.password_length_notice.replace('$number', vars('min_password_length'))); throw new Error(lang('password_length_notice').replace('$number', vars('min_password_length')));
} }
// Validate user email. // Validate user email.
if (!App.Utils.Validation.email($email.val())) { if (!App.Utils.Validation.email($email.val())) {
$email.addClass('is-invalid'); $email.addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
// Check if username exists // Check if username exists
if ($username.attr('already-exists') === 'true') { if ($username.attr('already-exists') === 'true') {
$username.addClass('is-invalid'); $username.addClass('is-invalid');
throw new Error(App.Lang.username_already_exists); throw new Error(lang('username_already_exists'));
} }
return true; return true;
@ -370,14 +370,14 @@ App.Pages.Admins = (function () {
if (!response.length) { if (!response.length) {
$filterAdmins.find('.results').append( $filterAdmins.find('.results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': function () { 'click': function () {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);

View file

@ -73,7 +73,7 @@ App.Pages.Booking = (function () {
} }
}, },
content: { content: {
message: App.Lang.website_using_cookies_to_ensure_best_experience, message: lang('website_using_cookies_to_ensure_best_experience'),
dismiss: 'OK' dismiss: 'OK'
} }
}); });
@ -103,50 +103,50 @@ App.Pages.Booking = (function () {
defaultDate: moment().toDate(), defaultDate: moment().toDate(),
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
prevText: App.Lang.previous, prevText: lang('previous'),
nextText: App.Lang.next, nextText: lang('next'),
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
onSelect: () => { onSelect: () => {
App.Http.Booking.getAvailableHours(moment($selectDate.datepicker('getDate')).format('YYYY-MM-DD')); App.Http.Booking.getAvailableHours(moment($selectDate.datepicker('getDate')).format('YYYY-MM-DD'));
@ -262,7 +262,7 @@ App.Pages.Booking = (function () {
// Add the "Any Provider" entry. // Add the "Any Provider" entry.
if ($selectProvider.find('option').length >= 1 && vars('display_any_provider') === '1') { if ($selectProvider.find('option').length >= 1 && vars('display_any_provider') === '1') {
$selectProvider.prepend(new Option('- ' + App.Lang.any_provider + ' -', 'any-provider', true, true)); $selectProvider.prepend(new Option('- ' + lang('any_provider') + ' -', 'any-provider', true, true));
} }
App.Http.Booking.getUnavailableDates( App.Http.Booking.getUnavailableDates(
@ -297,7 +297,7 @@ App.Pages.Booking = (function () {
$('<div/>', { $('<div/>', {
'id': 'select-hour-prompt', 'id': 'select-hour-prompt',
'class': 'text-danger mb-4', 'class': 'text-danger mb-4',
'text': App.Lang.appointment_hour_missing 'text': lang('appointment_hour_missing')
}).prependTo('#available-hours'); }).prependTo('#available-hours');
} }
return; return;
@ -406,7 +406,7 @@ App.Pages.Booking = (function () {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -425,8 +425,8 @@ App.Pages.Booking = (function () {
]; ];
App.Utils.Message.show( App.Utils.Message.show(
App.Lang.cancel_appointment_title, lang('cancel_appointment_title'),
App.Lang.write_appointment_removal_reason, lang('write_appointment_removal_reason'),
buttons buttons
); );
@ -445,13 +445,13 @@ App.Pages.Booking = (function () {
$deletePersonalInformation.on('click', () => { $deletePersonalInformation.on('click', () => {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: () => { click: () => {
App.Http.Booking.deletePersonalInformation(vars('customer_token')); App.Http.Booking.deletePersonalInformation(vars('customer_token'));
} }
@ -459,8 +459,8 @@ App.Pages.Booking = (function () {
]; ];
App.Utils.Message.show( App.Utils.Message.show(
App.Lang.delete_personal_information, lang('delete_personal_information'),
App.Lang.delete_personal_information_prompt, lang('delete_personal_information_prompt'),
buttons buttons
); );
}); });
@ -515,25 +515,25 @@ App.Pages.Booking = (function () {
}); });
if (missingRequiredField) { if (missingRequiredField) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
const $acceptToTermsAndConditions = $('#accept-to-terms-and-conditions'); const $acceptToTermsAndConditions = $('#accept-to-terms-and-conditions');
if ($acceptToTermsAndConditions.length && !$acceptToTermsAndConditions.prop('checked')) { if ($acceptToTermsAndConditions.length && !$acceptToTermsAndConditions.prop('checked')) {
$acceptToTermsAndConditions.parents('.form-check').addClass('text-danger'); $acceptToTermsAndConditions.parents('.form-check').addClass('text-danger');
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
const $acceptToPrivacyPolicy = $('#accept-to-privacy-policy'); const $acceptToPrivacyPolicy = $('#accept-to-privacy-policy');
if ($acceptToPrivacyPolicy.length && !$acceptToPrivacyPolicy.prop('checked')) { if ($acceptToPrivacyPolicy.length && !$acceptToPrivacyPolicy.prop('checked')) {
$acceptToPrivacyPolicy.parents('.form-check').addClass('text-danger'); $acceptToPrivacyPolicy.parents('.form-check').addClass('text-danger');
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Validate email address. // Validate email address.
if ($email.val() && !App.Utils.Validation.email($email.val())) { if ($email.val() && !App.Utils.Validation.email($email.val())) {
$email.parents('.form-group').addClass('is-invalid'); $email.parents('.form-group').addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
return true; return true;
@ -576,21 +576,21 @@ App.Pages.Booking = (function () {
$('<div/>', { $('<div/>', {
'html': [ 'html': [
$('<h4/>', { $('<h4/>', {
'text': App.Lang.appointment 'text': lang('appointment')
}), }),
$('<p/>', { $('<p/>', {
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'text': App.Lang.service + ': ' + $selectService.find('option:selected').text() 'text': lang('service') + ': ' + $selectService.find('option:selected').text()
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': App.Lang.provider + ': ' + $selectProvider.find('option:selected').text() 'text': lang('provider') + ': ' + $selectProvider.find('option:selected').text()
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': 'text':
App.Lang.start + lang('start') +
': ' + ': ' +
selectedDate + selectedDate +
' ' + ' ' +
@ -598,11 +598,11 @@ App.Pages.Booking = (function () {
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': App.Lang.timezone + ': ' + $selectTimezone.find('option:selected').text() 'text': lang('timezone') + ': ' + $selectTimezone.find('option:selected').text()
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': App.Lang.price + ': ' + servicePrice + ' ' + serviceCurrency, 'text': lang('price') + ': ' + servicePrice + ' ' + serviceCurrency,
'prop': { 'prop': {
'hidden': !servicePrice 'hidden': !servicePrice
} }
@ -626,32 +626,32 @@ App.Pages.Booking = (function () {
$('<div/>', { $('<div/>', {
'html': [ 'html': [
$('<h4/>)', { $('<h4/>)', {
'text': App.Lang.customer 'text': lang('customer')
}), }),
$('<p/>', { $('<p/>', {
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'text': App.Lang.customer + ': ' + firstName + ' ' + lastName 'text': lang('customer') + ': ' + firstName + ' ' + lastName
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': App.Lang.phone_number + ': ' + phoneNumber 'text': lang('phone_number') + ': ' + phoneNumber
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': App.Lang.email + ': ' + email 'text': lang('email') + ': ' + email
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': address ? App.Lang.address + ': ' + address : '' 'text': address ? lang('address') + ': ' + address : ''
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': city ? App.Lang.city + ': ' + city : '' 'text': city ? lang('city') + ': ' + city : ''
}), }),
$('<br/>'), $('<br/>'),
$('<span/>', { $('<span/>', {
'text': zipCode ? App.Lang.zip_code + ': ' + zipCode : '' 'text': zipCode ? lang('zip_code') + ': ' + zipCode : ''
}), }),
$('<br/>') $('<br/>')
] ]
@ -810,19 +810,19 @@ App.Pages.Booking = (function () {
if (service.duration) { if (service.duration) {
$('<span/>', { $('<span/>', {
'text': '[' + App.Lang.duration + ' ' + service.duration + ' ' + App.Lang.minutes + ']' 'text': '[' + lang('duration') + ' ' + service.duration + ' ' + lang('minutes') + ']'
}).appendTo($serviceDescription); }).appendTo($serviceDescription);
} }
if (Number(service.price) > 0) { if (Number(service.price) > 0) {
$('<span/>', { $('<span/>', {
'text': '[' + App.Lang.price + ' ' + service.price + ' ' + service.currency + ']' 'text': '[' + lang('price') + ' ' + service.price + ' ' + service.currency + ']'
}).appendTo($serviceDescription); }).appendTo($serviceDescription);
} }
if (service.location) { if (service.location) {
$('<span/>', { $('<span/>', {
'text': '[' + App.Lang.location + ' ' + service.location + ']' 'text': '[' + lang('location') + ' ' + service.location + ']'
}).appendTo($serviceDescription); }).appendTo($serviceDescription);
} }
} }

View file

@ -72,14 +72,14 @@ App.Pages.BookingConfirmation = (function () {
'class': 'alert alert-success col-xs-12', 'class': 'alert alert-success col-xs-12',
'html': [ 'html': [
$('<h4/>', { $('<h4/>', {
'text': App.Lang.success 'text': lang('success')
}), }),
$('<p/>', { $('<p/>', {
'text': App.Lang.appointment_added_to_google_calendar 'text': lang('appointment_added_to_google_calendar')
}), }),
$('<a/>', { $('<a/>', {
'href': response.htmlLink, 'href': response.htmlLink,
'text': App.Lang.view_appointment_in_google_calendar 'text': lang('view_appointment_in_google_calendar')
}) })
] ]
}) })
@ -95,10 +95,10 @@ App.Pages.BookingConfirmation = (function () {
'class': 'alert alert-danger col-xs-12', 'class': 'alert alert-danger col-xs-12',
'html': [ 'html': [
$('<h4/>', { $('<h4/>', {
'text': App.Lang.oops_something_went_wrong 'text': lang('oops_something_went_wrong')
}), }),
$('<p/>', { $('<p/>', {
'text': App.Lang.could_not_add_to_google_calendar 'text': lang('could_not_add_to_google_calendar')
}), }),
$('<pre/>', { $('<pre/>', {
'text': error.message 'text': error.message

View file

@ -41,7 +41,7 @@ App.Pages.BookingSettings = (function () {
}); });
if (missingRequiredFields) { if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
return false; return false;
@ -143,7 +143,7 @@ App.Pages.BookingSettings = (function () {
*/ */
function onSaveSettingsClick() { function onSaveSettingsClick() {
if (isInvalid()) { if (isInvalid()) {
App.Layouts.Backend.displayNotification(App.Lang.settings_are_invalid); App.Layouts.Backend.displayNotification(lang('settings_are_invalid'));
return; return;
} }
@ -151,7 +151,7 @@ App.Pages.BookingSettings = (function () {
const bookingSettings = serialize(); const bookingSettings = serialize();
App.Http.BookingSettings.save(bookingSettings).done(() => { App.Http.BookingSettings.save(bookingSettings).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.settings_saved); App.Layouts.Backend.displayNotification(lang('settings_saved'));
}); });
} }

View file

@ -42,7 +42,7 @@ App.Pages.BusinessSettings = (function () {
}); });
if (missingRequiredFields) { if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
return false; return false;
@ -85,7 +85,7 @@ App.Pages.BusinessSettings = (function () {
*/ */
function onSaveSettingsClick() { function onSaveSettingsClick() {
if (isInvalid()) { if (isInvalid()) {
App.Layouts.Backend.displayNotification(App.Lang.settings_are_invalid); App.Layouts.Backend.displayNotification(lang('settings_are_invalid'));
return; return;
} }
@ -93,7 +93,7 @@ App.Pages.BusinessSettings = (function () {
const businessSettings = serialize(); const businessSettings = serialize();
App.Http.BusinessSettings.save(businessSettings).done(() => { App.Http.BusinessSettings.save(businessSettings).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.settings_saved); App.Layouts.Backend.displayNotification(lang('settings_saved'));
}); });
} }
@ -103,7 +103,7 @@ App.Pages.BusinessSettings = (function () {
function onApplyGlobalWorkingPlan() { function onApplyGlobalWorkingPlan() {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -115,7 +115,7 @@ App.Pages.BusinessSettings = (function () {
App.Http.BusinessSettings.applyGlobalWorkingPlan(workingPlan) App.Http.BusinessSettings.applyGlobalWorkingPlan(workingPlan)
.done(() => { .done(() => {
App.Layouts.Backend.displayNotification(App.Lang.working_plans_got_updated); App.Layouts.Backend.displayNotification(lang('working_plans_got_updated'));
}) })
.always(function () { .always(function () {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -124,7 +124,7 @@ App.Pages.BusinessSettings = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.working_plan, App.Lang.overwrite_existing_working_plans, buttons); App.Utils.Message.show(lang('working_plan'), lang('overwrite_existing_working_plans'), buttons);
} }
/** /**

View file

@ -69,7 +69,7 @@ App.Pages.Calendar = (function () {
App.Components.WorkingPlanExceptionsModal.add().done((date, workingPlanException) => { App.Components.WorkingPlanExceptionsModal.add().done((date, workingPlanException) => {
const successCallback = () => { const successCallback = () => {
App.Layouts.Backend.displayNotification(App.Lang.working_plan_exception_saved); App.Layouts.Backend.displayNotification(lang('working_plan_exception_saved'));
const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {}; const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {};

View file

@ -94,13 +94,13 @@ App.Pages.Categories = (function () {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: () => { click: () => {
remove(categoryId); remove(categoryId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -108,7 +108,7 @@ App.Pages.Categories = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_category, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_category'), lang('delete_record_prompt'), buttons);
}); });
/** /**
@ -164,14 +164,14 @@ App.Pages.Categories = (function () {
if (response.length === 0) { if (response.length === 0) {
$('#filter-categories .results').append( $('#filter-categories .results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': () => { 'click': () => {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);
@ -192,7 +192,7 @@ App.Pages.Categories = (function () {
*/ */
function save(category) { function save(category) {
App.Http.Categories.save(category).then((response) => { App.Http.Categories.save(category).then((response) => {
App.Layouts.Backend.displayNotification(App.Lang.category_saved); App.Layouts.Backend.displayNotification(lang('category_saved'));
resetForm(); resetForm();
$filterCategories.find('.key').val(''); $filterCategories.find('.key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -206,7 +206,7 @@ App.Pages.Categories = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Categories.destroy(id).then(() => { App.Http.Categories.destroy(id).then(() => {
App.Layouts.Backend.displayNotification(App.Lang.category_deleted); App.Layouts.Backend.displayNotification(lang('category_deleted'));
resetForm(); resetForm();
filter($('#filter-categories .key').val()); filter($('#filter-categories .key').val());
}); });
@ -243,7 +243,7 @@ App.Pages.Categories = (function () {
}); });
if (missingRequired) { if (missingRequired) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
return true; return true;

View file

@ -143,13 +143,13 @@ App.Pages.Customers = (function () {
const customerId = $id.val(); const customerId = $id.val();
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: () => { click: () => {
remove(customerId); remove(customerId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -157,7 +157,7 @@ App.Pages.Customers = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_customer, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_customer'), lang('delete_record_prompt'), buttons);
}); });
} }
@ -168,7 +168,7 @@ App.Pages.Customers = (function () {
*/ */
function save(customer) { function save(customer) {
App.Http.Customers.save(customer).then((response) => { App.Http.Customers.save(customer).then((response) => {
App.Layouts.Backend.displayNotification(App.Lang.customer_saved); App.Layouts.Backend.displayNotification(lang('customer_saved'));
resetForm(); resetForm();
$('#filter-customers .key').val(''); $('#filter-customers .key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -182,7 +182,7 @@ App.Pages.Customers = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Customers.destroy(id).then(() => { App.Http.Customers.destroy(id).then(() => {
App.Layouts.Backend.displayNotification(App.Lang.customer_deleted); App.Layouts.Backend.displayNotification(lang('customer_deleted'));
resetForm(); resetForm();
filter($('#filter-customers .key').val()); filter($('#filter-customers .key').val());
}); });
@ -207,13 +207,13 @@ App.Pages.Customers = (function () {
}); });
if (missingRequired) { if (missingRequired) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Validate email address. // Validate email address.
if (!App.Utils.Validation.email($email.val())) { if (!App.Utils.Validation.email($email.val())) {
$email.addClass('is-invalid'); $email.addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
return true; return true;
@ -268,7 +268,7 @@ App.Pages.Customers = (function () {
if (!customer.appointments.length) { if (!customer.appointments.length) {
$('<p/>', { $('<p/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}).appendTo($customerAppointments); }).appendTo($customerAppointments);
} }
@ -370,14 +370,14 @@ App.Pages.Customers = (function () {
if (!response.length) { if (!response.length) {
$filterCustomers.find('.results').append( $filterCustomers.find('.results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': () => { 'click': () => {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);

View file

@ -40,7 +40,7 @@ App.Pages.GeneralSettings = (function () {
}); });
if (missingRequiredFields) { if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
return false; return false;
@ -76,7 +76,7 @@ App.Pages.GeneralSettings = (function () {
*/ */
function onSaveSettingsClick() { function onSaveSettingsClick() {
if (isInvalid()) { if (isInvalid()) {
App.Layouts.Backend.displayNotification(App.Lang.settings_are_invalid); App.Layouts.Backend.displayNotification(lang('settings_are_invalid'));
return; return;
} }
@ -84,7 +84,7 @@ App.Pages.GeneralSettings = (function () {
const generalSettings = serialize(); const generalSettings = serialize();
App.Http.GeneralSettings.save(generalSettings).done(() => { App.Http.GeneralSettings.save(generalSettings).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.settings_saved); App.Layouts.Backend.displayNotification(lang('settings_saved'));
}); });
} }

View file

@ -46,7 +46,7 @@ App.Pages.LegalSettings = (function () {
}); });
if (missingRequiredFields) { if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
return false; return false;
@ -125,7 +125,7 @@ App.Pages.LegalSettings = (function () {
*/ */
function onSaveSettingsClick() { function onSaveSettingsClick() {
if (isInvalid()) { if (isInvalid()) {
App.Layouts.Backend.displayNotification(App.Lang.settings_are_invalid); App.Layouts.Backend.displayNotification(lang('settings_are_invalid'));
return; return;
} }
@ -133,7 +133,7 @@ App.Pages.LegalSettings = (function () {
const legalSettings = serialize(); const legalSettings = serialize();
App.Http.LegalSettings.save(legalSettings).done(() => { App.Http.LegalSettings.save(legalSettings).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.settings_saved); App.Layouts.Backend.displayNotification(lang('settings_saved'));
}); });
} }

View file

@ -40,7 +40,7 @@ App.Pages.Login = (function () {
if (response.success) { if (response.success) {
window.location.href = vars('dest_url'); window.location.href = vars('dest_url');
} else { } else {
$alert.text(App.Lang.login_failed); $alert.text(lang('login_failed'));
$alert.removeClass('d-none alert-danger alert-success').addClass('alert-danger'); $alert.removeClass('d-none alert-danger alert-success').addClass('alert-danger');
} }
}); });

View file

@ -131,13 +131,13 @@ App.Pages.Providers = (function () {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: function () { click: function () {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: function () { click: function () {
remove(providerId); remove(providerId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -145,7 +145,7 @@ App.Pages.Providers = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_provider, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_provider'), lang('delete_record_prompt'), buttons);
}); });
/** /**
@ -239,7 +239,7 @@ App.Pages.Providers = (function () {
*/ */
function save(provider) { function save(provider) {
App.Http.Providers.save(provider).then((response) => { App.Http.Providers.save(provider).then((response) => {
App.Layouts.Backend.displayNotification(App.Lang.provider_saved); App.Layouts.Backend.displayNotification(lang('provider_saved'));
resetForm(); resetForm();
$('#filter-providers .key').val(''); $('#filter-providers .key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -253,7 +253,7 @@ App.Pages.Providers = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Providers.destroy(id).then(() => { App.Http.Providers.destroy(id).then(() => {
App.Layouts.Backend.displayNotification(App.Lang.provider_deleted); App.Layouts.Backend.displayNotification(lang('provider_deleted'));
resetForm(); resetForm();
filter($('#filter-providers .key').val()); filter($('#filter-providers .key').val());
}); });
@ -280,30 +280,30 @@ App.Pages.Providers = (function () {
}); });
if (missingRequired) { if (missingRequired) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Validate passwords. // Validate passwords.
if ($password.val() !== $passwordConfirmation.val()) { if ($password.val() !== $passwordConfirmation.val()) {
$('#provider-password, #provider-password-confirm').addClass('is-invalid'); $('#provider-password, #provider-password-confirm').addClass('is-invalid');
throw new Error(App.Lang.passwords_mismatch); throw new Error(lang('passwords_mismatch'));
} }
if ($password.val().length < vars('min_password_length') && $password.val() !== '') { if ($password.val().length < vars('min_password_length') && $password.val() !== '') {
$('#provider-password, #provider-password-confirm').addClass('is-invalid'); $('#provider-password, #provider-password-confirm').addClass('is-invalid');
throw new Error(App.Lang.password_length_notice.replace('$number', MIN_PASSWORD_LENGTH)); throw new Error(lang('password_length_notice').replace('$number', MIN_PASSWORD_LENGTH));
} }
// Validate user email. // Validate user email.
if (!App.Utils.Validation.email($email.val())) { if (!App.Utils.Validation.email($email.val())) {
$email.addClass('is-invalid'); $email.addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(lang('invalid_email'));
} }
// Check if username exists // Check if username exists
if ($username.attr('already-exists') === 'true') { if ($username.attr('already-exists') === 'true') {
$username.addClass('is-invalid'); $username.addClass('is-invalid');
throw new Error(App.Lang.username_already_exists); throw new Error(lang('username_already_exists'));
} }
return true; return true;
@ -447,14 +447,14 @@ App.Pages.Providers = (function () {
if (!response.length) { if (!response.length) {
$filterProviders.find('.results').append( $filterProviders.find('.results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': function () { 'click': function () {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);

View file

@ -45,7 +45,7 @@ App.Pages.Recovery = (function () {
if (response.success) { if (response.success) {
$alert.addClass('alert-success'); $alert.addClass('alert-success');
$alert.text(App.Lang.new_password_sent_with_email); $alert.text(lang('new_password_sent_with_email'));
} else { } else {
$alert.addClass('alert-danger'); $alert.addClass('alert-danger');
$alert.text( $alert.text(

View file

@ -68,12 +68,12 @@ App.Pages.Secretaries = (function () {
if (response.is_valid === 'false') { if (response.is_valid === 'false') {
$input.addClass('is-invalid'); $input.addClass('is-invalid');
$input.attr('already-exists', 'true'); $input.attr('already-exists', 'true');
$input.parents().eq(3).find('.form-message').text(App.Lang.username_already_exists); $input.parents().eq(3).find('.form-message').text(lang('username_already_exists'));
$input.parents().eq(3).find('.form-message').show(); $input.parents().eq(3).find('.form-message').show();
} else { } else {
$input.removeClass('is-invalid'); $input.removeClass('is-invalid');
$input.attr('already-exists', 'false'); $input.attr('already-exists', 'false');
if ($input.parents().eq(3).find('.form-message').text() === App.Lang.username_already_exists) { if ($input.parents().eq(3).find('.form-message').text() === lang('username_already_exists')) {
$input.parents().eq(3).find('.form-message').hide(); $input.parents().eq(3).find('.form-message').hide();
} }
} }
@ -155,13 +155,13 @@ App.Pages.Secretaries = (function () {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: () => { click: () => {
remove(secretaryId); remove(secretaryId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -169,7 +169,7 @@ App.Pages.Secretaries = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_secretary, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_secretary'), lang('delete_record_prompt'), buttons);
}); });
/** /**
@ -243,7 +243,7 @@ App.Pages.Secretaries = (function () {
*/ */
function save(secretary) { function save(secretary) {
App.Http.Secretaries.save(secretary).done((response) => { App.Http.Secretaries.save(secretary).done((response) => {
App.Layouts.Backend.displayNotification(App.Lang.secretary_saved); App.Layouts.Backend.displayNotification(lang('secretary_saved'));
resetForm(); resetForm();
$('#filter-secretaries .key').val(''); $('#filter-secretaries .key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -257,7 +257,7 @@ App.Pages.Secretaries = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Secretaries.destroy(id).done(() => { App.Http.Secretaries.destroy(id).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.secretary_deleted); App.Layouts.Backend.displayNotification(lang('secretary_deleted'));
resetForm(); resetForm();
filter($('#filter-secretaries .key').val()); filter($('#filter-secretaries .key').val());
}); });
@ -393,14 +393,14 @@ App.Pages.Secretaries = (function () {
if (!response.length) { if (!response.length) {
$('#filter-secretaries .results').append( $('#filter-secretaries .results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': () => { 'click': () => {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);

View file

@ -163,13 +163,13 @@ App.Pages.Services = (function () {
const serviceId = $id.val(); const serviceId = $id.val();
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
}, },
{ {
text: App.Lang.delete, text: lang('delete'),
click: () => { click: () => {
remove(serviceId); remove(serviceId);
$('#message-box').dialog('close'); $('#message-box').dialog('close');
@ -177,7 +177,7 @@ App.Pages.Services = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.delete_service, App.Lang.delete_record_prompt, buttons); App.Utils.Message.show(lang('delete_service'), lang('delete_record_prompt'), buttons);
}); });
} }
@ -189,7 +189,7 @@ App.Pages.Services = (function () {
*/ */
function save(service) { function save(service) {
App.Http.Services.save(service).then((response) => { App.Http.Services.save(service).then((response) => {
App.Layouts.Backend.displayNotification(App.Lang.service_saved); App.Layouts.Backend.displayNotification(lang('service_saved'));
resetForm(); resetForm();
$filterServices.find('.key').val(''); $filterServices.find('.key').val('');
filter('', response.id, true); filter('', response.id, true);
@ -203,7 +203,7 @@ App.Pages.Services = (function () {
*/ */
function remove(id) { function remove(id) {
App.Http.Services.destroy(id).then(() => { App.Http.Services.destroy(id).then(() => {
App.Layouts.Backend.displayNotification(App.Lang.service_deleted); App.Layouts.Backend.displayNotification(lang('service_deleted'));
resetForm(); resetForm();
filter($filterServices.find('.key').val()); filter($filterServices.find('.key').val());
}); });
@ -230,13 +230,13 @@ App.Pages.Services = (function () {
}); });
if (missingRequired) { if (missingRequired) {
throw new Error(App.Lang.fields_are_required); throw new Error(lang('fields_are_required'));
} }
// Validate the duration. // Validate the duration.
if (Number($duration.val()) < 5) { if (Number($duration.val()) < 5) {
$duration.addClass('is-invalid'); $duration.addClass('is-invalid');
throw new Error(App.Lang.invalid_duration); throw new Error(lang('invalid_duration'));
} }
return true; return true;
@ -306,14 +306,14 @@ App.Pages.Services = (function () {
if (response.length === 0) { if (response.length === 0) {
$filterServices.find('.results').append( $filterServices.find('.results').append(
$('<em/>', { $('<em/>', {
'text': App.Lang.no_records_found 'text': lang('no_records_found')
}) })
); );
} else if (response.length === filterLimit) { } else if (response.length === filterLimit) {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary w-100 load-more text-center', 'class': 'btn btn-outline-secondary w-100 load-more text-center',
'text': App.Lang.load_more, 'text': lang('load_more'),
'click': () => { 'click': () => {
filterLimit += 20; filterLimit += 20;
filter(keyword, selectId, show); filter(keyword, selectId, show);
@ -393,7 +393,7 @@ App.Pages.Services = (function () {
$select.append(new Option(category.name, category.id)); $select.append(new Option(category.name, category.id));
}); });
$select.append(new Option('- ' + App.Lang.no_category + ' -', '')).val(''); $select.append(new Option('- ' + lang('no_category') + ' -', '')).val('');
}); });
} }

View file

@ -84,7 +84,7 @@ App.Utils.CalendarDefaultView = (function () {
App.Components.WorkingPlanExceptionsModal.edit(date, workingPlanException).done( App.Components.WorkingPlanExceptionsModal.edit(date, workingPlanException).done(
(date, workingPlanException) => { (date, workingPlanException) => {
const successCallback = () => { const successCallback = () => {
App.Layouts.Backend.displayNotification(App.Lang.working_plan_exception_saved); App.Layouts.Backend.displayNotification(lang('working_plan_exception_saved'));
const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {}; const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {};
@ -118,7 +118,7 @@ App.Utils.CalendarDefaultView = (function () {
App.Components.AppointmentsModal.resetModal(); App.Components.AppointmentsModal.resetModal();
// Apply appointment data and show modal dialog. // Apply appointment data and show modal dialog.
$appointmentsModal.find('.modal-header h3').text(App.Lang.edit_appointment_title); $appointmentsModal.find('.modal-header h3').text(lang('edit_appointment_title'));
$appointmentsModal.find('#appointment-id').val(appointment.id); $appointmentsModal.find('#appointment-id').val(appointment.id);
$appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change'); $appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change');
$appointmentsModal.find('#select-provider').val(appointment.id_users_provider); $appointmentsModal.find('#select-provider').val(appointment.id_users_provider);
@ -190,7 +190,7 @@ App.Utils.CalendarDefaultView = (function () {
} }
const successCallback = () => { const successCallback = () => {
App.Layouts.Backend.displayNotification(App.Lang.working_plan_exception_deleted); App.Layouts.Backend.displayNotification(lang('working_plan_exception_deleted'));
const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {}; const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {};
delete workingPlanExceptions[date]; delete workingPlanExceptions[date];
@ -213,7 +213,7 @@ App.Utils.CalendarDefaultView = (function () {
} else if (!lastFocusedEventData.data.is_unavailable) { } else if (!lastFocusedEventData.data.is_unavailable) {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -236,8 +236,8 @@ App.Utils.CalendarDefaultView = (function () {
]; ];
App.Utils.Message.show( App.Utils.Message.show(
App.Lang.delete_appointment_title, lang('delete_appointment_title'),
App.Lang.write_appointment_removal_reason, lang('write_appointment_removal_reason'),
buttons buttons
); );
@ -293,11 +293,11 @@ App.Utils.CalendarDefaultView = (function () {
// If the user has already the sync enabled then apply the proper style changes. // If the user has already the sync enabled then apply the proper style changes.
if ($selectFilterItem.find('option:selected').attr('google-sync') === 'true') { if ($selectFilterItem.find('option:selected').attr('google-sync') === 'true') {
$('#enable-sync').removeClass('btn-light').addClass('btn-secondary enabled'); $('#enable-sync').removeClass('btn-light').addClass('btn-secondary enabled');
$('#enable-sync span').text(App.Lang.disable_sync); $('#enable-sync span').text(lang('disable_sync'));
$('#google-sync').prop('disabled', false); $('#google-sync').prop('disabled', false);
} else { } else {
$('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light'); $('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light');
$('#enable-sync span').text(App.Lang.enable_sync); $('#enable-sync span').text(lang('enable_sync'));
$('#google-sync').prop('disabled', true); $('#google-sync').prop('disabled', true);
} }
} }
@ -373,7 +373,7 @@ App.Utils.CalendarDefaultView = (function () {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -387,7 +387,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -400,7 +400,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.notes 'text': lang('notes')
}), }),
$('<span/>', { $('<span/>', {
'text': getEventNotes(event) 'text': getEventNotes(event)
@ -419,7 +419,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -430,7 +430,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -441,7 +441,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -464,7 +464,7 @@ App.Utils.CalendarDefaultView = (function () {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.provider 'text': lang('provider')
}), }),
$('<span/>', { $('<span/>', {
'text': event.data ? event.data.provider.first_name + ' ' + event.data.provider.last_name : '-' 'text': event.data ? event.data.provider.first_name + ' ' + event.data.provider.last_name : '-'
@ -473,7 +473,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -487,7 +487,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -501,7 +501,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.timezone 'text': lang('timezone')
}), }),
$('<span/>', { $('<span/>', {
'text': vars('timezones')[event.data.provider.timezone] 'text': vars('timezones')[event.data.provider.timezone]
@ -520,7 +520,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -531,7 +531,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -542,7 +542,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -558,7 +558,7 @@ App.Utils.CalendarDefaultView = (function () {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -572,7 +572,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -586,7 +586,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.timezone 'text': lang('timezone')
}), }),
$('<span/>', { $('<span/>', {
'text': vars('timezones')[event.data.provider.timezone] 'text': vars('timezones')[event.data.provider.timezone]
@ -595,7 +595,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.service 'text': lang('service')
}), }),
$('<span/>', { $('<span/>', {
'text': event.data.service.name 'text': event.data.service.name
@ -604,7 +604,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.provider 'text': lang('provider')
}), }),
App.Utils.CalendarEventPopover.renderMapIcon(event.data.provider), App.Utils.CalendarEventPopover.renderMapIcon(event.data.provider),
$('<span/>', { $('<span/>', {
@ -614,7 +614,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.customer 'text': lang('customer')
}), }),
App.Utils.CalendarEventPopover.renderMapIcon(event.data.customer), App.Utils.CalendarEventPopover.renderMapIcon(event.data.customer),
$('<span/>', { $('<span/>', {
@ -625,7 +625,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.email 'text': lang('email')
}), }),
App.Utils.CalendarEventPopover.renderMailIcon(event.data.customer.email), App.Utils.CalendarEventPopover.renderMailIcon(event.data.customer.email),
$('<span/>', { $('<span/>', {
@ -636,7 +636,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<strong/>', { $('<strong/>', {
'class': 'd-inline-block me-2', 'class': 'd-inline-block me-2',
'text': App.Lang.phone 'text': lang('phone')
}), }),
App.Utils.CalendarEventPopover.renderPhoneIcon(event.data.customer.phone_number), App.Utils.CalendarEventPopover.renderPhoneIcon(event.data.customer.phone_number),
$('<span/>', { $('<span/>', {
@ -646,7 +646,7 @@ App.Utils.CalendarDefaultView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.notes 'text': lang('notes')
}), }),
$('<span/>', { $('<span/>', {
'text': getEventNotes(event) 'text': getEventNotes(event)
@ -665,7 +665,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -676,7 +676,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -687,7 +687,7 @@ App.Utils.CalendarDefaultView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -729,7 +729,7 @@ App.Utils.CalendarDefaultView = (function () {
function calendarEventResize(event, delta, revertFunc) { function calendarEventResize(event, delta, revertFunc) {
if (vars('privileges').appointments.edit === false) { if (vars('privileges').appointments.edit === false) {
revertFunc(); revertFunc();
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments); App.Layouts.Backend.displayNotification(lang('no_privileges_edit_appointments'));
return; return;
} }
@ -769,9 +769,9 @@ App.Utils.CalendarDefaultView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.appointment_updated, [ App.Layouts.Backend.displayNotification(lang('appointment_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -811,9 +811,9 @@ App.Utils.CalendarDefaultView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.unavailable_updated, [ App.Layouts.Backend.displayNotification(lang('unavailable_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -868,7 +868,7 @@ App.Utils.CalendarDefaultView = (function () {
function calendarEventDrop(event, delta, revertFunc) { function calendarEventDrop(event, delta, revertFunc) {
if (vars('privileges').appointments.edit === false) { if (vars('privileges').appointments.edit === false) {
revertFunc(); revertFunc();
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments); App.Layouts.Backend.displayNotification(lang('no_privileges_edit_appointments'));
return; return;
} }
@ -922,9 +922,9 @@ App.Utils.CalendarDefaultView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.appointment_updated, [ App.Layouts.Backend.displayNotification(lang('appointment_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -965,9 +965,9 @@ App.Utils.CalendarDefaultView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.unavailable_updated, [ App.Layouts.Backend.displayNotification(lang('unavailable_updated'), [
{ {
label: App.Lang.undo, label: lang('undo'),
function: undoFunction function: undoFunction
} }
]); ]);
@ -1082,7 +1082,7 @@ App.Utils.CalendarDefaultView = (function () {
} }
const unavailabilityEvent = { const unavailabilityEvent = {
title: App.Lang.unavailable + notes, title: lang('unavailable') + notes,
start: moment(unavailable.start_datetime), start: moment(unavailable.start_datetime),
end: moment(unavailable.end_datetime), end: moment(unavailable.end_datetime),
allDay: false, allDay: false,
@ -1142,7 +1142,7 @@ App.Utils.CalendarDefaultView = (function () {
workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end; workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end;
workingPlanExceptionEvent = { workingPlanExceptionEvent = {
title: App.Lang.working_plan_exception, title: lang('working_plan_exception'),
start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true), start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true),
end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'), end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true, allDay: true,
@ -1163,7 +1163,7 @@ App.Utils.CalendarDefaultView = (function () {
if (sortedWorkingPlan[weekdayName] === null) { if (sortedWorkingPlan[weekdayName] === null) {
// Working plan exception. // Working plan exception.
unavailabilityEvent = { unavailabilityEvent = {
title: App.Lang.not_working, title: lang('not_working'),
start: calendarView.intervalStart.clone(), start: calendarView.intervalStart.clone(),
end: calendarView.intervalEnd.clone(), end: calendarView.intervalEnd.clone(),
allDay: false, allDay: false,
@ -1186,7 +1186,7 @@ App.Utils.CalendarDefaultView = (function () {
if (viewStart < workDateStart) { if (viewStart < workDateStart) {
const unavailablePeriodBeforeWorkStarts = { const unavailablePeriodBeforeWorkStarts = {
title: App.Lang.not_working, title: lang('not_working'),
start: viewStart, start: viewStart,
end: workDateStart, end: workDateStart,
allDay: false, allDay: false,
@ -1207,7 +1207,7 @@ App.Utils.CalendarDefaultView = (function () {
if (viewEnd > workDateEnd) { if (viewEnd > workDateEnd) {
const unavailablePeriodAfterWorkEnds = { const unavailablePeriodAfterWorkEnds = {
title: App.Lang.not_working, title: lang('not_working'),
start: workDateEnd, start: workDateEnd,
end: viewEnd, end: viewEnd,
allDay: false, allDay: false,
@ -1232,7 +1232,7 @@ App.Utils.CalendarDefaultView = (function () {
breakEnd.minute(parseInt(breakEndString[1])); breakEnd.minute(parseInt(breakEndString[1]));
const unavailablePeriod = { const unavailablePeriod = {
title: App.Lang.break, title: lang('break'),
start: breakStart, start: breakStart,
end: breakEnd, end: breakEnd,
allDay: false, allDay: false,
@ -1263,7 +1263,7 @@ App.Utils.CalendarDefaultView = (function () {
workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end; workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end;
workingPlanExceptionEvent = { workingPlanExceptionEvent = {
title: App.Lang.working_plan_exception, title: lang('working_plan_exception'),
start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true), start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true),
end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'), end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true, allDay: true,
@ -1284,7 +1284,7 @@ App.Utils.CalendarDefaultView = (function () {
if (sortedWorkingPlan[weekdayName] === null) { if (sortedWorkingPlan[weekdayName] === null) {
// Add a full day unavailable event. // Add a full day unavailable event.
unavailabilityEvent = { unavailabilityEvent = {
title: App.Lang.not_working, title: lang('not_working'),
start: calendarDate.clone(), start: calendarDate.clone(),
end: calendarDate.clone().add(1, 'day'), end: calendarDate.clone().add(1, 'day'),
allDay: false, allDay: false,
@ -1308,7 +1308,7 @@ App.Utils.CalendarDefaultView = (function () {
if (calendarDate < workDateStart) { if (calendarDate < workDateStart) {
unavailabilityEvent = { unavailabilityEvent = {
title: App.Lang.not_working, title: lang('not_working'),
start: calendarDate.clone(), start: calendarDate.clone(),
end: moment( end: moment(
calendarDate.format('YYYY-MM-DD') + calendarDate.format('YYYY-MM-DD') +
@ -1333,7 +1333,7 @@ App.Utils.CalendarDefaultView = (function () {
if (calendarView.end > workDateEnd) { if (calendarView.end > workDateEnd) {
unavailabilityEvent = { unavailabilityEvent = {
title: App.Lang.not_working, title: lang('not_working'),
start: moment( start: moment(
calendarDate.format('YYYY-MM-DD') + calendarDate.format('YYYY-MM-DD') +
' ' + ' ' +
@ -1363,7 +1363,7 @@ App.Utils.CalendarDefaultView = (function () {
breakEnd.minute(parseInt(breakEndString[1])); breakEnd.minute(parseInt(breakEndString[1]));
const unavailabilityEvent = { const unavailabilityEvent = {
title: App.Lang.break, title: lang('break'),
start: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.start), start: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.start),
end: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.end), end: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.end),
allDay: false, allDay: false,
@ -1439,7 +1439,7 @@ App.Utils.CalendarDefaultView = (function () {
slotLabelInterval: '01:00', slotLabelInterval: '01:00',
timeFormat: timeFormat, timeFormat: timeFormat,
slotLabelFormat: slotTimeFormat, slotLabelFormat: slotTimeFormat,
allDayText: App.Lang.all_day, allDayText: lang('all_day'),
columnFormat: columnFormat, columnFormat: columnFormat,
header: { header: {
left: 'prev,next today', left: 'prev,next today',
@ -1504,65 +1504,65 @@ App.Utils.CalendarDefaultView = (function () {
// Translations // Translations
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
monthNamesShort: [ monthNamesShort: [
App.Lang.january.substr(0, 3), lang('january').substr(0, 3),
App.Lang.february.substr(0, 3), lang('february').substr(0, 3),
App.Lang.march.substr(0, 3), lang('march').substr(0, 3),
App.Lang.april.substr(0, 3), lang('april').substr(0, 3),
App.Lang.may.substr(0, 3), lang('may').substr(0, 3),
App.Lang.june.substr(0, 3), lang('june').substr(0, 3),
App.Lang.july.substr(0, 3), lang('july').substr(0, 3),
App.Lang.august.substr(0, 3), lang('august').substr(0, 3),
App.Lang.september.substr(0, 3), lang('september').substr(0, 3),
App.Lang.october.substr(0, 3), lang('october').substr(0, 3),
App.Lang.november.substr(0, 3), lang('november').substr(0, 3),
App.Lang.december.substr(0, 3) lang('december').substr(0, 3)
], ],
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
buttonText: { buttonText: {
today: App.Lang.today, today: lang('today'),
day: App.Lang.day, day: lang('day'),
week: App.Lang.week, week: lang('week'),
month: App.Lang.month month: lang('month')
}, },
// Calendar events need to be declared on initialization. // Calendar events need to be declared on initialization.
@ -1581,7 +1581,7 @@ App.Utils.CalendarDefaultView = (function () {
// Fill the select list boxes of the page. // Fill the select list boxes of the page.
if (vars('available_providers').length > 0) { if (vars('available_providers').length > 0) {
$('<optgroup/>', { $('<optgroup/>', {
'label': App.Lang.providers, 'label': lang('providers'),
'type': 'providers-group', 'type': 'providers-group',
'html': vars('available_providers').map((availableProvider) => { 'html': vars('available_providers').map((availableProvider) => {
const hasGoogleSync = availableProvider.settings.google_sync === '1' ? 'true' : 'false'; const hasGoogleSync = availableProvider.settings.google_sync === '1' ? 'true' : 'false';
@ -1598,7 +1598,7 @@ App.Utils.CalendarDefaultView = (function () {
if (vars('available_services').length > 0) { if (vars('available_services').length > 0) {
$('<optgroup/>', { $('<optgroup/>', {
'label': App.Lang.services, 'label': lang('services'),
'type': 'services-group', 'type': 'services-group',
'html': vars('available_services').map((availableService) => 'html': vars('available_services').map((availableService) =>
$('<option/>', { $('<option/>', {
@ -1649,7 +1649,7 @@ App.Utils.CalendarDefaultView = (function () {
App.Components.AppointmentsModal.resetModal(); App.Components.AppointmentsModal.resetModal();
$appointmentsModal.find('.modal-header h3').text(App.Lang.edit_appointment_title); $appointmentsModal.find('.modal-header h3').text(lang('edit_appointment_title'));
$appointmentsModal.find('#appointment-id').val(appointment.id); $appointmentsModal.find('#appointment-id').val(appointment.id);
$appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change'); $appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change');
$appointmentsModal.find('#select-provider').val(appointment.id_users_provider); $appointmentsModal.find('#select-provider').val(appointment.id_users_provider);

View file

@ -49,7 +49,7 @@ App.Utils.CalendarGoogleSync = (function () {
windowHandle.close(); windowHandle.close();
window.clearInterval(authInterval); window.clearInterval(authInterval);
$('#enable-sync').addClass('btn-secondary enabled').removeClass('btn-light'); $('#enable-sync').addClass('btn-secondary enabled').removeClass('btn-light');
$('#enable-sync span').text(App.Lang.disable_sync); $('#enable-sync span').text(lang('disable_sync'));
$('#google-sync').prop('disabled', false); $('#google-sync').prop('disabled', false);
$('#select-filter-item option:selected').attr('google-sync', 'true'); $('#select-filter-item option:selected').attr('google-sync', 'true');
@ -78,7 +78,7 @@ App.Utils.CalendarGoogleSync = (function () {
} else { } else {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -103,7 +103,7 @@ App.Utils.CalendarGoogleSync = (function () {
App.Http.Google.disableProviderSync(provider.id); App.Http.Google.disableProviderSync(provider.id);
$('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light'); $('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light');
$('#enable-sync span').text(App.Lang.enable_sync); $('#enable-sync span').text(lang('enable_sync'));
$('#google-sync').prop('disabled', true); $('#google-sync').prop('disabled', true);
$('#select-filter-item option:selected').attr('google-sync', 'false'); $('#select-filter-item option:selected').attr('google-sync', 'false');
@ -112,7 +112,7 @@ App.Utils.CalendarGoogleSync = (function () {
} }
]; ];
App.Utils.Message.show(App.Lang.disable_sync, App.Lang.disable_sync_prompt, buttons); App.Utils.Message.show(lang('disable_sync'), lang('disable_sync_prompt'), buttons);
} }
}); });
@ -125,7 +125,7 @@ App.Utils.CalendarGoogleSync = (function () {
const calendarId = $('#google-calendar').val(); const calendarId = $('#google-calendar').val();
App.Http.Google.selectGoogleCalendar(providerId, calendarId).done(() => { App.Http.Google.selectGoogleCalendar(providerId, calendarId).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.google_calendar_selected); App.Layouts.Backend.displayNotification(lang('google_calendar_selected'));
$('#select-google-calendar').modal('hide'); $('#select-google-calendar').modal('hide');
}); });
}); });
@ -140,11 +140,11 @@ App.Utils.CalendarGoogleSync = (function () {
App.Http.Google.syncWithGoogle(providerId) App.Http.Google.syncWithGoogle(providerId)
.done(() => { .done(() => {
App.Layouts.Backend.displayNotification(App.Lang.google_sync_completed); App.Layouts.Backend.displayNotification(lang('google_sync_completed'));
$('#reload-appointments').trigger('click'); $('#reload-appointments').trigger('click');
}) })
.fail(() => { .fail(() => {
App.Layouts.Backend.displayNotification(App.Lang.google_sync_failed); App.Layouts.Backend.displayNotification(lang('google_sync_failed'));
}); });
}); });
} }

View file

@ -158,7 +158,7 @@ App.Utils.CalendarTableView = (function () {
App.Components.WorkingPlanExceptionsModal.edit(date, workingPlanException).done( App.Components.WorkingPlanExceptionsModal.edit(date, workingPlanException).done(
(date, workingPlanException) => { (date, workingPlanException) => {
const successCallback = () => { const successCallback = () => {
App.Layouts.Backend.displayNotification(App.Lang.working_plan_exception_saved); App.Layouts.Backend.displayNotification(lang('working_plan_exception_saved'));
const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {}; const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {};
@ -191,7 +191,7 @@ App.Utils.CalendarTableView = (function () {
BackendCalendarAppointmentsModal.resetAppointmentDialog(); BackendCalendarAppointmentsModal.resetAppointmentDialog();
// Apply appointment data and show modal dialog. // Apply appointment data and show modal dialog.
$appointmentsModal.find('.modal-header h3').text(App.Lang.edit_appointment_title); $appointmentsModal.find('.modal-header h3').text(lang('edit_appointment_title'));
$appointmentsModal.find('#appointment-id').val(appointment.id); $appointmentsModal.find('#appointment-id').val(appointment.id);
$appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change'); $appointmentsModal.find('#select-service').val(appointment.id_services).trigger('change');
$appointmentsModal.find('#select-provider').val(appointment.id_users_provider); $appointmentsModal.find('#select-provider').val(appointment.id_users_provider);
@ -274,7 +274,7 @@ App.Utils.CalendarTableView = (function () {
} else if (lastFocusedEventData.data.is_unavailable === '0') { } else if (lastFocusedEventData.data.is_unavailable === '0') {
const buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: lang('cancel'),
click: () => { click: () => {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -297,8 +297,8 @@ App.Utils.CalendarTableView = (function () {
]; ];
App.Utils.Message.show( App.Utils.Message.show(
App.Lang.delete_appointment_title, lang('delete_appointment_title'),
App.Lang.write_appointment_removal_reason, lang('write_appointment_removal_reason'),
buttons buttons
); );
@ -332,8 +332,8 @@ App.Utils.CalendarTableView = (function () {
$calendarFilter $calendarFilter
.find('select') .find('select')
.empty() .empty()
.append(new Option('1 ' + App.Lang.day, 1)) .append(new Option('1 ' + lang('day'), 1))
.append(new Option('3 ' + App.Lang.days, 3)); .append(new Option('3 ' + lang('days'), 3));
const $calendarHeader = $('<div/>', { const $calendarHeader = $('<div/>', {
'class': 'calendar-header' 'class': 'calendar-header'
@ -403,7 +403,7 @@ App.Utils.CalendarTableView = (function () {
// Create providers and service filters. // Create providers and service filters.
$('<label/>', { $('<label/>', {
'text': App.Lang.provider 'text': lang('provider')
}).appendTo($calendarHeader); }).appendTo($calendarHeader);
$filterProvider = $('<select/>', { $filterProvider = $('<select/>', {
@ -442,7 +442,7 @@ App.Utils.CalendarTableView = (function () {
}); });
$('<label/>', { $('<label/>', {
'text': App.Lang.service 'text': lang('service')
}).appendTo($calendarHeader); }).appendTo($calendarHeader);
$filterService = $('<select/>', { $filterService = $('<select/>', {
@ -749,67 +749,67 @@ App.Utils.CalendarTableView = (function () {
// Translations // Translations
monthNames: [ monthNames: [
App.Lang.january, lang('january'),
App.Lang.february, lang('february'),
App.Lang.march, lang('march'),
App.Lang.april, lang('april'),
App.Lang.may, lang('may'),
App.Lang.june, lang('june'),
App.Lang.july, lang('july'),
App.Lang.august, lang('august'),
App.Lang.september, lang('september'),
App.Lang.october, lang('october'),
App.Lang.november, lang('november'),
App.Lang.december lang('december')
], ],
monthNamesShort: [ monthNamesShort: [
App.Lang.january.substr(0, 3), lang('january').substr(0, 3),
App.Lang.february.substr(0, 3), lang('february').substr(0, 3),
App.Lang.march.substr(0, 3), lang('march').substr(0, 3),
App.Lang.april.substr(0, 3), lang('april').substr(0, 3),
App.Lang.may.substr(0, 3), lang('may').substr(0, 3),
App.Lang.june.substr(0, 3), lang('june').substr(0, 3),
App.Lang.july.substr(0, 3), lang('july').substr(0, 3),
App.Lang.august.substr(0, 3), lang('august').substr(0, 3),
App.Lang.september.substr(0, 3), lang('september').substr(0, 3),
App.Lang.october.substr(0, 3), lang('october').substr(0, 3),
App.Lang.november.substr(0, 3), lang('november').substr(0, 3),
App.Lang.december.substr(0, 3) lang('december').substr(0, 3)
], ],
dayNames: [ dayNames: [
App.Lang.sunday, lang('sunday'),
App.Lang.monday, lang('monday'),
App.Lang.tuesday, lang('tuesday'),
App.Lang.wednesday, lang('wednesday'),
App.Lang.thursday, lang('thursday'),
App.Lang.friday, lang('friday'),
App.Lang.saturday lang('saturday')
], ],
dayNamesShort: [ dayNamesShort: [
App.Lang.sunday.substr(0, 3), lang('sunday').substr(0, 3),
App.Lang.monday.substr(0, 3), lang('monday').substr(0, 3),
App.Lang.tuesday.substr(0, 3), lang('tuesday').substr(0, 3),
App.Lang.wednesday.substr(0, 3), lang('wednesday').substr(0, 3),
App.Lang.thursday.substr(0, 3), lang('thursday').substr(0, 3),
App.Lang.friday.substr(0, 3), lang('friday').substr(0, 3),
App.Lang.saturday.substr(0, 3) lang('saturday').substr(0, 3)
], ],
dayNamesMin: [ dayNamesMin: [
App.Lang.sunday.substr(0, 2), lang('sunday').substr(0, 2),
App.Lang.monday.substr(0, 2), lang('monday').substr(0, 2),
App.Lang.tuesday.substr(0, 2), lang('tuesday').substr(0, 2),
App.Lang.wednesday.substr(0, 2), lang('wednesday').substr(0, 2),
App.Lang.thursday.substr(0, 2), lang('thursday').substr(0, 2),
App.Lang.friday.substr(0, 2), lang('friday').substr(0, 2),
App.Lang.saturday.substr(0, 2) lang('saturday').substr(0, 2)
], ],
buttonText: { buttonText: {
today: App.Lang.today, today: lang('today'),
day: App.Lang.day, day: lang('day'),
week: App.Lang.week, week: lang('week'),
month: App.Lang.month, month: lang('month'),
agendaDay: App.Lang.calendar, agendaDay: lang('calendar'),
listDay: App.Lang.list listDay: lang('list')
}, },
// Calendar events need to be declared on initialization. // Calendar events need to be declared on initialization.
@ -847,7 +847,7 @@ App.Utils.CalendarTableView = (function () {
const workingPlanExceptionEnd = selDayDate + ' ' + workingPlan[selDayName].end; const workingPlanExceptionEnd = selDayDate + ' ' + workingPlan[selDayName].end;
const workingPlanExceptionEvent = { const workingPlanExceptionEvent = {
title: App.Lang.working_plan_exception, title: lang('working_plan_exception'),
start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true), start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true),
end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'), end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true, allDay: true,
@ -866,7 +866,7 @@ App.Utils.CalendarTableView = (function () {
if (workingPlan[selDayName] === null) { if (workingPlan[selDayName] === null) {
const nonWorkingDay = { const nonWorkingDay = {
title: App.Lang.not_working, title: lang('not_working'),
start: start, start: start,
end: end, end: end,
allDay: false, allDay: false,
@ -886,7 +886,7 @@ App.Utils.CalendarTableView = (function () {
if (start < workDateStart) { if (start < workDateStart) {
unavailablePeriod = { unavailablePeriod = {
title: App.Lang.not_working, title: lang('not_working'),
start: start, start: start,
end: workDateStart, end: workDateStart,
allDay: false, allDay: false,
@ -903,7 +903,7 @@ App.Utils.CalendarTableView = (function () {
if (end > workDateEnd) { if (end > workDateEnd) {
const unavailablePeriod = { const unavailablePeriod = {
title: App.Lang.not_working, title: lang('not_working'),
start: workDateEnd, start: workDateEnd,
end: end, end: end,
allDay: false, allDay: false,
@ -924,7 +924,7 @@ App.Utils.CalendarTableView = (function () {
breakEnd = moment(start.format('YYYY-MM-DD') + ' ' + currentBreak.end); breakEnd = moment(start.format('YYYY-MM-DD') + ' ' + currentBreak.end);
const unavailablePeriod = { const unavailablePeriod = {
title: App.Lang.break, title: lang('break'),
start: breakStart, start: breakStart,
end: breakEnd, end: breakEnd,
allDay: false, allDay: false,
@ -1008,7 +1008,7 @@ App.Utils.CalendarTableView = (function () {
} }
const event = { const event = {
title: App.Lang.unavailable, title: lang('unavailable'),
start: moment(unavailability.start_datetime), start: moment(unavailability.start_datetime),
end: moment(unavailability.end_datetime), end: moment(unavailability.end_datetime),
allDay: false, allDay: false,
@ -1062,7 +1062,7 @@ App.Utils.CalendarTableView = (function () {
}); });
$event.html( $event.html(
App.Lang.break + lang('break') +
' <span class="hour">' + ' <span class="hour">' +
moment(eventDate).format('HH:mm') + moment(eventDate).format('HH:mm') +
'</span> (' + '</span> (' +
@ -1154,7 +1154,7 @@ App.Utils.CalendarTableView = (function () {
$html = $('<div/>', { $html = $('<div/>', {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1167,7 +1167,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1180,7 +1180,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.notes 'text': lang('notes')
}), }),
$('<span/>', { $('<span/>', {
'text': getEventNotes(event) 'text': getEventNotes(event)
@ -1199,7 +1199,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -1210,7 +1210,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -1221,7 +1221,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -1249,7 +1249,7 @@ App.Utils.CalendarTableView = (function () {
$html = $('<div/>', { $html = $('<div/>', {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'text': App.Lang.provider 'text': lang('provider')
}), }),
$('<span/>', { $('<span/>', {
'text': event.data ? event.data.provider.first_name + ' ' + event.data.provider.last_name : '-' 'text': event.data ? event.data.provider.first_name + ' ' + event.data.provider.last_name : '-'
@ -1257,7 +1257,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1270,7 +1270,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1283,7 +1283,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.timezone 'text': lang('timezone')
}), }),
$('<span/>', { $('<span/>', {
'text': vars('timezones')[event.data.provider.timezone] 'text': vars('timezones')[event.data.provider.timezone]
@ -1302,7 +1302,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -1313,7 +1313,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -1324,7 +1324,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -1339,7 +1339,7 @@ App.Utils.CalendarTableView = (function () {
$html = $('<div/>', { $html = $('<div/>', {
'html': [ 'html': [
$('<strong/>', { $('<strong/>', {
'text': App.Lang.start 'text': lang('start')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1352,7 +1352,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.end 'text': lang('end')
}), }),
$('<span/>', { $('<span/>', {
'text': App.Utils.Date.format( 'text': App.Utils.Date.format(
@ -1365,7 +1365,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.timezone 'text': lang('timezone')
}), }),
$('<span/>', { $('<span/>', {
'text': vars('timezones')[event.data.provider.timezone] 'text': vars('timezones')[event.data.provider.timezone]
@ -1373,7 +1373,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.service 'text': lang('service')
}), }),
$('<span/>', { $('<span/>', {
'text': event.data.service.name 'text': event.data.service.name
@ -1381,7 +1381,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.provider 'text': lang('provider')
}), }),
App.Utils.CalendarEventPopover.renderMapIcon(event.data.provider), App.Utils.CalendarEventPopover.renderMapIcon(event.data.provider),
$('<span/>', { $('<span/>', {
@ -1390,7 +1390,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.customer 'text': lang('customer')
}), }),
App.Utils.CalendarEventPopover.renderMapIcon(event.data.customer), App.Utils.CalendarEventPopover.renderMapIcon(event.data.customer),
$('<span/>', { $('<span/>', {
@ -1399,7 +1399,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.email 'text': lang('email')
}), }),
App.Utils.CalendarEventPopover.renderMailIcon(event.data.customer.email), App.Utils.CalendarEventPopover.renderMailIcon(event.data.customer.email),
$('<span/>', { $('<span/>', {
@ -1408,7 +1408,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.phone 'text': lang('phone')
}), }),
App.Utils.CalendarEventPopover.renderPhoneIcon(event.data.customer.phone_number), App.Utils.CalendarEventPopover.renderPhoneIcon(event.data.customer.phone_number),
$('<span/>', { $('<span/>', {
@ -1417,7 +1417,7 @@ App.Utils.CalendarTableView = (function () {
$('<br/>'), $('<br/>'),
$('<strong/>', { $('<strong/>', {
'text': App.Lang.notes 'text': lang('notes')
}), }),
$('<span/>', { $('<span/>', {
'text': getEventNotes(event) 'text': getEventNotes(event)
@ -1436,7 +1436,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-ban me-2' 'class': 'fas fa-ban me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.close 'text': lang('close')
}) })
] ]
}), }),
@ -1447,7 +1447,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-trash-alt me-2' 'class': 'fas fa-trash-alt me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.delete 'text': lang('delete')
}) })
] ]
}), }),
@ -1458,7 +1458,7 @@ App.Utils.CalendarTableView = (function () {
'class': 'fas fa-edit me-2' 'class': 'fas fa-edit me-2'
}), }),
$('<span/>', { $('<span/>', {
'text': App.Lang.edit 'text': lang('edit')
}) })
] ]
}) })
@ -1498,7 +1498,7 @@ App.Utils.CalendarTableView = (function () {
function onEventResize(event, delta, revertFunc) { function onEventResize(event, delta, revertFunc) {
if (vars('privileges').appointments.edit === false) { if (vars('privileges').appointments.edit === false) {
revertFunc(); revertFunc();
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments); App.Layouts.Backend.displayNotification(lang('no_privileges_edit_appointments'));
return; return;
} }
@ -1540,9 +1540,9 @@ App.Utils.CalendarTableView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.appointment_updated, [ App.Layouts.Backend.displayNotification(lang('appointment_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -1580,9 +1580,9 @@ App.Utils.CalendarTableView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.unavailable_updated, [ App.Layouts.Backend.displayNotification(lang('unavailable_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -1606,7 +1606,7 @@ App.Utils.CalendarTableView = (function () {
function onEventDrop(event, delta, revertFunc) { function onEventDrop(event, delta, revertFunc) {
if (vars('privileges').appointments.edit === false) { if (vars('privileges').appointments.edit === false) {
revertFunc(); revertFunc();
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments); App.Layouts.Backend.displayNotification(lang('no_privileges_edit_appointments'));
return; return;
} }
@ -1660,9 +1660,9 @@ App.Utils.CalendarTableView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.appointment_updated, [ App.Layouts.Backend.displayNotification(lang('appointment_updated'), [
{ {
'label': App.Lang.undo, 'label': lang('undo'),
'function': undoFunction 'function': undoFunction
} }
]); ]);
@ -1701,9 +1701,9 @@ App.Utils.CalendarTableView = (function () {
revertFunc(); revertFunc();
}; };
App.Layouts.Backend.displayNotification(App.Lang.unavailable_updated, [ App.Layouts.Backend.displayNotification(lang('unavailable_updated'), [
{ {
label: App.Lang.undo, label: lang('undo'),
function: undoFunction function: undoFunction
} }
]); ]);

View file

@ -50,7 +50,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
if (!buttons) { if (!buttons) {
buttons = [ buttons = [
{ {
text: App.Lang.close, text: lang('close'),
click: function () { click: function () {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }
@ -284,7 +284,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
return; return;
} }
GeneralFunctions.displayMessageBox(App.Lang.unexpected_issues, App.Lang.unexpected_issues_message); GeneralFunctions.displayMessageBox(lang('unexpected_issues'), lang('unexpected_issues_message'));
$('<div/>', { $('<div/>', {
'class': 'card', 'class': 'card',

View file

@ -29,7 +29,7 @@ window.App.Utils.Message = (function () {
if (!buttons) { if (!buttons) {
buttons = [ buttons = [
{ {
text: App.Lang.close, text: lang('close'),
click: function () { click: function () {
$('#message-box').dialog('close'); $('#message-box').dialog('close');
} }

View file

@ -135,7 +135,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-break', 'class': 'btn btn-outline-secondary btn-sm edit-break',
'title': App.Lang.edit, 'title': lang('edit'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-edit' 'class': 'fas fa-edit'
@ -145,7 +145,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-break', 'class': 'btn btn-outline-secondary btn-sm delete-break',
'title': App.Lang.delete, 'title': lang('delete'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-trash-alt' 'class': 'fas fa-trash-alt'
@ -155,7 +155,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm save-break d-none', 'class': 'btn btn-outline-secondary btn-sm save-break d-none',
'title': App.Lang.save, 'title': lang('save'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-check-circle' 'class': 'fas fa-check-circle'
@ -165,7 +165,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm cancel-break d-none', 'class': 'btn btn-outline-secondary btn-sm cancel-break d-none',
'title': App.Lang.cancel, 'title': lang('cancel'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-ban' 'class': 'fas fa-ban'
@ -212,13 +212,13 @@ App.Utils.WorkingPlan = (function () {
*/ */
editableDayCell($selector) { editableDayCell($selector) {
const weekDays = {}; const weekDays = {};
weekDays[App.Lang.sunday] = App.Lang.sunday; //'Sunday'; weekDays[lang('sunday')] = lang('sunday'); //'Sunday';
weekDays[App.Lang.monday] = App.Lang.monday; //'Monday'; weekDays[lang('monday')] = lang('monday'); //'Monday';
weekDays[App.Lang.tuesday] = App.Lang.tuesday; //'Tuesday'; weekDays[lang('tuesday')] = lang('tuesday'); //'Tuesday';
weekDays[App.Lang.wednesday] = App.Lang.wednesday; //'Wednesday'; weekDays[lang('wednesday')] = lang('wednesday'); //'Wednesday';
weekDays[App.Lang.thursday] = App.Lang.thursday; //'Thursday'; weekDays[lang('thursday')] = lang('thursday'); //'Thursday';
weekDays[App.Lang.friday] = App.Lang.friday; //'Friday'; weekDays[lang('friday')] = lang('friday'); //'Friday';
weekDays[App.Lang.saturday] = App.Lang.saturday; //'Saturday'; weekDays[lang('saturday')] = lang('saturday'); //'Saturday';
$selector.editable( $selector.editable(
function (value) { function (value) {
@ -264,12 +264,12 @@ App.Utils.WorkingPlan = (function () {
submit: $('<button/>', { submit: $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'd-none submit-editable', 'class': 'd-none submit-editable',
'text': App.Lang.save 'text': lang('save')
}).get(0).outerHTML, }).get(0).outerHTML,
cancel: $('<button/>', { cancel: $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'd-none cancel-editable', 'class': 'd-none cancel-editable',
'text': App.Lang.cancel 'text': lang('cancel')
}).get(0).outerHTML, }).get(0).outerHTML,
onblur: 'ignore', onblur: 'ignore',
onreset: function () { onreset: function () {
@ -319,7 +319,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-working-plan-exception', 'class': 'btn btn-outline-secondary btn-sm edit-working-plan-exception',
'title': App.Lang.edit, 'title': lang('edit'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-edit' 'class': 'fas fa-edit'
@ -329,7 +329,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-working-plan-exception', 'class': 'btn btn-outline-secondary btn-sm delete-working-plan-exception',
'title': App.Lang.delete, 'title': lang('delete'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-trash-alt' 'class': 'fas fa-trash-alt'
@ -385,7 +385,7 @@ App.Utils.WorkingPlan = (function () {
'html': [ 'html': [
$('<td/>', { $('<td/>', {
'class': 'break-day editable', 'class': 'break-day editable',
'text': App.Lang.sunday 'text': lang('sunday')
}), }),
$('<td/>', { $('<td/>', {
'class': 'break-start editable', 'class': 'break-start editable',
@ -400,7 +400,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-break', 'class': 'btn btn-outline-secondary btn-sm edit-break',
'title': App.Lang.edit, 'title': lang('edit'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-edit' 'class': 'fas fa-edit'
@ -410,7 +410,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-break', 'class': 'btn btn-outline-secondary btn-sm delete-break',
'title': App.Lang.delete, 'title': lang('delete'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-trash-alt' 'class': 'fas fa-trash-alt'
@ -420,7 +420,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm save-break d-none', 'class': 'btn btn-outline-secondary btn-sm save-break d-none',
'title': App.Lang.save, 'title': lang('save'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-check-circle' 'class': 'fas fa-check-circle'
@ -430,7 +430,7 @@ App.Utils.WorkingPlan = (function () {
$('<button/>', { $('<button/>', {
'type': 'button', 'type': 'button',
'class': 'btn btn-outline-secondary btn-sm cancel-break d-none', 'class': 'btn btn-outline-secondary btn-sm cancel-break d-none',
'title': App.Lang.cancel, 'title': lang('cancel'),
'html': [ 'html': [
$('<span/>', { $('<span/>', {
'class': 'fas fa-ban' 'class': 'fas fa-ban'
@ -472,12 +472,12 @@ App.Utils.WorkingPlan = (function () {
.find('.break-start input, .break-end input') .find('.break-start input, .break-end input')
.timepicker({ .timepicker({
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm', timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes minuteText: lang('minutes')
}); });
$(this).parent().parent().find('.break-day select').focus(); $(this).parent().parent().find('.break-day select').focus();
@ -703,12 +703,12 @@ App.Utils.WorkingPlan = (function () {
// Set timepickers where needed. // Set timepickers where needed.
$('.working-plan input:text').timepicker({ $('.working-plan input:text').timepicker({
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm', timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
currentText: App.Lang.now, currentText: lang('now'),
closeText: App.Lang.close, closeText: lang('close'),
timeOnlyTitle: App.Lang.select_time, timeOnlyTitle: lang('select_time'),
timeText: App.Lang.time, timeText: lang('time'),
hourText: App.Lang.hour, hourText: lang('hour'),
minuteText: App.Lang.minutes, minuteText: lang('minutes'),
onSelect: function () { onSelect: function () {
// Start time must be earlier than end time. // Start time must be earlier than end time.
@ -746,19 +746,19 @@ App.Utils.WorkingPlan = (function () {
convertValueToDay(value) { convertValueToDay(value) {
switch (value) { switch (value) {
case 'sunday': case 'sunday':
return App.Lang.sunday; return lang('sunday');
case 'monday': case 'monday':
return App.Lang.monday; return lang('monday');
case 'tuesday': case 'tuesday':
return App.Lang.tuesday; return lang('tuesday');
case 'wednesday': case 'wednesday':
return App.Lang.wednesday; return lang('wednesday');
case 'thursday': case 'thursday':
return App.Lang.thursday; return lang('thursday');
case 'friday': case 'friday':
return App.Lang.friday; return lang('friday');
case 'saturday': case 'saturday':
return App.Lang.saturday; return lang('saturday');
} }
} }
/** /**
@ -768,19 +768,19 @@ App.Utils.WorkingPlan = (function () {
*/ */
convertDayToValue(day) { convertDayToValue(day) {
switch (day) { switch (day) {
case App.Lang.sunday: case lang('sunday'):
return 'sunday'; return 'sunday';
case App.Lang.monday: case lang('monday'):
return 'monday'; return 'monday';
case App.Lang.tuesday: case lang('tuesday'):
return 'tuesday'; return 'tuesday';
case App.Lang.wednesday: case lang('wednesday'):
return 'wednesday'; return 'wednesday';
case App.Lang.thursday: case lang('thursday'):
return 'thursday'; return 'thursday';
case App.Lang.friday: case lang('friday'):
return 'friday'; return 'friday';
case App.Lang.saturday: case lang('saturday'):
return 'saturday'; return 'saturday';
} }
} }