diff --git a/assets/js/backend_calendar.js b/assets/js/backend_calendar.js index b50f0f2d..5c9b260c 100755 --- a/assets/js/backend_calendar.js +++ b/assets/js/backend_calendar.js @@ -25,7 +25,7 @@ window.BackendCalendar = window.BackendCalendar || {}; /** * Bind common event handlers. */ - function _bindEventHandlers() { + function bindEventHandlers() { var $calendarPage = $('#calendar-page'); $calendarPage.on('click', '#toggle-fullscreen', function () { @@ -87,7 +87,7 @@ window.BackendCalendar = window.BackendCalendar || {}; BackendCalendarUnavailabilitiesModal.initialize(); BackendCalendarExtraPeriodsModal.initialize(); - _bindEventHandlers(); + bindEventHandlers(); }; })(window.BackendCalendar); diff --git a/assets/js/backend_calendar_appointments_modal.js b/assets/js/backend_calendar_appointments_modal.js index ad07eeb6..81e8e593 100755 --- a/assets/js/backend_calendar_appointments_modal.js +++ b/assets/js/backend_calendar_appointments_modal.js @@ -22,7 +22,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa 'use strict'; - function _updateTimezone() { + function updateTimezone() { var providerId = $('#select-provider').val(); var provider = GlobalVariables.availableProviders.filter(function(availableProvider) { @@ -34,7 +34,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa } } - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Manage Appointments Dialog Cancel Button "Click" * @@ -51,7 +51,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa */ $('#manage-appointment #save-appointment').click(function () { // Before doing anything the appointment data need to be validated. - if (!_validateAppointmentForm()) { + if (!validateAppointmentForm()) { return; } @@ -321,7 +321,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa * Event: Provider "Change" */ $('#select-provider').change(function () { - _updateTimezone(); + updateTimezone(); }); /** @@ -488,7 +488,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa * * @return {Boolean} Returns the validation result. */ - function _validateAppointmentForm() { + function validateAppointmentForm() { var $dialog = $('#manage-appointment'); // Reset previous validation css formatting. @@ -532,7 +532,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa } exports.initialize = function () { - _bindEventHandlers(); + bindEventHandlers(); }; })(window.BackendCalendarAppointmentsModal); diff --git a/assets/js/backend_calendar_default_view.js b/assets/js/backend_calendar_default_view.js index 1f538291..e8b43883 100755 --- a/assets/js/backend_calendar_default_view.js +++ b/assets/js/backend_calendar_default_view.js @@ -31,7 +31,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; /** * Bind event handlers for the calendar view. */ - function _bindEventHandlers() { + function bindEventHandlers() { var $calendarPage = $('#calendar-page'); /** @@ -40,7 +40,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * When the user clicks the reload button an the calendar items need to be refreshed. */ $('#reload-appointments').click(function () { - _refreshCalendarAppointments( + refreshCalendarAppointments( $('#calendar'), $('#select-filter-item').val(), $('#select-filter-item').find('option:selected').attr('type'), @@ -264,7 +264,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * * @return {Number} Returns the calendar element height in pixels. */ - function _getCalendarHeight() { + function getCalendarHeight() { var result = window.innerHeight - $('#footer').outerHeight() - $('#header').outerHeight() - $('#calendar-toolbar').outerHeight() - 60; // 60 for fine tuning return (result > 500) ? result : 500; // Minimum height is 500px @@ -276,7 +276,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * When the user clicks on an appointment object on the calendar, then a data preview popover is display * above the calendar item. */ - function _calendarEventClick(event, jsEvent, view) { + function calendarEventClick(event, jsEvent, view) { $('.popover').remove(); // Close all open popovers. var html; @@ -427,7 +427,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * * @see updateAppointmentData() */ - function _calendarEventResize(event, delta, revertFunc, jsEvent, ui, view) { + function calendarEventResize(event, delta, revertFunc, jsEvent, ui, view) { if (GlobalVariables.user.privileges.appointments.edit === false) { revertFunc(); Backend.displayNotification(EALang.no_privileges_edit_appointments); @@ -550,10 +550,10 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * The calendar element needs to be re-sized too in order to fit into the window. Nevertheless, if the window * becomes very small the the calendar won't shrink anymore. * - * @see _getCalendarHeight() + * @see getCalendarHeight() */ - function _calendarWindowResize(view) { - $('#calendar').fullCalendar('option', 'height', _getCalendarHeight()); + function calendarWindowResize(view) { + $('#calendar').fullCalendar('option', 'height', getCalendarHeight()); } /** @@ -562,7 +562,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * When the user clicks on a day square on the calendar, then he will automatically be transferred to that * day view calendar. */ - function _calendarDayClick(date, jsEvent, view) { + function calendarDayClick(date, jsEvent, view) { if (!date.hasTime()) { $('#calendar').fullCalendar('changeView', 'agendaDay'); $('#calendar').fullCalendar('gotoDate', date); @@ -575,7 +575,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * This event handler is triggered whenever the user drags and drops an event into a different position * on the calendar. We need to update the database with this change. This is done via an ajax call. */ - function _calendarEventDrop(event, delta, revertFunc, jsEvent, ui, view) { + function calendarEventDrop(event, delta, revertFunc, jsEvent, ui, view) { if (GlobalVariables.user.privileges.appointments.edit === false) { revertFunc(); Backend.displayNotification(EALang.no_privileges_edit_appointments); @@ -710,12 +710,12 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * Whenever the calendar changes or refreshes its view certain actions need to be made, in order to * display proper information to the user. */ - function _calendarViewRender() { + function calendarViewRender() { if ($('#select-filter-item').val() === null) { return; } - _refreshCalendarAppointments( + refreshCalendarAppointments( $('#calendar'), $('#select-filter-item').val(), $('#select-filter-item option:selected').attr('type'), @@ -743,7 +743,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * not the $.html() method. So in order for the title to display the html properly we convert all the * .fc-event-titles where needed into html. */ - function _convertTitlesToHtml() { + function convertTitlesToHtml() { // Convert the titles to html code. $('.fc-custom').each(function () { var title = $(this).find('.fc-event-title').text(); @@ -764,7 +764,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; * @param {Date} startDate Visible start date of the calendar. * @param {Date} endDate Visible end date of the calendar. */ - function _refreshCalendarAppointments($calendar, recordId, filterType, startDate, endDate) { + function refreshCalendarAppointments($calendar, recordId, filterType, startDate, endDate) { var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_get_calendar_appointments'; var data = { @@ -1165,7 +1165,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; // Initialize page calendar $('#calendar').fullCalendar({ defaultView: defaultView, - height: _getCalendarHeight(), + height: getCalendarHeight(), editable: true, firstDay: firstWeekdayNumber, snapDuration: '00:30:00', @@ -1248,17 +1248,17 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; }, // Calendar events need to be declared on initialization. - windowResize: _calendarWindowResize, - viewRender: _calendarViewRender, - dayClick: _calendarDayClick, - eventClick: _calendarEventClick, - eventResize: _calendarEventResize, - eventDrop: _calendarEventDrop, - eventAfterAllRender: _convertTitlesToHtml + windowResize: calendarWindowResize, + viewRender: calendarViewRender, + dayClick: calendarDayClick, + eventClick: calendarEventClick, + eventResize: calendarEventResize, + eventDrop: calendarEventDrop, + eventAfterAllRender: convertTitlesToHtml }); // Trigger once to set the proper footer position after calendar initialization. - _calendarWindowResize(); + calendarWindowResize(); // Fill the select list boxes of the page. if (GlobalVariables.availableProviders.length > 0) { @@ -1327,7 +1327,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; } // Bind the default event handlers. - _bindEventHandlers(); + bindEventHandlers(); $('#select-filter-item').trigger('change'); @@ -1400,7 +1400,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; var $selectFilterItem = $('#select-filter-item'); setInterval(function () { - _refreshCalendarAppointments( + refreshCalendarAppointments( $calendar, $selectFilterItem.val(), $selectFilterItem.find('option:selected').attr('type'), diff --git a/assets/js/backend_calendar_extra_periods_modal.js b/assets/js/backend_calendar_extra_periods_modal.js index 6335589f..fb1b2928 100644 --- a/assets/js/backend_calendar_extra_periods_modal.js +++ b/assets/js/backend_calendar_extra_periods_modal.js @@ -22,7 +22,7 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa 'use strict'; - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Manage extra Dialog Save Button "Click" * @@ -226,7 +226,7 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa extraProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id)); } - _bindEventHandlers(); + bindEventHandlers(); }; })(window.BackendCalendarExtraPeriodsModal); diff --git a/assets/js/backend_calendar_google_sync.js b/assets/js/backend_calendar_google_sync.js index 94f5aaa9..013744ec 100644 --- a/assets/js/backend_calendar_google_sync.js +++ b/assets/js/backend_calendar_google_sync.js @@ -25,7 +25,7 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; /** * Bind event handlers. */ - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Enable - Disable Synchronization Button "Click" * @@ -97,7 +97,7 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; provider.settings.google_sync = '0'; provider.settings.google_token = null; - _disableProviderSync(provider.id); + disableProviderSync(provider.id); $('#enable-sync').removeClass('btn-danger enabled'); $('#enable-sync span:eq(1)').text(EALang.enable_sync); @@ -166,7 +166,7 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; * * @param {Number} providerId The selected provider record ID. */ - function _disableProviderSync(providerId) { + function disableProviderSync(providerId) { // Make an ajax call to the server in order to disable the setting // from the database. var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_disable_provider_sync'; @@ -182,7 +182,7 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {}; exports.initialize = function () { - _bindEventHandlers(); + bindEventHandlers(); }; })(window.BackendCalendarGoogleSync); diff --git a/assets/js/backend_calendar_unavailabilities_modal.js b/assets/js/backend_calendar_unavailabilities_modal.js index 3d320039..f565d120 100755 --- a/assets/js/backend_calendar_unavailabilities_modal.js +++ b/assets/js/backend_calendar_unavailabilities_modal.js @@ -22,7 +22,7 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili 'use strict'; - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Manage Unavailable Dialog Save Button "Click" * @@ -230,7 +230,7 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili $unavailabilityProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id)); } - _bindEventHandlers(); + bindEventHandlers(); }; })(window.BackendCalendarUnavailabilitiesModal); diff --git a/assets/js/backend_customers.js b/assets/js/backend_customers.js index 2832cb3c..bb1a021e 100644 --- a/assets/js/backend_customers.js +++ b/assets/js/backend_customers.js @@ -47,14 +47,14 @@ window.BackendCustomers = window.BackendCustomers || {}; helper.filter(''); if (defaultEventHandlers) { - _bindEventHandlers(); + bindEventHandlers(); } }; /** * Default event handlers declaration for backend customers page. */ - function _bindEventHandlers() { + function bindEventHandlers() { helper.bindEventHandlers(); } diff --git a/assets/js/backend_services.js b/assets/js/backend_services.js index 172b7dcf..1c4c5f3d 100644 --- a/assets/js/backend_services.js +++ b/assets/js/backend_services.js @@ -35,10 +35,10 @@ window.BackendServices = window.BackendServices || {}; /** * Default initialize method of the page. * - * @param {Boolean} bindEventHandlers Optional (true), determines whether to bind the default event handlers. + * @param {Boolean} [defaultEventHandlers] Optional (true), determines whether to bind the default event handlers. */ - exports.initialize = function (bindEventHandlers) { - bindEventHandlers = bindEventHandlers || true; + exports.initialize = function (defaultEventHandlers) { + defaultEventHandlers = defaultEventHandlers || true; // Fill available service categories listbox. $.each(GlobalVariables.categories, function (index, category) { @@ -52,8 +52,8 @@ window.BackendServices = window.BackendServices || {}; helper.resetForm(); helper.filter(''); - if (bindEventHandlers) { - _bindEventHandlers(); + if (defaultEventHandlers) { + bindEventHandlers(); } }; @@ -62,7 +62,7 @@ window.BackendServices = window.BackendServices || {}; * * Do not use this method if you include the "BackendServices" namespace on another page. */ - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Page Tab Button "Click" * diff --git a/assets/js/backend_settings.js b/assets/js/backend_settings.js index 881f76a1..5525e259 100644 --- a/assets/js/backend_settings.js +++ b/assets/js/backend_settings.js @@ -136,7 +136,7 @@ window.BackendSettings = window.BackendSettings || {}; settings = new SystemSettings(); if (bindEventHandlers) { - _bindEventHandlers(); + bindEventHandlers(); var $link = $('#settings-page .nav li').not('.hidden').first().find('a'); $link.tab('show'); } @@ -160,7 +160,7 @@ window.BackendSettings = window.BackendSettings || {}; * * This method depends on the backend/settings html, so do not use this method on a different page. */ - function _bindEventHandlers() { + function bindEventHandlers() { exports.wp.bindEventHandlers(); /** diff --git a/assets/js/backend_users.js b/assets/js/backend_users.js index 285d76f5..7772f328 100644 --- a/assets/js/backend_users.js +++ b/assets/js/backend_users.js @@ -102,7 +102,7 @@ window.BackendUsers = window.BackendUsers || {}; // Bind event handlers. if (defaultEventHandlers) { - _bindEventHandlers(); + bindEventHandlers(); } }; @@ -110,7 +110,7 @@ window.BackendUsers = window.BackendUsers || {}; * Binds the default backend users event handlers. Do not use this method on a different * page because it needs the backend users page DOM. */ - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Page Tab Button "Click" * diff --git a/assets/js/frontend_book.js b/assets/js/frontend_book.js index c029742f..3f8d9876 100644 --- a/assets/js/frontend_book.js +++ b/assets/js/frontend_book.js @@ -53,8 +53,8 @@ window.FrontendBook = window.FrontendBook || {}; * @param {Boolean} manageMode (OPTIONAL) Determines whether the customer is going * to make changes to an existing appointment rather than booking a new one. */ - exports.initialize = function (bindEventHandlers, manageMode) { - bindEventHandlers = bindEventHandlers || true; + exports.initialize = function (defaultEventHandlers, manageMode) { + defaultEventHandlers = defaultEventHandlers || true; manageMode = manageMode || false; if (window.console) { @@ -147,13 +147,13 @@ window.FrontendBook = window.FrontendBook || {}; $('#select-timezone').val(Intl.DateTimeFormat().resolvedOptions().timeZone); // Bind the event handlers (might not be necessary every time we use this class). - if (bindEventHandlers) { - _bindEventHandlers(); + if (defaultEventHandlers) { + bindEventHandlers(); } // If the manage mode is true, the appointments data should be loaded by default. if (FrontendBook.manageMode) { - _applyAppointmentData(GlobalVariables.appointmentData, + applyAppointmentData(GlobalVariables.appointmentData, GlobalVariables.providerData, GlobalVariables.customerData); } else { var $selectProvider = $('#select-provider'); @@ -196,7 +196,7 @@ window.FrontendBook = window.FrontendBook || {}; /** * This method binds the necessary event handlers for the book appointments page. */ - function _bindEventHandlers() { + function bindEventHandlers() { /** * Event: Timezone "Changed" */ @@ -253,7 +253,7 @@ window.FrontendBook = window.FrontendBook || {}; FrontendBookApi.getUnavailableDates($('#select-provider').val(), $(this).val(), $('#select-date').datepicker('getDate').toString('yyyy-MM-dd')); FrontendBook.updateConfirmFrame(); - _updateServiceDescription($('#select-service').val(), $('#service-description')); + updateServiceDescription($('#select-service').val(), $('#service-description')); }); /** @@ -286,7 +286,7 @@ window.FrontendBook = window.FrontendBook || {}; // If we are on the 3rd tab then we will need to validate the user's // input before proceeding to the next step. if ($(this).attr('data-step_index') === '3') { - if (!_validateCustomerForm()) { + if (!validateCustomerForm()) { return; // Validation failed, do not continue. } else { FrontendBook.updateConfirmFrame(); @@ -457,7 +457,7 @@ window.FrontendBook = window.FrontendBook || {}; * * @return {Boolean} Returns the validation result. */ - function _validateCustomerForm() { + function validateCustomerForm() { $('#wizard-frame-3 .has-error').removeClass('has-error'); $('#wizard-frame-3 label.text-danger').removeClass('text-danger'); @@ -583,7 +583,7 @@ window.FrontendBook = window.FrontendBook || {}; data.appointment = { start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd') + ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00', - end_datetime: _calcEndDatetime(), + end_datetime: calculateEndDatetime(), notes: $('#notes').val(), is_unavailable: false, id_users_provider: $('#select-provider').val(), @@ -606,7 +606,7 @@ window.FrontendBook = window.FrontendBook || {}; * * @return {String} Returns the end datetime in string format. */ - function _calcEndDatetime() { + function calculateEndDatetime() { // Find selected service duration. var serviceId = $('#select-service').val(); var serviceDuration; @@ -643,7 +643,7 @@ window.FrontendBook = window.FrontendBook || {}; * * @return {Boolean} Returns the operation result. */ - function _applyAppointmentData(appointment, provider, customer) { + function applyAppointmentData(appointment, provider, customer) { try { // Select Service & Provider $('#select-service').val(appointment.id_services).trigger('change'); @@ -683,7 +683,7 @@ window.FrontendBook = window.FrontendBook || {}; * @param {Object} $div The destination div jquery object (e.g. provide $('#div-id') * object as value). */ - function _updateServiceDescription(serviceId, $div) { + function updateServiceDescription(serviceId, $div) { var html = ''; $.each(GlobalVariables.availableServices, function (index, service) { diff --git a/assets/js/frontend_book_api.js b/assets/js/frontend_book_api.js index bb2f096f..bd7ce4ce 100755 --- a/assets/js/frontend_book_api.js +++ b/assets/js/frontend_book_api.js @@ -255,16 +255,16 @@ window.FrontendBookApi = window.FrontendBookApi || {}; .done(function (response) { unavailableDatesBackup = response; selectedDateStringBackup = selectedDateString; - _applyUnavailableDates(response, selectedDateString, true); + applyUnavailableDates(response, selectedDateString, true); }) .fail(GeneralFunctions.ajaxFailureHandler); }; exports.applyPreviousUnavailableDates = function () { - _applyUnavailableDates(unavailableDatesBackup, selectedDateStringBackup); + applyUnavailableDates(unavailableDatesBackup, selectedDateStringBackup); }; - function _applyUnavailableDates(unavailableDates, selectedDateString, setDate) { + function applyUnavailableDates(unavailableDates, selectedDateString, setDate) { setDate = setDate || false; processingUnavailabilities = true;