From 185686d19450ad206800ef35c7de3bc89c860853 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 7 Sep 2020 11:36:36 +0300 Subject: [PATCH] Replaced custom toggle buttons with bootstrap switcher component. --- application/views/backend/settings.php | 58 ++++++++++++-------------- application/views/backend/users.php | 34 ++++++++------- assets/js/backend_settings.js | 22 +++++----- assets/js/backend_settings_system.js | 13 +++--- assets/js/backend_users_admins.js | 8 +--- assets/js/backend_users_providers.js | 8 +--- assets/js/backend_users_secretaries.js | 6 +-- 7 files changed, 70 insertions(+), 79 deletions(-) diff --git a/application/views/backend/settings.php b/application/views/backend/settings.php index 45801612..17d7771f 100755 --- a/application/views/backend/settings.php +++ b/application/views/backend/settings.php @@ -156,59 +156,53 @@
- - + +
- -
- +
+ + +
- -
- +
+ + +
- -
- +
+ + +
- -
- +
+ + +
diff --git a/application/views/backend/users.php b/application/views/backend/users.php index c509f04a..f9eae349 100755 --- a/application/views/backend/users.php +++ b/application/views/backend/users.php @@ -209,12 +209,14 @@
- +
+ + +
-

+

@@ -446,12 +448,14 @@
- +
+ + +
-

+

