diff --git a/application/views/layouts/account_layout.php b/application/views/layouts/account_layout.php index 923acb6c..50de3213 100644 --- a/application/views/layouts/account_layout.php +++ b/application/views/layouts/account_layout.php @@ -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> diff --git a/application/views/layouts/booking_layout.php b/application/views/layouts/booking_layout.php index ad61676c..a42be7a4 100644 --- a/application/views/layouts/booking_layout.php +++ b/application/views/layouts/booking_layout.php @@ -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') ?> diff --git a/application/views/pages/booking.php b/application/views/pages/booking.php index 39a794a1..7fcf0cd1 100755 --- a/application/views/pages/booking.php +++ b/application/views/pages/booking.php @@ -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> diff --git a/assets/js/components/working_plan_exceptions_modal.js b/assets/js/components/working_plan_exceptions_modal.js index a9cd3c6f..c8e9cef6 100644 --- a/assets/js/components/working_plan_exceptions_modal.js +++ b/assets/js/components/working_plan_exceptions_modal.js @@ -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: [ diff --git a/assets/js/layouts/account_layout.js b/assets/js/layouts/account_layout.js index ce14b2dc..116e0fe9 100644 --- a/assets/js/layouts/account_layout.js +++ b/assets/js/layouts/account_layout.js @@ -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 {}; })(); diff --git a/assets/js/layouts/backend_layout.js b/assets/js/layouts/backend_layout.js index 1e73e61d..61645915 100644 --- a/assets/js/layouts/backend_layout.js +++ b/assets/js/layouts/backend_layout.js @@ -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); diff --git a/assets/js/layouts/booking_layout.js b/assets/js/layouts/booking_layout.js index 9a4d6c65..c5bfab33 100644 --- a/assets/js/layouts/booking_layout.js +++ b/assets/js/layouts/booking_layout.js @@ -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 {}; })(); diff --git a/assets/js/pages/booking.js b/assets/js/pages/booking.js index 2556bee5..7459e392 100644 --- a/assets/js/pages/booking.js +++ b/assets/js/pages/booking.js @@ -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); }