';
+ $.each(GlobalVariables.providers, function (index, provider) {
+ html +=
+ '
' +
+ '' +
+ '
';
+ });
+ html += '
';
+ $('#secretary-providers').html(html);
+ $('#secretary-providers input:checkbox').prop('disabled', true);
+ })
+ .fail(GeneralFunctions.ajaxFailureHandler);
}
helper.resetForm();
@@ -164,37 +168,40 @@ window.BackendUsers = window.BackendUsers || {};
$('#admin-username, #provider-username, #secretary-username').focusout(function () {
var $input = $(this);
- if ($input.prop('readonly') == true || $input.val() == '') {
+ if ($input.prop('readonly') === true || $input.val() === '') {
return;
}
var userId = $input.parents().eq(2).find('.record-id').val();
- if (userId == undefined) {
+ if (!userId) {
return;
}
- var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username';
- var postData = {
+ var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username';
+
+ var data = {
csrfToken: GlobalVariables.csrfToken,
username: $input.val(),
user_id: userId
};
- $.post(postUrl, postData, function (response) {
- if (response == false) {
- $input.closest('.form-group').addClass('has-error');
- $input.attr('already-exists', 'true');
- $input.parents().eq(3).find('.form-message').text(EALang.username_already_exists);
- $input.parents().eq(3).find('.form-message').show();
- } else {
- $input.closest('.form-group').removeClass('has-error');
- $input.attr('already-exists', 'false');
- if ($input.parents().eq(3).find('.form-message').text() == EALang.username_already_exists) {
- $input.parents().eq(3).find('.form-message').hide();
+ $.post(url, data)
+ .done(function (response) {
+ if (response === 'false') {
+ $input.closest('.form-group').addClass('has-error');
+ $input.attr('already-exists', 'true');
+ $input.parents().eq(3).find('.form-message').text(EALang.username_already_exists);
+ $input.parents().eq(3).find('.form-message').show();
+ } else {
+ $input.closest('.form-group').removeClass('has-error');
+ $input.attr('already-exists', 'false');
+ if ($input.parents().eq(3).find('.form-message').text() === EALang.username_already_exists) {
+ $input.parents().eq(3).find('.form-message').hide();
+ }
}
- }
- }, 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ })
+ .fail(GeneralFunctions.ajaxFailureHandler);
});
}
diff --git a/assets/js/backend_users_admins.js b/assets/js/backend_users_admins.js
index 55c98798..84ee7a88 100644
--- a/assets/js/backend_users_admins.js
+++ b/assets/js/backend_users_admins.js
@@ -181,7 +181,7 @@
$('#admins').on('click', '#cancel-admin', function () {
var id = $('#admin-id').val();
this.resetForm();
- if (id != '') {
+ if (id) {
this.select(id, true);
}
}.bind(this));
@@ -195,6 +195,7 @@
*/
AdminsHelper.prototype.save = function (admin) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_admin';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
admin: JSON.stringify(admin)
@@ -217,6 +218,7 @@
*/
AdminsHelper.prototype.delete = function (id) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_admin';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
admin_id: id
@@ -244,45 +246,45 @@
var missingRequired = false;
$('#admins .required').each(function () {
- if ($(this).val() == '' || $(this).val() == undefined) {
+ if (!$(this).val()) {
$(this).closest('.form-group').addClass('has-error');
missingRequired = true;
}
});
if (missingRequired) {
- throw 'Fields with * are required.';
+ throw new Error('Fields with * are required.');
}
// Validate passwords.
- if ($('#admin-password').val() != $('#admin-password-confirm').val()) {
+ if ($('#admin-password').val() !== $('#admin-password-confirm').val()) {
$('#admin-password, #admin-password-confirm').closest('.form-group').addClass('has-error');
- throw EALang.passwords_mismatch;
+ throw new Error(EALang.passwords_mismatch);
}
if ($('#admin-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
- && $('#admin-password').val() != '') {
+ && $('#admin-password').val() !== '') {
$('#admin-password, #admin-password-confirm').closest('.form-group').addClass('has-error');
- throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
+ throw new Error(EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH));
}
// Validate user email.
if (!GeneralFunctions.validateEmail($('#admin-email').val())) {
$('#admin-email').closest('.form-group').addClass('has-error');
- throw EALang.invalid_email;
+ throw new Error(EALang.invalid_email);
}
// Check if username exists
- if ($('#admin-username').attr('already-exists') == 'true') {
+ if ($('#admin-username').attr('already-exists') === 'true') {
$('#admin-username').closest('.form-group').addClass('has-error');
- throw EALang.username_already_exists;
+ throw new Error(EALang.username_already_exists);
}
return true;
- } catch (message) {
+ } catch (error) {
$('#admins .form-message')
.addClass('alert-danger')
- .text(message)
+ .text(error.message)
.show();
return false;
}
@@ -328,7 +330,7 @@
$('#admin-username').val(admin.settings.username);
$('#admin-calendar-view').val(admin.settings.calendar_view);
- if (admin.settings.notifications == true) {
+ if (admin.settings.notifications === true) {
$('#admin-notifications').addClass('active');
} else {
$('#admin-notifications').removeClass('active');
@@ -347,41 +349,44 @@
AdminsHelper.prototype.filter = function (key, selectId, display) {
display = display || false;
- var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_admins';
- var postData = {
+ var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_admins';
+
+ var data = {
csrfToken: GlobalVariables.csrfToken,
key: key,
limit: this.filterLimit
};
- $.post(postUrl, postData, function (response) {
- this.filterResults = response;
+ $.post(url, data)
+ .done(function (response) {
+ this.filterResults = response;
- $('#filter-admins .results').html('');
- $.each(response, function (index, admin) {
- var html = this.getFilterHtml(admin);
- $('#filter-admins .results').append(html);
- }.bind(this));
+ $('#filter-admins .results').html('');
+ $.each(response, function (index, admin) {
+ var html = this.getFilterHtml(admin);
+ $('#filter-admins .results').append(html);
+ }.bind(this));
- if (response.length == 0) {
- $('#filter-admins .results').html('' + EALang.no_records_found + '')
- } else if (response.length === this.filterLimit) {
- $('', {
- 'type': 'button',
- 'class': 'well btn-block load-more text-center',
- 'text': EALang.load_more,
- 'click': function () {
- this.filterLimit += 20;
- this.filter(key, selectId, display);
- }.bind(this)
- })
- .appendTo('#filter-admins .results');
- }
+ if (!response.length) {
+ $('#filter-admins .results').html('' + EALang.no_records_found + '')
+ } else if (response.length === this.filterLimit) {
+ $('', {
+ 'type': 'button',
+ 'class': 'well btn-block load-more text-center',
+ 'text': EALang.load_more,
+ 'click': function () {
+ this.filterLimit += 20;
+ this.filter(key, selectId, display);
+ }.bind(this)
+ })
+ .appendTo('#filter-admins .results');
+ }
- if (selectId != undefined) {
- this.select(selectId, display);
- }
- }.bind(this), 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ if (selectId) {
+ this.select(selectId, display);
+ }
+ }.bind(this))
+ .fail(GeneralFunctions.ajaxFailureHandler);
};
/**
@@ -395,11 +400,9 @@
var name = admin.first_name + ' ' + admin.last_name;
var info = admin.email;
- info = (admin.mobile_number != '' && admin.mobile_number != null)
- ? info + ', ' + admin.mobile_number : info;
+ info = admin.mobile_number ? info + ', ' + admin.mobile_number : info;
- info = (admin.phone_number != '' && admin.phone_number != null)
- ? info + ', ' + admin.phone_number : info;
+ info = admin.phone_number ? info + ', ' + admin.phone_number : info;
var html =
'
' +
@@ -424,7 +427,7 @@
$('#filter-admins .selected').removeClass('selected');
$('.admin-row').each(function () {
- if ($(this).attr('data-id') == id) {
+ if (Number($(this).attr('data-id')) === Number(id)) {
$(this).addClass('selected');
return false;
}
@@ -432,7 +435,7 @@
if (display) {
$.each(this.filterResults, function (index, admin) {
- if (admin.id == id) {
+ if (Number(admin.id) === Number(id)) {
this.display(admin);
$('#edit-admin, #delete-admin').prop('disabled', false);
return false;
diff --git a/assets/js/backend_users_providers.js b/assets/js/backend_users_providers.js
index 04c644e9..4b7e1057 100755
--- a/assets/js/backend_users_providers.js
+++ b/assets/js/backend_users_providers.js
@@ -203,7 +203,7 @@
$('#providers').on('click', '#cancel-provider', function () {
var id = $('#filter-providers .selected').attr('data-id');
this.resetForm();
- if (id != '') {
+ if (id) {
this.select(id, true);
}
}.bind(this));
@@ -298,44 +298,44 @@
// Validate required fields.
var missingRequired = false;
$('#providers .required').each(function () {
- if ($(this).val() == '' || $(this).val() == undefined) {
+ if (!$(this).val()) {
$(this).closest('.form-group').addClass('has-error');
missingRequired = true;
}
});
if (missingRequired) {
- throw EALang.fields_are_required;
+ throw new Error(EALang.fields_are_required);
}
// Validate passwords.
- if ($('#provider-password').val() != $('#provider-password-confirm').val()) {
+ if ($('#provider-password').val() !== $('#provider-password-confirm').val()) {
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
- throw EALang.passwords_mismatch;
+ throw new Error(EALang.passwords_mismatch);
}
if ($('#provider-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
- && $('#provider-password').val() != '') {
+ && $('#provider-password').val() !== '') {
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
- throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
+ throw new Error(EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH));
}
// Validate user email.
if (!GeneralFunctions.validateEmail($('#provider-email').val())) {
$('#provider-email').closest('.form-group').addClass('has-error');
- throw EALang.invalid_email;
+ throw new Error(EALang.invalid_email);
}
// Check if username exists
- if ($('#provider-username').attr('already-exists') == 'true') {
+ if ($('#provider-username').attr('already-exists') === 'true') {
$('#provider-username').closest('.form-group').addClass('has-error');
- throw EALang.username_already_exists;
+ throw new Error(EALang.username_already_exists);
}
return true;
- } catch (message) {
+ } catch (error) {
$('#providers .form-message')
.addClass('alert-danger')
- .text(message)
+ .text(error.message)
.show();
return false;
}
@@ -395,7 +395,7 @@
$('#provider-username').val(provider.settings.username);
$('#provider-calendar-view').val(provider.settings.calendar_view);
- if (provider.settings.notifications == true) {
+ if (provider.settings.notifications === '1') {
$('#provider-notifications').addClass('active');
} else {
$('#provider-notifications').removeClass('active');
@@ -414,7 +414,7 @@
$('#provider-services input:checkbox').prop('checked', false);
$.each(provider.services, function (index, serviceId) {
$('#provider-services input:checkbox').each(function () {
- if ($(this).attr('data-id') == serviceId) {
+ if (Number($(this).attr('data-id')) === Number(serviceId)) {
$(this).prop('checked', true);
// Add dedicated service-provider link.
dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id)
@@ -446,41 +446,43 @@
ProvidersHelper.prototype.filter = function (key, selectId, display) {
display = display || false;
- var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
- var postData = {
+ var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
+ var data = {
csrfToken: GlobalVariables.csrfToken,
key: key,
limit: this.filterLimit
};
- $.post(postUrl, postData, function (response) {
- this.filterResults = response;
+ $.post(url, data)
+ .done(function (response) {
+ this.filterResults = response;
- $('#filter-providers .results').html('');
- $.each(response, function (index, provider) {
- var html = this.getFilterHtml(provider);
- $('#filter-providers .results').append(html);
- }.bind(this));
+ $('#filter-providers .results').html('');
+ $.each(response, function (index, provider) {
+ var html = this.getFilterHtml(provider);
+ $('#filter-providers .results').append(html);
+ }.bind(this));
- if (response.length == 0) {
- $('#filter-providers .results').html('' + EALang.no_records_found + '')
- } else if (response.length === this.filterLimit) {
- $('', {
- 'type': 'button',
- 'class': 'well btn-block load-more text-center',
- 'text': EALang.load_more,
- 'click': function () {
- this.filterLimit += 20;
- this.filter(key, selectId, display);
- }.bind(this)
- })
- .appendTo('#filter-providers .results');
- }
+ if (!response.length) {
+ $('#filter-providers .results').html('' + EALang.no_records_found + '')
+ } else if (response.length === this.filterLimit) {
+ $('', {
+ 'type': 'button',
+ 'class': 'well btn-block load-more text-center',
+ 'text': EALang.load_more,
+ 'click': function () {
+ this.filterLimit += 20;
+ this.filter(key, selectId, display);
+ }.bind(this)
+ })
+ .appendTo('#filter-providers .results');
+ }
- if (selectId != undefined) {
- this.select(selectId, display);
- }
- }.bind(this), 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ if (selectId) {
+ this.select(selectId, display);
+ }
+ }.bind(this))
+ .fail(GeneralFunctions.ajaxFailureHandler);
};
/**
@@ -494,11 +496,9 @@
var name = provider.first_name + ' ' + provider.last_name,
info = provider.email;
- info = (provider.mobile_number != '' && provider.mobile_number != null)
- ? info + ', ' + provider.mobile_number : info;
+ info = provider.mobile_number ? info + ', ' + provider.mobile_number : info;
- info = (provider.phone_number != '' && provider.phone_number != null)
- ? info + ', ' + provider.phone_number : info;
+ info = provider.phone_number ? info + ', ' + provider.phone_number : info;
var html =
'
' +
@@ -587,7 +587,7 @@
// Select record in filter results.
$('#filter-providers .provider-row').each(function () {
- if ($(this).attr('data-id') == id) {
+ if (Number($(this).attr('data-id')) === Number(id)) {
$(this).addClass('selected');
return false;
}
@@ -596,7 +596,7 @@
// Display record in form (if display = true).
if (display) {
$.each(this.filterResults, function (index, provider) {
- if (provider.id == id) {
+ if (Number(provider.id) === Number(id)) {
this.display(provider);
$('#edit-provider, #delete-provider').prop('disabled', false);
return false;
diff --git a/assets/js/backend_users_secretaries.js b/assets/js/backend_users_secretaries.js
index e6770cad..be1d9e34 100644
--- a/assets/js/backend_users_secretaries.js
+++ b/assets/js/backend_users_secretaries.js
@@ -194,7 +194,7 @@
$('#secretaries').on('click', '#cancel-secretary', function () {
var id = $('#secretary-id').val();
this.resetForm();
- if (id != '') {
+ if (id) {
this.select(id, true);
}
}.bind(this));
@@ -208,6 +208,7 @@
*/
SecretariesHelper.prototype.save = function (secretary) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_secretary';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
secretary: JSON.stringify(secretary)
@@ -230,6 +231,7 @@
*/
SecretariesHelper.prototype.delete = function (id) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_secretary';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
secretary_id: id
@@ -257,45 +259,45 @@
// Validate required fields.
var missingRequired = false;
$('#secretaries .required').each(function () {
- if ($(this).val() == '' || $(this).val() == undefined) {
+ if (!$(this).val()) {
$(this).closest('.form-group').addClass('has-error');
missingRequired = true;
}
});
if (missingRequired) {
- throw 'Fields with * are required.';
+ throw new Error('Fields with * are required.');
}
// Validate passwords.
- if ($('#secretary-password').val() != $('#secretary-password-confirm').val()) {
+ if ($('#secretary-password').val() !== $('#secretary-password-confirm').val()) {
$('#secretary-password, #secretary-password-confirm').closest('.form-group').addClass('has-error');
- throw 'Passwords mismatch!';
+ throw new Error('Passwords mismatch!');
}
if ($('#secretary-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
- && $('#secretary-password').val() != '') {
+ && $('#secretary-password').val() !== '') {
$('#secretary-password, #secretary-password-confirm').closest('.form-group').addClass('has-error');
- throw 'Password must be at least ' + BackendUsers.MIN_PASSWORD_LENGTH
- + ' characters long.';
+ throw new Error('Password must be at least ' + BackendUsers.MIN_PASSWORD_LENGTH
+ + ' characters long.');
}
// Validate user email.
if (!GeneralFunctions.validateEmail($('#secretary-email').val())) {
$('#secretary-email').closest('.form-group').addClass('has-error');
- throw 'Invalid email address!';
+ throw new Error('Invalid email address!');
}
// Check if username exists
- if ($('#secretary-username').attr('already-exists') == 'true') {
+ if ($('#secretary-username').attr('already-exists') === 'true') {
$('#secretary-username').closest('.form-group').addClass('has-error');
- throw 'Username already exists.';
+ throw new Error('Username already exists.');
}
return true;
- } catch (message) {
+ } catch (error) {
$('#secretaries .form-message')
.addClass('alert-danger')
- .text(message)
+ .text(error.message)
.show();
return false;
}
@@ -344,7 +346,7 @@
$('#secretary-username').val(secretary.settings.username);
$('#secretary-calendar-view').val(secretary.settings.calendar_view);
- if (secretary.settings.notifications == true) {
+ if (secretary.settings.notifications === '1') {
$('#secretary-notifications').addClass('active');
} else {
$('#secretary-notifications').removeClass('active');
@@ -353,7 +355,7 @@
$('#secretary-providers input:checkbox').prop('checked', false);
$.each(secretary.providers, function (index, providerId) {
$('#secretary-providers input:checkbox').each(function () {
- if ($(this).attr('data-id') == providerId) {
+ if (Number($(this).attr('data-id')) === Number(providerId)) {
$(this).prop('checked', true);
}
});
@@ -371,41 +373,44 @@
SecretariesHelper.prototype.filter = function (key, selectId, display) {
display = display || false;
- var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_secretaries';
- var postData = {
+ var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_secretaries';
+
+ var data = {
csrfToken: GlobalVariables.csrfToken,
key: key,
limit: this.filterLimit
};
- $.post(postUrl, postData, function (response) {
- this.filterResults = response;
+ $.post(url, data)
+ .done(function (response) {
+ this.filterResults = response;
- $('#filter-secretaries .results').html('');
- $.each(response, function (index, secretary) {
- var html = this.getFilterHtml(secretary);
- $('#filter-secretaries .results').append(html);
- }.bind(this));
+ $('#filter-secretaries .results').html('');
+ $.each(response, function (index, secretary) {
+ var html = this.getFilterHtml(secretary);
+ $('#filter-secretaries .results').append(html);
+ }.bind(this));
- if (response.length == 0) {
- $('#filter-secretaries .results').html('' + EALang.no_records_found + '')
- } else if (response.length === this.filterLimit) {
- $('', {
- 'type': 'button',
- 'class': 'well btn-block load-more text-center',
- 'text': EALang.load_more,
- 'click': function () {
- this.filterLimit += 20;
- this.filter(key, selectId, display);
- }.bind(this)
- })
- .appendTo('#filter-secretaries .results');
- }
+ if (!response.length) {
+ $('#filter-secretaries .results').html('' + EALang.no_records_found + '')
+ } else if (response.length === this.filterLimit) {
+ $('', {
+ 'type': 'button',
+ 'class': 'well btn-block load-more text-center',
+ 'text': EALang.load_more,
+ 'click': function () {
+ this.filterLimit += 20;
+ this.filter(key, selectId, display);
+ }.bind(this)
+ })
+ .appendTo('#filter-secretaries .results');
+ }
- if (selectId != undefined) {
- this.select(selectId, display);
- }
- }.bind(this), 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ if (selectId) {
+ this.select(selectId, display);
+ }
+ }.bind(this))
+ .fail(GeneralFunctions.ajaxFailureHandler);
};
/**
@@ -419,11 +424,9 @@
var name = secretary.first_name + ' ' + secretary.last_name;
var info = secretary.email;
- info = (secretary.mobile_number != '' && secretary.mobile_number != null)
- ? info + ', ' + secretary.mobile_number : info;
+ info = secretary.mobile_number ? info + ', ' + secretary.mobile_number : info;
- info = (secretary.phone_number != '' && secretary.phone_number != null)
- ? info + ', ' + secretary.phone_number : info;
+ info = secretary.phone_number ? info + ', ' + secretary.phone_number : info;
var html =
'
' +
@@ -447,7 +450,7 @@
$('#filter-secretaries .selected').removeClass('selected');
$('#filter-secretaries .secretary-row').each(function () {
- if ($(this).attr('data-id') == id) {
+ if (Number($(this).attr('data-id')) === Number(id)) {
$(this).addClass('selected');
return false;
}
@@ -455,7 +458,7 @@
if (display) {
$.each(this.filterResults, function (index, admin) {
- if (admin.id == id) {
+ if (Number(admin.id) === Number(id)) {
this.display(admin);
$('#edit-secretary, #delete-secretary').prop('disabled', false);
return false;
diff --git a/assets/js/frontend_book.js b/assets/js/frontend_book.js
index 952af0da..c029742f 100644
--- a/assets/js/frontend_book.js
+++ b/assets/js/frontend_book.js
@@ -57,7 +57,7 @@ window.FrontendBook = window.FrontendBook || {};
bindEventHandlers = bindEventHandlers || true;
manageMode = manageMode || false;
- if (window.console === undefined) {
+ if (window.console) {
window.console = function () {
}; // IE compatibility
}
@@ -230,14 +230,13 @@ window.FrontendBook = window.FrontendBook || {};
* become visible.
*/
$('#select-service').change(function () {
- var currServiceId = $('#select-service').val();
+ var serviceId = $('#select-service').val();
$('#select-provider').empty();
$.each(GlobalVariables.availableProviders, function (indexProvider, provider) {
- $.each(provider.services, function (indexService, serviceId) {
- // If the current provider is able to provide the selected service,
- // add him to the listbox.
- if (serviceId == currServiceId) {
+ $.each(provider.services, function (indexService, providerServiceId) {
+ // If the current provider is able to provide the selected service, add him to the listbox.
+ if (Number(providerServiceId) === Number(serviceId)) {
var optionHtml = '';
@@ -266,15 +265,15 @@ window.FrontendBook = window.FrontendBook || {};
$('.button-next').click(function () {
// If we are on the first step and there is not provider selected do not continue
// with the next step.
- if ($(this).attr('data-step_index') === '1' && $('#select-provider').val() == null) {
+ if ($(this).attr('data-step_index') === '1' && !$('#select-provider').val()) {
return;
}
// If we are on the 2nd tab then the user should have an appointment hour
// selected.
if ($(this).attr('data-step_index') === '2') {
- if ($('.selected-hour').length == 0) {
- if ($('#select-hour-prompt').length == 0) {
+ if (!$('.selected-hour').length) {
+ if (!$('#select-hour-prompt').length) {
$('#available-hours').append('
'
+ ''
+ EALang.appointment_hour_missing
@@ -466,37 +465,37 @@ window.FrontendBook = window.FrontendBook || {};
// Validate required fields.
var missingRequiredField = false;
$('.required').each(function () {
- if ($(this).val() == '') {
+ if (!$(this).val()) {
$(this).parents('.form-group').addClass('has-error');
missingRequiredField = true;
}
});
if (missingRequiredField) {
- throw EALang.fields_are_required;
+ throw new Error(EALang.fields_are_required);
}
var $acceptToTermsAndConditions = $('#accept-to-terms-and-conditions');
if ($acceptToTermsAndConditions.length && !$acceptToTermsAndConditions.prop('checked')) {
$acceptToTermsAndConditions.parents('label').addClass('text-danger');
- throw EALang.fields_are_required;
+ throw new Error(EALang.fields_are_required);
}
var $acceptToPrivacyPolicy = $('#accept-to-privacy-policy');
if ($acceptToPrivacyPolicy.length && !$acceptToPrivacyPolicy.prop('checked')) {
$acceptToPrivacyPolicy.parents('label').addClass('text-danger');
- throw EALang.fields_are_required;
+ throw new Error(EALang.fields_are_required);
}
// Validate email address.
if (!GeneralFunctions.validateEmail($('#email').val())) {
$('#email').parents('.form-group').addClass('has-error');
- throw EALang.invalid_email;
+ throw new Error(EALang.invalid_email);
}
return true;
- } catch (exc) {
- $('#form-message').text(exc);
+ } catch (error) {
+ $('#form-message').text(error.message);
return false;
}
}
@@ -517,12 +516,12 @@ window.FrontendBook = window.FrontendBook || {};
selectedDate = GeneralFunctions.formatDate(selectedDate, GlobalVariables.dateFormat);
}
- var selServiceId = $('#select-service').val();
+ var serviceId = $('#select-service').val();
var servicePrice = '';
var serviceCurrency = '';
$.each(GlobalVariables.availableServices, function (index, service) {
- if (service.id == selServiceId && service.price != '' && service.price != null && service.price != '0.00' && service.price != '0,00') {
+ if (Number(service.id) === Number(serviceId) && Number(service.price) > 0) {
servicePrice = ' ' + service.price;
serviceCurrency = service.currency;
return false; // break loop
@@ -568,9 +567,9 @@ window.FrontendBook = window.FrontendBook || {};
// Update appointment form data for submission to server when the user confirms
// the appointment.
- var postData = {};
+ var data = {};
- postData.customer = {
+ data.customer = {
last_name: $('#last-name').val(),
first_name: $('#first-name').val(),
email: $('#email').val(),
@@ -581,7 +580,7 @@ window.FrontendBook = window.FrontendBook || {};
timezone: $('#select-timezone').val()
};
- postData.appointment = {
+ data.appointment = {
start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00',
end_datetime: _calcEndDatetime(),
@@ -591,14 +590,14 @@ window.FrontendBook = window.FrontendBook || {};
id_services: $('#select-service').val()
};
- postData.manage_mode = FrontendBook.manageMode;
+ data.manage_mode = FrontendBook.manageMode;
if (FrontendBook.manageMode) {
- postData.appointment.id = GlobalVariables.appointmentData.id;
- postData.customer.id = GlobalVariables.customerData.id;
+ data.appointment.id = GlobalVariables.appointmentData.id;
+ data.customer.id = GlobalVariables.customerData.id;
}
$('input[name="csrfToken"]').val(GlobalVariables.csrfToken);
- $('input[name="post_data"]').val(JSON.stringify(postData));
+ $('input[name="post_data"]').val(JSON.stringify(data));
};
/**
@@ -609,12 +608,13 @@ window.FrontendBook = window.FrontendBook || {};
*/
function _calcEndDatetime() {
// Find selected service duration.
- var selServiceDuration = undefined;
+ var serviceId = $('#select-service').val();
+ var serviceDuration;
$.each(GlobalVariables.availableServices, function (index, service) {
- if (service.id == $('#select-service').val()) {
- selServiceDuration = service.duration;
- return false; // Stop searching ...
+ if (Number(service.id) === Number(serviceId)) {
+ serviceDuration = service.duration;
+ return false;
}
});
@@ -622,10 +622,10 @@ window.FrontendBook = window.FrontendBook || {};
var startDatetime = $('#select-date').datepicker('getDate').toString('dd-MM-yyyy')
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm');
startDatetime = Date.parseExact(startDatetime, 'dd-MM-yyyy HH:mm');
- var endDatetime = undefined;
+ var endDatetime;
- if (selServiceDuration !== undefined && startDatetime !== null) {
- endDatetime = startDatetime.add({'minutes': parseInt(selServiceDuration)});
+ if (serviceDuration && startDatetime) {
+ endDatetime = startDatetime.add({'minutes': parseInt(serviceDuration)});
} else {
endDatetime = new Date();
}
@@ -687,22 +687,22 @@ window.FrontendBook = window.FrontendBook || {};
var html = '';
$.each(GlobalVariables.availableServices, function (index, service) {
- if (service.id == serviceId) { // Just found the service.
+ if (Number(service.id) === Number(serviceId)) {
html = '' + service.name + ' ';
- if (service.description != '' && service.description != null) {
+ if (service.description) {
html += ' ' + service.description + ' ';
}
- if (service.duration != '' && service.duration != null) {
+ if (service.duration) {
html += '[' + EALang.duration + ' ' + service.duration + ' ' + EALang.minutes + ']';
}
- if (service.price != '' && service.price != null && service.price != '0.00' && service.price != '0,00') {
+ if (Number(service.price) > 0) {
html += '[' + EALang.price + ' ' + service.price + ' ' + service.currency + ']';
}
- if (service.location != '' && service.location != null) {
+ if (service.location) {
html += '[' + EALang.location + ' ' + service.location + ']';
}
@@ -712,13 +712,9 @@ window.FrontendBook = window.FrontendBook || {};
}
});
- $div.html(html);
-
- if (html != '') {
- $div.show();
- } else {
- $div.hide();
- }
+ $div
+ .html(html)
+ .toggle(html);
}
})(window.FrontendBook);
diff --git a/assets/js/frontend_book_api.js b/assets/js/frontend_book_api.js
index fcc89f4a..bb2f096f 100755
--- a/assets/js/frontend_book_api.js
+++ b/assets/js/frontend_book_api.js
@@ -37,90 +37,101 @@ window.FrontendBookApi = window.FrontendBookApi || {};
exports.getAvailableHours = function (selDate) {
$('#available-hours').empty();
- // Find the selected service duration (it is going to be send within the "postData" object).
- var selServiceDuration = 15; // Default value of duration (in minutes).
- $.each(GlobalVariables.availableServices, function (index, service) {
- if (service.id == $('#select-service').val()) {
- selServiceDuration = service.duration;
- }
- });
+ // Find the selected service duration (it is going to be send within the "data" object).
+ var serviceId = $('#select-service').val();
+
+ // Default value of duration (in minutes).
+ var serviceDuration = 15;
+
+ var service = GlobalVariables.availableServices.filter(function(availableService) {
+ return Number(availableService.id) === Number(serviceId);
+ }).shift();
+
+ if (service) {
+ serviceDuration = service.duration;
+ }
// If the manage mode is true then the appointment's start date should return as available too.
- var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : undefined;
+ var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : null;
// Make ajax post request and get the available hours.
- var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours';
- var postData = {
+ var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours';
+
+ var data = {
csrfToken: GlobalVariables.csrfToken,
service_id: $('#select-service').val(),
provider_id: $('#select-provider').val(),
selected_date: selDate,
- service_duration: selServiceDuration,
+ service_duration: serviceDuration,
manage_mode: FrontendBook.manageMode,
appointment_id: appointmentId
};
- $.post(postUrl, postData, function (response) {
- // The response contains the available hours for the selected provider and
- // service. Fill the available hours div with response data.
- if (response.length > 0) {
- var providerId = $('#select-provider').val();
+ $.post(url, data)
+ .done(function (response) {
+ // The response contains the available hours for the selected provider and
+ // service. Fill the available hours div with response data.
+ if (response.length > 0) {
+ var providerId = $('#select-provider').val();
- if (providerId === 'any-provider') {
- providerId = GlobalVariables.availableProviders[0].id; // Use first available provider.
- }
-
- var provider = GlobalVariables.availableProviders.filter(function(availableProvider) {
- return providerId == availableProvider.id;
- }).shift();
-
- if (!provider) {
- throw new Error('Could not find provider.');
- }
-
- var providerTimezone = provider.timezone;
-
- var selectedTimezone = $('#select-timezone').val();
-
- var currColumn = 1;
-
- $('#available-hours').html('');
-
- var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
-
- $.each(response, function (index, availableHour) {
- if ((currColumn * 10) < (index + 1)) {
- currColumn++;
- $('#available-hours').append('');
+ if (providerId === 'any-provider') {
+ providerId = GlobalVariables.availableProviders[0].id; // Use first available provider.
}
- var availableHourMoment = moment
- .tz(selDate + ' ' + availableHour + ':00', providerTimezone)
- .tz(selectedTimezone);
+ var provider = GlobalVariables.availableProviders.filter(function(availableProvider) {
+ return Number(providerId) === Number(availableProvider.id);
+ }).shift();
- $('#available-hours div:eq(' + (currColumn - 1) + ')').append(
- '' + availableHourMoment.format(timeFormat) + ' ');
- });
+ if (!provider) {
+ throw new Error('Could not find provider.');
+ }
+
+ var providerTimezone = provider.timezone;
+
+ var selectedTimezone = $('#select-timezone').val();
+
+ var currColumn = 1;
+
+ $('#available-hours').html('');
+
+ var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
+
+ response.forEach(function (availableHour, index) {
+ if ((currColumn * 10) < (index + 1)) {
+ currColumn++;
+ $('#available-hours').append('');
+ }
+
+ var availableHourMoment = moment
+ .tz(selDate + ' ' + availableHour + ':00', providerTimezone)
+ .tz(selectedTimezone);
+
+ $('#available-hours div:eq(' + (currColumn - 1) + ')').append(
+ '' + availableHourMoment.format(timeFormat) + ' ');
+ });
+
+ if (FrontendBook.manageMode) {
+ // Set the appointment's start time as the default selection.
+ $('.available-hour')
+ .removeClass('selected-hour')
+ .filter(function () {
+ return $(this).text() === Date.parseExact(
+ GlobalVariables.appointmentData.start_datetime,
+ 'yyyy-MM-dd HH:mm:ss').toString(timeFormat);
+ })
+ .addClass('selected-hour');
+ } else {
+ // Set the first available hour as the default selection.
+ $('.available-hour:eq(0)').addClass('selected-hour');
+ }
+
+ FrontendBook.updateConfirmFrame();
- if (FrontendBook.manageMode) {
- // Set the appointment's start time as the default selection.
- $('.available-hour').removeClass('selected-hour');
- $('.available-hour').filter(function () {
- return $(this).text() === Date.parseExact(
- GlobalVariables.appointmentData.start_datetime,
- 'yyyy-MM-dd HH:mm:ss').toString(timeFormat);
- }).addClass('selected-hour');
} else {
- // Set the first available hour as the default selection.
- $('.available-hour:eq(0)').addClass('selected-hour');
+ $('#available-hours').text(EALang.no_available_hours);
}
-
- FrontendBook.updateConfirmFrame();
-
- } else {
- $('#available-hours').text(EALang.no_available_hours);
- }
- }, 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ })
+ .fail(GeneralFunctions.ajaxFailureHandler);
};
/**
@@ -141,26 +152,27 @@ window.FrontendBookApi = window.FrontendBookApi || {};
}
var formData = jQuery.parseJSON($('input[name="post_data"]').val());
- var postData = {
+ var data = {
csrfToken: GlobalVariables.csrfToken,
post_data: formData
};
if ($captchaText.length > 0) {
- postData.captcha = $captchaText.val();
+ data.captcha = $captchaText.val();
}
if (GlobalVariables.manageMode) {
- postData.exclude_appointment_id = GlobalVariables.appointmentData.id;
+ data.exclude_appointment_id = GlobalVariables.appointmentData.id;
}
- var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_register_appointment';
+ var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_register_appointment';
+
var $layer = $('');
$.ajax({
- url: postUrl,
+ url: url,
method: 'post',
- data: postData,
+ data: data,
dataType: 'json',
beforeSend: function (jqxhr, settings) {
$layer
@@ -221,9 +233,10 @@ window.FrontendBookApi = window.FrontendBookApi || {};
return;
}
- var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : undefined;
+ var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : null;
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates';
+
var data = {
provider_id: providerId,
service_id: serviceId,
@@ -279,7 +292,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
// Grey out unavailable dates.
$('#select-date .ui-datepicker-calendar td:not(.ui-datepicker-other-month)').each(function (index, td) {
selectedDate.set({day: index + 1});
- if ($.inArray(selectedDate.toString('yyyy-MM-dd'), unavailableDates) != -1) {
+ if (unavailableDates.indexOf(selectedDate.toString('yyyy-MM-dd')) !== -1) {
$(td).addClass('ui-datepicker-unselectable ui-state-disabled');
}
});
@@ -294,6 +307,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
*/
exports.saveConsent = function (consent) {
var url = GlobalVariables.baseUrl + '/index.php/consents/ajax_save_consent';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
consent: consent
@@ -309,14 +323,17 @@ window.FrontendBookApi = window.FrontendBookApi || {};
*/
exports.deletePersonalInformation = function (customerToken) {
var url = GlobalVariables.baseUrl + '/index.php/privacy/ajax_delete_personal_information';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
customer_token: customerToken
};
- $.post(url, data, function (response) {
- location.href = GlobalVariables.baseUrl;
- }, 'json').fail(GeneralFunctions.ajaxFailureHandler);
+ $.post(url, data)
+ .done(function () {
+ location.href = GlobalVariables.baseUrl;
+ })
+ .fail(GeneralFunctions.ajaxFailureHandler);
};
})(window.FrontendBookApi);
diff --git a/assets/js/frontend_book_success.js b/assets/js/frontend_book_success.js
index 4f9ea8d1..e2a82c81 100644
--- a/assets/js/frontend_book_success.js
+++ b/assets/js/frontend_book_success.js
@@ -37,7 +37,7 @@ $(document).ready(function () {
function handleAuthResult(authResult) {
try {
if (authResult.error) {
- throw 'Could not authorize user.';
+ throw new Error('Could not authorize user.');
}
// The user has granted access, add the appointment to his calendar.
@@ -79,7 +79,7 @@ $(document).ready(function () {
request.execute(function (response) {
if (response.error) {
- throw 'Could not add the event to Google Calendar.';
+ throw new Error('Could not add the event to Google Calendar.');
}
$('#success-frame').append(
@@ -98,14 +98,14 @@ $(document).ready(function () {
$('#add-to-google-calendar').hide();
});
});
- } catch (exc) {
+ } catch (error) {
// The user denied access or something else happened, display corresponding message on the screen.
$('#success-frame').append(
'
' +
'
' + EALang.oops_something_went_wrong + '
' +
'
' +
EALang.could_not_add_to_google_calendar +
- '
' + exc + '
' +
+ '
' + error.message + '
' +
'' +
'
');
}
diff --git a/assets/js/general_functions.js b/assets/js/general_functions.js
index 8a737c11..b1ce8c43 100755
--- a/assets/js/general_functions.js
+++ b/assets/js/general_functions.js
@@ -31,15 +31,15 @@ window.GeneralFunctions = window.GeneralFunctions || {};
* @param {Array} buttons Contains the dialog buttons along with their functions.
*/
exports.displayMessageBox = function (title, message, buttons) {
- if (title === undefined || title === '') {
+ if (!title) {
title = '- No Title Provided -';
}
- if (message === undefined || message === '') {
+ if (!message) {
message = '- No Message Provided -';
}
- if (buttons === undefined) {
+ if (!buttons) {
buttons = [
{
text: EALang.close,
@@ -170,19 +170,22 @@ window.GeneralFunctions = window.GeneralFunctions || {};
*/
exports.clone = function (originalObject) {
// Handle the 3 simple types, and null or undefined
- if (null == originalObject || 'object' != typeof originalObject)
+ if (!originalObject || typeof originalObject !== 'object') {
return originalObject;
+ }
+
+ var copy;
// Handle Date
if (originalObject instanceof Date) {
- var copy = new Date();
+ copy = new Date();
copy.setTime(originalObject.getTime());
return copy;
}
// Handle Array
if (originalObject instanceof Array) {
- var copy = [];
+ copy = [];
for (var i = 0, len = originalObject.length; i < len; i++) {
copy[i] = GeneralFunctions.clone(originalObject[i]);
}
@@ -191,7 +194,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
// Handle Object
if (originalObject instanceof Object) {
- var copy = {};
+ copy = {};
for (var attr in originalObject) {
if (originalObject.hasOwnProperty(attr))
copy[attr] = GeneralFunctions.clone(originalObject[attr]);
@@ -309,10 +312,12 @@ window.GeneralFunctions = window.GeneralFunctions || {};
$(document).on('click', 'li.language', function () {
// Change language with ajax call and refresh page.
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_change_language';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
language: $(this).attr('data-language')
};
+
$.post(url, data)
done(function () {
document.location.reload(true);
diff --git a/assets/js/installation.js b/assets/js/installation.js
index 94cdd03b..0b728f85 100644
--- a/assets/js/installation.js
+++ b/assets/js/installation.js
@@ -14,6 +14,7 @@ $(function () {
var MIN_PASSWORD_LENGTH = 7;
+ var $install = $('#install');
var $alert = $('.alert');
$(document).ajaxStart(function () {
@@ -27,12 +28,13 @@ $(function () {
/**
* Event: Install Easy!Appointments Button "Click"
*/
- $('#install').click(function () {
+ $install.click(function () {
if (!validate()) {
return;
}
var url = GlobalVariables.baseUrl + '/index.php/installation/ajax_install';
+
var data = {
csrfToken: GlobalVariables.csrfToken,
admin: getAdminData(),
@@ -75,45 +77,45 @@ $(function () {
// Check for empty fields.
var missingRequired = false;
$('input').each(function () {
- if ($(this).val() == '') {
+ if (!$(this).val()) {
$(this).closest('.form-group').addClass('has-error');
missingRequired = true;
}
});
if (missingRequired) {
- throw 'All the page fields are required.';
+ throw new Error('All the page fields are required.');
}
// Validate Passwords
- if ($('#password').val() != $('#retype-password').val()) {
+ if ($('#password').val() !== $('#retype-password').val()) {
$('#password').closest('.form-group').addClass('has-error');
$('#retype-password').closest('.form-group').addClass('has-error');
- throw 'Passwords do not match!';
+ throw new Error('Passwords do not match!');
}
if ($('#password').val().length < MIN_PASSWORD_LENGTH) {
$('#password').closest('.form-group').addClass('has-error');
$('#retype-password').closest('.form-group').addClass('has-error');
- throw 'The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.';
+ throw new Error('The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.');
}
// Validate Email
if (!GeneralFunctions.validateEmail($('#email').val())) {
$('#email').closest('.form-group').addClass('has-error');
- throw 'The email address is invalid!';
+ throw new Error('The email address is invalid!');
}
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
$('#company-email').closest('.form-group').addClass('has-error');
- throw 'The email address is invalid!';
+ throw new Error('The email address is invalid!');
}
return true;
} catch (error) {
$alert
.addClass('alert-danger')
- .text(error)
+ .text(error.message)
.show();
return false;
@@ -126,7 +128,7 @@ $(function () {
* @return {Object}
*/
function getAdminData() {
- var admin = {
+ return {
first_name: $('#first-name').val(),
last_name: $('#last-name').val(),
email: $('#email').val(),
@@ -134,8 +136,6 @@ $(function () {
username: $('#username').val(),
password: $('#password').val()
};
-
- return admin;
}
/**
@@ -144,20 +144,18 @@ $(function () {
* @return {Object}
*/
function getCompanyData() {
- var company = {
+ return {
company_name: $('#company-name').val(),
company_email: $('#company-email').val(),
company_link: $('#company-link').val()
};
-
- return company;
}
// Validate the base URL setting (must not contain any trailing slash).
if (GlobalVariables.baseUrl.slice(-1) === '/') {
- GeneralFunctions.displayMessageBox('Misconfiguration Detected', 'Please remove any trailing slashes from your '
- + 'BASE_URL setting of the root config.php file and try again.');
- $('#install')
+ GeneralFunctions.displayMessageBox('Misconfiguration Detected', 'Please remove any trailing '
+ + 'slashes from your BASE_URL setting of the root config.php file and try again.');
+ $install
.prop('disabled', true)
.fadeTo('0.4');
}
diff --git a/assets/js/login.js b/assets/js/login.js
index 2fa9da0d..6b38a9c4 100644
--- a/assets/js/login.js
+++ b/assets/js/login.js
@@ -13,6 +13,7 @@ $(function () {
event.preventDefault();
var url = GlobalVariables.baseUrl + '/index.php/user/ajax_check_login';
+
var data = {
'csrfToken': GlobalVariables.csrfToken,
'username': $('#username').val(),
diff --git a/assets/js/working_plan.js b/assets/js/working_plan.js
index 298df809..896e79f5 100755
--- a/assets/js/working_plan.js
+++ b/assets/js/working_plan.js
@@ -70,7 +70,7 @@
$('.working-plan tbody').append(tr);
- if (workingDay != null) {
+ if (workingDay) {
$('#' + index).prop('checked', true);
$('#' + index + '-start').val(Date.parse(workingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-end').val(Date.parse(workingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
@@ -125,7 +125,7 @@
*/
WorkingPlan.prototype.setupExtraPeriods = function (extraWorkingPlan) {
$.each(extraWorkingPlan, function (index, extraWorkingDay) {
- if (extraWorkingDay != null) {
+ if (extraWorkingDay) {
$('#' + index).prop('checked', true);
$('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
@@ -245,10 +245,10 @@
*
* Enable or disable the time selection for each day.
*/
- $('.working-plan tbody').on( "click", "input:checkbox", function (event) {
+ $('.working-plan tbody').on( "click", "input:checkbox", function () {
var id = $(this).attr('id');
- if ($(this).prop('checked') == true) {
+ if ($(this).prop('checked') === true) {
$('#' + id + '-start').prop('disabled', false).val('9:00 AM');
$('#' + id + '-end').prop('disabled', false).val('6:00 PM');
} else {
@@ -303,7 +303,7 @@
// Reset previous editable tds
var $previousEdt = $(this).closest('table').find('.editable').get();
$.each($previousEdt, function (index, editable) {
- if (editable.reset !== undefined) {
+ if (editable.reset) {
editable.reset();
}
});
@@ -436,7 +436,7 @@
// Reset previous editable tds
var $previousEdt = $(this).closest('table').find('.editable').get();
$.each($previousEdt, function (index, editable) {
- if (editable.reset !== undefined) {
+ if (editable.reset) {
editable.reset();
}
});
@@ -565,7 +565,7 @@
var workingPlan = {};
$('.working-plan input:checkbox').each(function (index, checkbox) {
var id = $(checkbox).attr('id');
- if ($(checkbox).prop('checked') == true) {
+ if ($(checkbox).prop('checked') === true) {
workingPlan[id] = {
start: Date.parse($('#' + id + '-start').val()).toString('HH:mm'),
end: Date.parse($('#' + id + '-end').val()).toString('HH:mm'),
@@ -575,7 +575,7 @@
$('.breaks tr').each(function (index, tr) {
var day = this.convertDayToValue($(tr).find('.break-day').text());
- if (day == id) {
+ if (day === id) {
var start = $(tr).find('.break-start').text();
var end = $(tr).find('.break-end').text();
@@ -626,12 +626,12 @@
/**
* Enables or disables the timepicker functionality from the working plan input text fields.
*
- * @param {Boolean} disabled (OPTIONAL = false) If true then the timepickers will be disabled.
+ * @param {Boolean} [disabled] If true then the timepickers will be disabled.
*/
WorkingPlan.prototype.timepickers = function (disabled) {
disabled = disabled || false;
- if (disabled == false) {
+ if (disabled === false) {
// Set timepickers where needed.
$('.working-plan input:text').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',