@@ -606,10 +610,12 @@
- +
+ + +
diff --git a/assets/js/backend_settings.js b/assets/js/backend_settings.js index dcc7db8b..154658aa 100644 --- a/assets/js/backend_settings.js +++ b/assets/js/backend_settings.js @@ -62,24 +62,24 @@ window.BackendSettings = window.BackendSettings || {}; workingPlan = $.parseJSON(setting.value); } - if (setting.name === 'customer_notifications' && setting.value === '1') { - $('#customer-notifications').addClass('active'); + if (setting.name === 'customer_notifications') { + $('#customer-notifications').prop('checked', Boolean(Number(setting.value))); } - if (setting.name === 'require_captcha' && setting.value === '1') { - $('#require-captcha').addClass('active'); + if (setting.name === 'require_captcha') { + $('#require-captcha').prop('checked', Boolean(Number(setting.value))); } - if (setting.name === 'require_phone_number' && setting.value === '1') { - $('#require-phone-number').addClass('active'); + if (setting.name === 'require_phone_number') { + $('#require-phone-number').prop('checked', Boolean(Number(setting.value))); } - if (setting.name === 'display_any_provider' && setting.value === '1') { - $('#display-any-provider').addClass('active'); + 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', setting.value === '1'); + $('#display-cookie-notice').prop('checked', Boolean(Number(setting.value))); } if (setting.name === 'cookie_notice_content') { @@ -87,7 +87,7 @@ window.BackendSettings = window.BackendSettings || {}; } if (setting.name === 'display_terms_and_conditions') { - $('#display-terms-and-conditions').prop('checked', setting.value === '1'); + $('#display-terms-and-conditions').prop('checked', Boolean(Number(setting.value))); } if (setting.name === 'terms_and_conditions_content') { @@ -95,7 +95,7 @@ window.BackendSettings = window.BackendSettings || {}; } if (setting.name === 'display_privacy_policy') { - $('#display-privacy-policy').prop('checked', setting.value === '1'); + $('#display-privacy-policy').prop('checked', Boolean(Number(setting.value))); } if (setting.name === 'privacy_policy_content') { diff --git a/assets/js/backend_settings_system.js b/assets/js/backend_settings_system.js index ac6d25b5..8adc993d 100644 --- a/assets/js/backend_settings_system.js +++ b/assets/js/backend_settings_system.js @@ -67,7 +67,8 @@ var settings = []; // General Settings Tab - $('#general').find('input, select').each(function (index, field) { + + $('#general').find('input, select').not('input:checkbox').each(function (index, field) { settings.push({ name: $(field).attr('data-field'), value: $(field).val() @@ -76,26 +77,27 @@ settings.push({ name: 'customer_notifications', - value: $('#customer-notifications').hasClass('active') ? '1' : '0' + value: $('#customer-notifications').prop('checked') ? '1' : '0' }); settings.push({ name: 'require_captcha', - value: $('#require-captcha').hasClass('active') ? '1' : '0' + value: $('#require-captcha').prop('checked') ? '1' : '0' }); settings.push({ name: 'require_phone_number', - value: $('#require-phone-number').hasClass('active') ? '1' : '0' + value: $('#require-phone-number').prop('checked') ? '1' : '0' }); settings.push({ name: 'display_any_provider', - value: $('#display-any-provider').hasClass('active') ? '1' : '0' + value: $('#display-any-provider').prop('checked') ? '1' : '0' }); // Business Logic Tab + settings.push({ name: 'company_working_plan', value: JSON.stringify(BackendSettings.wp.get()) @@ -107,6 +109,7 @@ }); // Legal Contents Tab + settings.push({ name: 'display_cookie_notice', value: $('#display-cookie-notice').prop('checked') ? '1' : '0' diff --git a/assets/js/backend_users_admins.js b/assets/js/backend_users_admins.js index 258d3cff..256ffc01 100644 --- a/assets/js/backend_users_admins.js +++ b/assets/js/backend_users_admins.js @@ -146,7 +146,7 @@ timezone: $('#admin-timezone').val(), settings: { username: $('#admin-username').val(), - notifications: $('#admin-notifications').hasClass('active'), + notifications: $('#admin-notifications').prop('checked'), calendar_view: $('#admin-calendar-view').val() } }; @@ -327,11 +327,7 @@ $('#admin-username').val(admin.settings.username); $('#admin-calendar-view').val(admin.settings.calendar_view); - if (admin.settings.notifications === true) { - $('#admin-notifications').addClass('active'); - } else { - $('#admin-notifications').removeClass('active'); - } + $('#admin-notifications').prop('checked', Boolean(Number(admin.settings.notifications))); }; /** diff --git a/assets/js/backend_users_providers.js b/assets/js/backend_users_providers.js index 3c7b6b62..f3548657 100755 --- a/assets/js/backend_users_providers.js +++ b/assets/js/backend_users_providers.js @@ -159,7 +159,7 @@ username: $('#provider-username').val(), working_plan: JSON.stringify(BackendUsers.wp.get()), extra_working_plan: JSON.stringify(BackendUsers.wp.getExtraWP()), - notifications: $('#provider-notifications').hasClass('active'), + notifications: $('#provider-notifications').prop('checked'), calendar_view: $('#provider-calendar-view').val() } }; @@ -391,11 +391,7 @@ $('#provider-username').val(provider.settings.username); $('#provider-calendar-view').val(provider.settings.calendar_view); - if (provider.settings.notifications === '1') { - $('#provider-notifications').addClass('active'); - } else { - $('#provider-notifications').removeClass('active'); - } + $('#provider-notifications').prop('checked', Boolean(Number(provider.settings.notifications))); // Add dedicated provider link. var dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id); diff --git a/assets/js/backend_users_secretaries.js b/assets/js/backend_users_secretaries.js index fa57f13d..830a8888 100644 --- a/assets/js/backend_users_secretaries.js +++ b/assets/js/backend_users_secretaries.js @@ -342,11 +342,7 @@ $('#secretary-username').val(secretary.settings.username); $('#secretary-calendar-view').val(secretary.settings.calendar_view); - if (secretary.settings.notifications === '1') { - $('#secretary-notifications').addClass('active'); - } else { - $('#secretary-notifications').removeClass('active'); - } + $('#secretary-notifications').prop('checked', Boolean(Number(secretary.settings.notifications))); $('#secretary-providers input:checkbox').prop('checked', false);