The layout modules will initialize the language selection on their own.

This commit is contained in:
Alex Tselegidis 2022-01-17 17:54:30 +01:00
parent 1986438357
commit 46f0a27998
8 changed files with 46 additions and 42 deletions

View file

@ -12,9 +12,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#35A768">
<?php slot('meta') ?>
<title><?= lang('login') ?> | Easy!Appointments</title>
<link rel="icon" type="image/x-icon" href="<?= asset_url('assets/img/favicon.ico') ?>">
@ -24,12 +24,12 @@
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/bootstrap.css') ?>">
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/general.css') ?>">
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/layouts/account_layout.css') ?>">
<?php slot('styles') ?>
</head>
<body>
<div id="login-frame" class="frame-container">
<?php slot('content') ?>
<div class="mt-4">
@ -51,28 +51,15 @@
<script src="<?= asset_url('assets/vendor/@fortawesome-fontawesome-free/solid.min.js') ?>"></script>
<script src="<?= asset_url('assets/js/app.js') ?>"></script>
<script src="<?= asset_url('assets/js/layouts/account_layout.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/url.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/lang.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/general_functions.js') ?>"></script>
<script src="<?= asset_url('assets/js/layouts/account_layout.js') ?>"></script>
<script src="<?= asset_url('assets/js/http/account_http_client.js') ?>"></script>
<?php component('js_vars_script') ?>
<?php component('js_lang_script') ?>
<script>
const GlobalVariables = {
csrfToken: <?= json_encode($this->security->get_csrf_hash()) ?>,
baseUrl: <?= json_encode($base_url) ?>,
destUrl: <?= json_encode($dest_url ?? '') ?>,
AJAX_SUCCESS: 'SUCCESS',
AJAX_FAILURE: 'FAILURE'
};
const availableLanguages = <?= json_encode(config('available_languages')) ?>;
$(function () {
GeneralFunctions.enableLanguageSelection($('#select-language'));
});
</script>
<?php slot('scripts') ?>
</body>

View file

@ -105,12 +105,6 @@
<?php component('js_vars_script') ?>
<?php component('js_lang_script') ?>
<script>
$(function () {
GeneralFunctions.enableLanguageSelection($('#select-language'));
});
</script>
<?php google_analytics_script() ?>
<?php slot('scripts') ?>

View file

@ -46,11 +46,12 @@
<?php section('content') ?>
<?php section('scripts') ?>
<script src="<?= asset_url('assets/js/utils/date.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/lang.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/message.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/string.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/validation.js') ?>"></script>
<script src="<?= asset_url('assets/js/utils/url.js') ?>"></script>
<script src="<?= asset_url('assets/js/http/booking_http_client.js') ?>"></script>

View file

@ -413,7 +413,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
$target.datepicker({
dateFormat: dateFormat,
firstDay: GeneralFunctions.getWeekDayId(App.Vars.first_weekday),
firstDay: App.Utils.Date.getWeekdayId(App.Vars.first_weekday),
minDate: 0,
defaultDate: moment().toDate(),
dayNames: [

View file

@ -15,5 +15,16 @@
* This module implements the account layout functionality.
*/
window.App.Layouts.Account = (function () {
const $selectLanguage = $('#select-language');
/**
* Initialize the module.
*/
function initialize() {
App.Utils.Lang.enableLanguageSelection($selectLanguage);
}
document.addEventListener('DOMContentLoaded', initialize);
return {};
})();

View file

@ -119,7 +119,7 @@ window.App.Layouts.Backend = (function () {
tippy('[data-tippy-content]');
GeneralFunctions.enableLanguageSelection($selectLanguage);
App.Utils.Lang.enableLanguageSelection($selectLanguage);
}
document.addEventListener('DOMContentLoaded', initialize);

View file

@ -15,5 +15,16 @@
* This module implements the booking layout functionality.
*/
window.App.Layouts.Booking = (function () {
const $selectLanguage = $('#select-language');
/**
* Initialize the module.
*/
function initialize() {
App.Utils.Lang.enableLanguageSelection($selectLanguage);
}
document.addEventListener('DOMContentLoaded', initialize);
return {};
})();

View file

@ -94,7 +94,7 @@ App.Pages.Booking = (function () {
// Initialize page's components (tooltips, datepickers etc).
tippy('[data-tippy-content]');
const weekDayId = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
const weekDayId = App.Utils.Date.getWeekdayId(GlobalVariables.firstWeekday);
$selectDate.datepicker({
dateFormat: 'dd-mm-yy',
@ -178,7 +178,7 @@ App.Pages.Booking = (function () {
);
} else {
// Check if a specific service was selected (via URL parameter).
const selectedServiceId = GeneralFunctions.getUrlParameter(location.href, 'service');
const selectedServiceId = App.Utils.Url.queryParam('service');
if (selectedServiceId && $selectService.find('option[value="' + selectedServiceId + '"]').length > 0) {
$selectService.val(selectedServiceId);
@ -187,7 +187,7 @@ App.Pages.Booking = (function () {
$selectService.trigger('change'); // Load the available hours.
// Check if a specific provider was selected.
const selectedProviderId = GeneralFunctions.getUrlParameter(location.href, 'provider');
const selectedProviderId = App.Utils.Url.queryParam('provider');
if (selectedProviderId && $selectProvider.find('option[value="' + selectedProviderId + '"]').length === 0) {
// Select a service of this provider in order to make the provider available in the select box.
@ -535,7 +535,7 @@ App.Pages.Booking = (function () {
}
// Validate email address.
if ($email.val() && !GeneralFunctions.validateEmail($email.val())) {
if ($email.val() && !App.Utils.Validation.email($email.val())) {
$email.parents('.form-group').addClass('is-invalid');
throw new Error(App.Lang.invalid_email);
}
@ -617,13 +617,13 @@ App.Pages.Booking = (function () {
}).appendTo('#appointment-details');
// Customer Details
const firstName = GeneralFunctions.escapeHtml($firstName.val());
const lastName = GeneralFunctions.escapeHtml($lastName.val());
const phoneNumber = GeneralFunctions.escapeHtml($phoneNumber.val());
const email = GeneralFunctions.escapeHtml($email.val());
const address = GeneralFunctions.escapeHtml($address.val());
const city = GeneralFunctions.escapeHtml($city.val());
const zipCode = GeneralFunctions.escapeHtml($zipCode.val());
const firstName = App.Utils.String.escapeHtml($firstName.val());
const lastName = App.Utils.String.escapeHtml($lastName.val());
const phoneNumber = App.Utils.String.escapeHtml($phoneNumber.val());
const email = App.Utils.String.escapeHtml($email.val());
const address = App.Utils.String.escapeHtml($address.val());
const city = App.Utils.String.escapeHtml($city.val());
const zipCode = App.Utils.String.escapeHtml($zipCode.val());
$('#customer-details').empty();
@ -804,7 +804,7 @@ App.Pages.Booking = (function () {
$('<br/>').appendTo($serviceDescription);
$('<span/>', {
'html': GeneralFunctions.escapeHtml(service.description).replaceAll('\n', '<br/>')
'html': App.Utils.String.escapeHtml(service.description).replaceAll('\n', '<br/>')
}).appendTo($serviceDescription);
}