From 80e77ad8a0c5b53f9edbf746ae7fec19d1d6861c Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 20 Dec 2021 09:16:57 +0100 Subject: [PATCH] Removed unnecessary files --- assets/img/eye-hidden.svg | 1 - assets/img/eye.svg | 1 - .../js/pages/backend_settings_client_form.js | 165 ------------------ .../backend_settings_client_form_helper.js | 162 ----------------- 4 files changed, 329 deletions(-) delete mode 100644 assets/img/eye-hidden.svg delete mode 100644 assets/img/eye.svg delete mode 100644 assets/js/pages/backend_settings_client_form.js delete mode 100644 assets/js/pages/backend_settings_client_form_helper.js diff --git a/assets/img/eye-hidden.svg b/assets/img/eye-hidden.svg deleted file mode 100644 index e69c69b1..00000000 --- a/assets/img/eye-hidden.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/img/eye.svg b/assets/img/eye.svg deleted file mode 100644 index 74fd7b3e..00000000 --- a/assets/img/eye.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/js/pages/backend_settings_client_form.js b/assets/js/pages/backend_settings_client_form.js deleted file mode 100644 index 89ce61ca..00000000 --- a/assets/js/pages/backend_settings_client_form.js +++ /dev/null @@ -1,165 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) Alex Tselegidis - * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link https://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -window.BackendSettingsClientForm = window.BackendSettingsClientForm || {}; - -/** - * Backend Settings - * - * Contains the functionality of the backend settings page. Can either work for system or user settings, - * but the actions allowed to the user are restricted to his role (only admin has full privileges). - * - * @module BackendSettingsClientForm - */ -(function (exports) { - 'use strict'; - - // Constants - exports.SETTINGS_SYSTEM = 'SETTINGS_SYSTEM'; - - /** - * Tab settings object. - * - * @type {Object} - */ - var settings = {}; - - /** - * Initialize Page - * - * @param {bool} defaultEventHandlers Optional (true), determines whether to bind the default event handlers. - */ - exports.initialize = function (defaultEventHandlers) { - defaultEventHandlers = defaultEventHandlers || true; - - // Apply setting values from database. - GlobalVariables.settings.system.forEach(function (setting) { - $('input[data-field="' + setting.name + '"]').val(setting.value); - $('select[data-field="' + setting.name + '"]').val(setting.value); - - if (setting.name === 'customer_notifications') { - $('#customer-notifications').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_captcha') { - $('#require-captcha').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'require_phone_number') { - $('#require-phone-number').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_any_provider') { - $('#display-any-provider').prop('checked', Boolean(Number(setting.value))); - } - - if (setting.name === 'display_cookie_notice') { - $('#display-cookie-notice').prop('checked', Boolean(Number(setting.value))); - } - }); - - // Set default settings helper. - settings = new SystemSettingsClientFormHelper(); - - if (defaultEventHandlers) { - bindEventHandlers(); - } - - Backend.placeFooterToBottom(); - }; - - /** - * Bind the backend/settings default event handlers. - * - * This method depends on the backend/settings html, so do not use this method on a different page. - */ - function bindEventHandlers() { - /** - * Event: Save Settings Button "Click" - * - * Store the setting changes into the database. - */ - $('.save-settings').on('click', function () { - var data = settings.get(); - settings.save(data); - }); - - /** - * Event: Visible/Hidden button "Click" - * - * Change the state of the Visible/Hidden button - */ - $('.hide-toggle').on('click', function () { - var $target = $(this); - - $target.find('span').each(function (index, span) { - var $span = $(span); - - var isHidden = $span.prop('hidden'); - - $span.prop('hidden', !isHidden); - }); - }); - - /** - * Set a Visible/Hidden toggle button to a certain state. - * - * @param {jQuery} $target Target element selector. - * @param {Boolean} isVisible a boolean which is true if the button should display 'visible' and false when the button should display 'hidden' - */ - function setShowToggleValue($target, isVisible) { - if (getShowToggleValue($target) !== isVisible) { - $target.find('span').each(function (index, span) { - var $span = $(span); - - var isHidden = $span.prop('hidden'); - - $span.prop('hidden', !isHidden); - }); - } - } - - /** - * Get the Visible/Hidden toggle button - * - * @param {jQuery} $target Target element selector. - * - * @return the state of the button. True for visible, false for hidden. - */ - function getShowToggleValue($target) { - var visiblePartArray = $target.find('.hide-toggle-visible'); - return !visiblePartArray.prop('hidden'); - } - - /** - * Event: require phone number switch "Click" - * - * make sure that our phone number is visible when it is required. - */ - $('#show-phone-number').on('click', function () { - if (!getShowToggleValue($(this))) { - //if button is set to hidden - $('#require-phone-number').prop('checked', false); - } - }); - - /** - * Event: require phone number switch "Click" - * - * make sure that our phone number is visible when it is required. - */ - $('#require-phone-number').on('click', function () { - if ($(this).prop('checked')) { - setShowToggleValue($('#show-phone-number'), true); - } - }); - } -})(window.BackendSettingsClientForm); diff --git a/assets/js/pages/backend_settings_client_form_helper.js b/assets/js/pages/backend_settings_client_form_helper.js deleted file mode 100644 index f8cecaaf..00000000 --- a/assets/js/pages/backend_settings_client_form_helper.js +++ /dev/null @@ -1,162 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Easy!Appointments - Open Source Web Scheduler - * - * @package EasyAppointments - * @author A.Tselegidis - * @copyright Copyright (c) Alex Tselegidis - * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link https://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -(function () { - 'use strict'; - - /** - * "System Settings" Tab Helper Class - * - * @class SystemSettingsClientFormHelper - */ - var SystemSettingsClientFormHelper = function () {}; - - /** - * Save the system settings. - * - * This method is run after changes are detected on the tab input fields. - * - * @param {Array} settings Contains the system settings data. - */ - SystemSettingsClientFormHelper.prototype.save = function (settings) { - if (!this.validate()) { - return; // Validation failed, do not proceed. - } - - var url = GlobalVariables.baseUrl + '/index.php/settings/client_form/save'; - - var data = { - csrf_token: GlobalVariables.csrfToken, - settings: JSON.stringify(settings), - type: BackendSettingsClientForm.SETTINGS_SYSTEM - }; - - $.post(url, data).done(function () { - Backend.displayNotification(App.Lang.settings_saved); - }); - }; - - /** - * Get the state of a visible/hidden toggle button - * - * This method uses the DOM elements of the backend/settings page, so it can't be used in another page. - * - * @argument the element jquery of a button object that is a visible/hidden toggle. - * - * @return '0' when the button shows 'invisible' and '1' when the button shows 'visible'. Will always return '0' on an error. - */ - function getToggleButtonState($element) { - var visiblePartArray = $element.find('.hide-toggle-visible'); - var invisiblePartArray = $element.find('.hide-toggle-hidden'); - if (!(visiblePartArray.length === 0 || invisiblePartArray.length === 0)) { - if (visiblePartArray.prop('hidden')) { - //our button is currently invisible - return '0'; //invisible - } else { - //our button is currently visible - return '1'; //visible - } - } else { - return '0'; //invisible - } - } - - /** - * Prepare the system settings array. - * - * This method uses the DOM elements of the backend/settings page, so it can't be used in another page. - * - * @return {Array} Returns the system settings array. - */ - SystemSettingsClientFormHelper.prototype.get = function () { - var settings = []; - - settings.push({ - name: 'customer_notifications', - value: $('#customer-notifications').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_captcha', - value: $('#require-captcha').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'require_phone_number', - value: $('#require-phone-number').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'display_any_provider', - value: $('#display-any-provider').prop('checked') ? '1' : '0' - }); - - settings.push({ - name: 'show_phone_number', - value: getToggleButtonState($('#show-phone-number')) - }); - - settings.push({ - name: 'show_address', - value: getToggleButtonState($('#show-address')) - }); - - settings.push({ - name: 'show_city', - value: getToggleButtonState($('#show-city')) - }); - - settings.push({ - name: 'show_zip_code', - value: getToggleButtonState($('#show-zip-code')) - }); - - settings.push({ - name: 'show_notes', - value: getToggleButtonState($('#show-notes')) - }); - - return settings; - }; - - /** - * Validate the settings data. - * - * If the validation fails then display a message to the user. - * - * @return {Boolean} Returns the validation result. - */ - SystemSettingsClientFormHelper.prototype.validate = function () { - $('#client-form .is-invalid').removeClass('is-invalid'); - - try { - // Validate required fields. - var missingRequired = false; - $('#client-form .required').each(function (index, requiredField) { - if (!$(requiredField).val()) { - $(requiredField).addClass('is-invalid'); - missingRequired = true; - } - }); - - if (missingRequired) { - throw new Error(App.Lang.fields_are_required); - } - - return true; - } catch (error) { - Backend.displayNotification(error.message); - return false; - } - }; - - window.SystemSettingsClientFormHelper = SystemSettingsClientFormHelper; -})();