Remove the "ajax_" prefix from all new AJAX endpoints.

This commit is contained in:
Alex Tselegidis 2022-01-17 19:44:44 +01:00
parent c154280026
commit 0da73ab43e
11 changed files with 176 additions and 267 deletions

View file

@ -244,7 +244,7 @@ class Booking extends EA_Controller {
* This method answers to an AJAX request. It calculates the available hours for the given service, provider and
* date.
*/
public function ajax_get_available_hours()
public function get_available_hours()
{
try
{
@ -527,7 +527,7 @@ class Booking extends EA_Controller {
*
* Outputs a JSON string with the unavailable dates. that are unavailable.
*/
public function ajax_get_unavailable_dates()
public function get_unavailable_dates()
{
try
{

View file

@ -153,7 +153,7 @@ class Calendar extends EA_Controller {
/**
* Save appointment changes that are made from the backend calendar page.
*/
public function ajax_save_appointment()
public function save_appointment()
{
try
{
@ -293,7 +293,7 @@ class Calendar extends EA_Controller {
/**
* Insert of update unavailable time period to database.
*/
public function ajax_save_unavailable()
public function save_unavailable()
{
try
{
@ -408,7 +408,7 @@ class Calendar extends EA_Controller {
/**
* Insert of update working plan exceptions to database.
*/
public function ajax_save_working_plan_exception()
public function save_working_plan_exception()
{
try
{
@ -440,7 +440,7 @@ class Calendar extends EA_Controller {
/**
* Delete a working plan exceptions time period to database.
*/
public function ajax_delete_working_plan_exception()
public function delete_working_plan_exception()
{
try
{
@ -472,7 +472,7 @@ class Calendar extends EA_Controller {
*
* This method will return all the calendar events within a specified period.
*/
public function ajax_get_calendar_events()
public function get_calendar_appointments_for_table_view()
{
try
{
@ -562,7 +562,7 @@ class Calendar extends EA_Controller {
* This method returns the database appointments and unavailable periods for the user selected date period and
* record type (provider or service).
*/
public function ajax_get_calendar_appointments()
public function get_calendar_appointments()
{
try
{

View file

@ -32,7 +32,7 @@ class Consents extends EA_Controller {
/**
* Save (insert or update) the consent
*/
public function ajax_save_consent()
public function save_consent()
{
try
{

View file

@ -25,9 +25,9 @@ class Google extends EA_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('google_sync');
$this->load->model('appointments_model');
$this->load->model('providers_model');
$this->load->model('roles_model');
@ -311,18 +311,18 @@ class Google extends EA_Controller {
* The user will need to select a specific calendar from this list to sync his appointments with. Google access must
* be already granted for the specific provider.
*/
public function ajax_get_google_calendars()
public function get_google_calendars()
{
try
{
if ( ! request('provider_id'))
$provider_id = request('provider_id');
if (empty($provider_id))
{
throw new Exception('Provider id is required in order to fetch the google calendars.');
}
// Check if selected provider has sync enabled.
$provider_id = request('provider_id');
$google_sync = $this->providers_model->get_setting($provider_id, 'google_sync');
if ( ! $google_sync)
@ -353,7 +353,7 @@ class Google extends EA_Controller {
*
* All the appointments will be synced with this particular calendar.
*/
public function ajax_select_google_calendar()
public function select_google_calendar()
{
try
{
@ -387,7 +387,7 @@ class Google extends EA_Controller {
*
* After that the provider's appointments will be no longer synced with Google Calendar.
*/
public function ajax_disable_provider_sync()
public function disable_provider_sync()
{
try
{

View file

@ -34,7 +34,7 @@ class Privacy extends EA_Controller {
/**
* Remove all customer data (including appointments) from the system.
*/
public function ajax_delete_personal_information()
public function delete_personal_information()
{
try
{

View file

@ -55,7 +55,7 @@ App.Http.Booking = (function () {
const appointmentId = App.Pages.Booking.manageMode ? App.Vars.appointment_data.id : null;
// Make ajax post request and get the available hours.
const url = App.Utils.Url.siteUrl('booking/ajax_get_available_hours');
const url = App.Utils.Url.siteUrl('booking/get_available_hours');
const data = {
csrf_token: App.Vars.csrf_token,
@ -238,7 +238,7 @@ App.Http.Booking = (function () {
const appointmentId = App.Pages.Booking.manageMode ? App.Vars.appointment_data.id : null;
const url = App.Utils.Url.siteUrl('booking/ajax_get_unavailable_dates');
const url = App.Utils.Url.siteUrl('booking/get_unavailable_dates');
const data = {
provider_id: providerId,
@ -308,7 +308,7 @@ App.Http.Booking = (function () {
* @param {Object} consent Contains user's consents.
*/
function saveConsent(consent) {
const url = App.Utils.Url.siteUrl('consents/ajax_save_consent');
const url = App.Utils.Url.siteUrl('consents/save_consent');
const data = {
csrf_token: App.Vars.csrf_token,
@ -324,7 +324,7 @@ App.Http.Booking = (function () {
* @param {Number} customerToken Customer unique token.
*/
function deletePersonalInformation(customerToken) {
const url = App.Utils.Url.siteUrl('privacy/ajax_delete_personal_information');
const url = App.Utils.Url.siteUrl('privacy/delete_personal_information');
const data = {
csrf_token: App.Vars.csrf_token,

View file

@ -27,9 +27,11 @@ App.Http.Calendar = (function () {
* @param {Object} [customer] Optional, contains the customer data.
* @param {Function} [successCallback] Optional, if defined, this function is going to be executed on post success.
* @param {Function} [errorCallback] Optional, if defined, this function is going to be executed on post failure.
*
* @return {*|jQuery.jqXHR}
*/
function saveAppointment(appointment, customer, successCallback, errorCallback) {
const url = App.Utils.Url.siteUrl('calendar/ajax_save_appointment');
const url = App.Utils.Url.siteUrl('calendar/save_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
@ -53,15 +55,35 @@ App.Http.Calendar = (function () {
});
}
/**
* Remove an appointment.
*
* @param {Number} appointmentId
* @param {String} deleteReason
*
* @return {jQuery.jqXHR}
*/
function deleteAppointment(appointmentId, deleteReason) {
const url = App.Utils.Url.siteUrl('calendar/delete_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
appointment_id: appointmentId,
delete_reason: deleteReason
};
return $.post(url, data);
}
/**
* Save unavailable period to database.
*
* @param {Object} unavailable Contains the unavailable period data.
* @param {Function} successCallback The ajax success callback function.
* @param {Function} errorCallback The ajax failure callback function.
* @param {Function} [successCallback] The ajax success callback function.
* @param {Function} [errorCallback] The ajax failure callback function.
*/
function saveUnavailable(unavailable, successCallback, errorCallback) {
const url = App.Utils.Url.siteUrl('calendar/ajax_save_unavailable');
const url = App.Utils.Url.siteUrl('calendar/save_unavailable');
const data = {
csrf_token: App.Vars.csrf_token,
@ -81,6 +103,24 @@ App.Http.Calendar = (function () {
});
}
/**
* Remove an unavailable.
*
* @param {Number} unavailableId
*
* @return {jQuery.jqXHR}
*/
function deleteUnavailable(unavailableId) {
const url = App.Utils.Url.siteUrl('calendar/delete_unavailable');
const data = {
csrf_token: App.Vars.csrf_token,
unavailable_id: unavailableId
};
return $.post(url, data);
}
/**
* Save working plan exception of work to database.
*
@ -91,7 +131,7 @@ App.Http.Calendar = (function () {
* @param {Function} errorCallback The ajax failure callback function.
*/
function saveWorkingPlanException(date, workingPlanException, providerId, successCallback, errorCallback) {
const url = App.Utils.Url.siteUrl('calendar/ajax_save_working_plan_exception');
const url = App.Utils.Url.siteUrl('calendar/save_working_plan_exception');
const data = {
csrf_token: App.Vars.csrf_token,
@ -113,8 +153,18 @@ App.Http.Calendar = (function () {
});
}
/**
* Delete working plan exception
*
* @param {String} date
* @param {Number} providerId
* @param {Function} [successCallback]
* @param {Function} [errorCallback]
*
* @return {*|jQuery.jqXHR}
*/
function deleteWorkingPlanException(date, providerId, successCallback, errorCallback) {
const url = App.Utils.Url.siteUrl('calendar/ajax_delete_working_plan_exception');
const url = App.Utils.Url.siteUrl('calendar/delete_working_plan_exception');
const data = {
csrf_token: App.Vars.csrf_token,
@ -135,10 +185,58 @@ App.Http.Calendar = (function () {
});
}
/**
* Get the appointments for the displayed calendar period.
*
* @param {Number} recordId Record ID (provider or service).
* @param {String} filterType The filter type, could be either "provider" or "service".
* @param {String} startDate Visible start date of the calendar.
* @param {String} endDate Visible end date of the calendar.
*
* @returns {jQuery.jqXHR}
*/
function getCalendarAppointments(recordId, startDate, endDate, filterType) {
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments');
const data = {
csrf_token: App.Vars.csrf_token,
record_id: recordId,
start_date: moment(startDate).format('YYYY-MM-DD'),
end_date: moment(endDate).format('YYYY-MM-DD'),
filter_type: filterType
};
return $.post(url, data);
}
/**
* Get the calendar appointments for the table view (different data structure).
*
* @param {Date} startDate
* @param {Date} endDate
*
* @return {*|jQuery.jqXHR}
*/
function getCalendarAppointmentsForTableView(startDate, endDate) {
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments_for_table_view');
const data = {
csrf_token: App.Vars.csrf_token,
startDate: moment(startDate).format('YYYY-MM-DD'),
endDate: moment(endDate).format('YYYY-MM-DD')
};
return $.post(url, data);
}
return {
saveAppointment,
deleteAppointment,
saveUnavailable,
deleteUnavailable,
saveWorkingPlanException,
deleteWorkingPlanException
deleteWorkingPlanException,
getCalendarAppointments,
getCalendarAppointmentsForTableView
};
})();

View file

@ -178,9 +178,6 @@ App.Utils.CalendarDefaultView = (function () {
$target.parents('.popover').popover('dispose');
let url;
let data;
if (lastFocusedEventData.data.workingPlanException) {
const providerId = $selectFilterItem.val();
@ -224,15 +221,11 @@ App.Utils.CalendarDefaultView = (function () {
{
text: 'OK',
click: () => {
url = App.Utils.Url.siteUrl('calendar/ajax_delete_appointment');
const appointmentId = lastFocusedEventData.data.id;
data = {
csrf_token: App.Vars.csrf_token,
appointment_id: lastFocusedEventData.data.id,
delete_reason: $('#delete-reason').val()
};
const deleteReason = $('#delete-reason').val();
$.post(url, data).done(() => {
App.Http.Calendar.deleteAppointment(appointmentId, deleteReason).done(() => {
$('#message-box').dialog('close');
// Refresh calendar event items.
@ -255,14 +248,10 @@ App.Utils.CalendarDefaultView = (function () {
}).appendTo('#message-box');
} else {
// Do not display confirmation prompt.
url = App.Utils.Url.siteUrl('calendar/ajax_delete_unavailable');
data = {
csrf_token: App.Vars.csrf_token,
unavailable_id: lastFocusedEventData.data.id
};
const unavailableId = lastFocusedEventData.data.id;
$.post(url, data).done(() => {
App.Http.Calendar.deleteUnavailable(unavailableId).done(() => {
$('#message-box').dialog('close');
// Refresh calendar event items.
@ -773,14 +762,7 @@ App.Utils.CalendarDefaultView = (function () {
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
.format('YYYY-MM-DD HH:mm:ss');
const url = App.Utils.Url.siteUrl('calendar/ajax_save_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
appointment_data: appointment
};
$.post(url, data).done(() => {
App.Http.Calendar.saveAppointment(appointment).done(() => {
$notification.hide('blind');
});
@ -822,14 +804,7 @@ App.Utils.CalendarDefaultView = (function () {
unavailable.is_unavailable = Number(unavailable.is_unavailable);
const url = App.Utils.Url.siteUrl('calendar/ajax_save_unavailable');
const data = {
csrf_token: App.Vars.csrf_token,
unavailable: unavailable
};
$.post(url, data).done(() => {
App.Http.Calendar.saveAppointment(unavailable).done(() => {
$notification.hide('blind');
});
@ -940,14 +915,7 @@ App.Utils.CalendarDefaultView = (function () {
event.data.start_datetime = appointment.start_datetime;
event.data.end_datetime = appointment.end_datetime;
const url = App.Utils.Url.siteUrl('calendar/ajax_save_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
appointment_data: appointment
};
$.post(url, data).done(() => {
App.Http.Calendar.saveAppointment(appointment).done(() => {
$notification.hide('blind');
});
@ -990,14 +958,7 @@ App.Utils.CalendarDefaultView = (function () {
event.data.start_datetime = unavailable.start_datetime;
event.data.end_datetime = unavailable.end_datetime;
const url = App.Utils.Url.siteUrl('calendar/ajax_save_unavailable');
const data = {
csrf_token: App.Vars.csrf_token,
unavailable: unavailable
};
$.post(url, data).done(() => {
App.Http.Calendar.saveUnavailable(unavailable).done(() => {
$notification.hide('blind');
});
@ -1076,25 +1037,19 @@ App.Utils.CalendarDefaultView = (function () {
* @param {Object} $calendar The calendar jQuery object.
* @param {Number} recordId The selected record id.
* @param {String} filterType The filter type, could be either FILTER_TYPE_PROVIDER or FILTER_TYPE_SERVICE.
* @param {Date} startDate Visible start date of the calendar.
* @param {Date} endDate Visible end date of the calendar.
* @param {String} startDate Visible start date of the calendar.
* @param {String} endDate Visible end date of the calendar.
*/
function refreshCalendarAppointments($calendar, recordId, filterType, startDate, endDate) {
const url = App.Utils.Url.siteUrl('calendar/ajax_get_calendar_appointments');
const data = {
csrf_token: App.Vars.csrf_token,
record_id: recordId,
start_date: moment(startDate).format('YYYY-MM-DD'),
end_date: moment(endDate).format('YYYY-MM-DD'),
filter_type: filterType
};
$('#loading').css('visibility', 'hidden');
const calendarEventSource = [];
return $.post(url, data)
startDate = moment(startDate).format('YYYY-MM-DD');
endDate = moment(endDate).format('YYYY-MM-DD');
App.Http.Calendar.getCalendarAppointments(recordId, filterType, startDate, endDate)
.done((response) => {
$calendar.fullCalendar('removeEvents');

View file

@ -17,6 +17,8 @@
* Old Name: BackendCalendarGoogleSync
*/
App.Utils.CalendarGoogleSync = (function () {
const $selectFilterItem = $('#select-filter-item');
/**
* Add the utility event listeners.
*/
@ -54,14 +56,9 @@ App.Utils.CalendarGoogleSync = (function () {
// Display the calendar selection dialog. First we will get a list of the available
// user's calendars and then we will display a selection modal so the user can select
// the sync calendar.
const url = App.Utils.Url.siteUrl('backend_api/ajax_get_google_calendars');
const providerId = $('#select-filter-item').val();
const data = {
csrf_token: App.Vars.csrf_token,
provider_id: $('#select-filter-item').val()
};
$.post(url, data).done((response) => {
App.Http.Google.getGoogleCalendars(providerId).done((response) => {
$('#google-calendar').empty();
response.forEach((calendar) => {
@ -103,7 +100,7 @@ App.Utils.CalendarGoogleSync = (function () {
provider.settings.google_sync = '0';
provider.settings.google_token = null;
disableProviderSync(provider.id);
App.Http.Google.disableProviderSync(provider.id);
$('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light');
$('#enable-sync span').text(App.Lang.enable_sync);
@ -123,14 +120,11 @@ App.Utils.CalendarGoogleSync = (function () {
* Event: Select Google Calendar "Click"
*/
$('#select-calendar').on('click', () => {
const url = App.Utils.Url.siteUrl('backend_api/ajax_select_google_calendar');
const providerId = $('#select-filter-item').val();
const data = {
csrf_token: App.Vars.csrf_token,
provider_id: $('#select-filter-item').val(),
calendar_id: $('#google-calendar').val()
};
$.post(url, data).done(() => {
const calendarId = $('#google-calendar').val();
App.Http.Google.selectGoogleCalendar(providerId, calendarId).done(() => {
App.Layouts.Backend.displayNotification(App.Lang.google_calendar_selected);
$('#select-google-calendar').modal('hide');
});
@ -142,13 +136,9 @@ App.Utils.CalendarGoogleSync = (function () {
* Trigger the synchronization algorithm.
*/
$('#google-sync').on('click', () => {
const url = App.Utils.Url.siteUrl('google/sync/' + $('#select-filter-item').val());
const providerId = $selectFilterItem.val();
$.ajax({
url: url,
type: 'GET',
dataType: 'json'
})
App.Http.Google.syncWithGoogle(providerId)
.done(() => {
App.Layouts.Backend.displayNotification(App.Lang.google_sync_completed);
$('#reload-appointments').trigger('click');
@ -159,25 +149,6 @@ App.Utils.CalendarGoogleSync = (function () {
});
}
/**
* Disable Provider Sync
*
* This method disables the Google synchronization for a specific provider.
*
* @param {Number} providerId The selected provider record ID.
*/
function disableProviderSync(providerId) {
// Make an ajax call to the server in order to disable the setting from the database.
const url = App.Utils.Url.siteUrl('backend_api/ajax_disable_provider_sync');
const data = {
csrf_token: App.Vars.csrf_token,
provider_id: providerId
};
$.post(url, data);
}
/**
* Initialize the module.
*/

View file

@ -66,7 +66,7 @@ App.Utils.CalendarTableView = (function () {
const endDateMoment = startDateMoment.clone().add(dayInterval - 1, 'days');
const endDate = endDateMoment.toDate();
getCalendarEvents(startDate, endDate).done((response) => {
App.Http.Calendar.getCalendarAppointmentsForTableView(startDate, endDate).done((response) => {
const currentDate = startDate;
while (currentDate <= endDate) {
@ -247,27 +247,23 @@ App.Utils.CalendarTableView = (function () {
$calendar.on('click', '.delete-popover', (event) => {
$(event.target).parents('.popover').popover('dispose'); // Hide the popover.
let url;
let data;
// If id_role parameter exists the popover is an working plan exception.
if (lastFocusedEventData.data.hasOwnProperty('id_roles')) {
// Do not display confirmation prompt.
url = App.Utils.Url.siteUrl + '/index.php/backend_api/ajax_delete_working_plan_exception';
data = {
csrf_token: App.Vars.csrf_token,
working_plan_exception: lastFocusedEventData.start.format('YYYY-MM-DD'),
provider_id: lastFocusedEventData.data.id
};
const date = lastFocusedEventData.start.format('YYYY-MM-DD');
$.post(url, data).done(() => {
const providerId = lastFocusedEventData.data.id;
App.Http.Calendar.deleteWorkingPlanException(date, providerId).done(() => {
$('#message-box').dialog('close');
const workingPlanExceptions = JSON.parse(
lastFocusedEventData.data.settings.working_plan_exceptions
);
delete workingPlanExceptions[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
// Refresh calendar event items.
@ -284,15 +280,11 @@ App.Utils.CalendarTableView = (function () {
{
text: 'OK',
click: () => {
url = App.Utils.Url.siteUrl('backend_api/ajax_delete_appointment');
const appointmentId = lastFocusedEventData.data.id;
data = {
csrf_token: App.Vars.csrf_token,
appointment_id: lastFocusedEventData.data.id,
delete_reason: $('#delete-reason').val()
};
const deleteReason = $('#delete-reason').val();
$.post(url, data).done(() => {
App.Http.Calendar.deleteAppointment(appointmentId, deleteReason).done(() => {
$('#message-box').dialog('close');
// Refresh calendar event items.
@ -315,14 +307,9 @@ App.Utils.CalendarTableView = (function () {
}).appendTo('#message-box');
} else {
// Do not display confirmation prompt.
url = App.Utils.Url.siteUrl + '/index.php/backend_api/ajax_delete_unavailable';
const unavailableId = lastFocusedEventData.data.id;
data = {
csrf_token: App.Vars.csrf_token,
unavailable_id: lastFocusedEventData.data.id
};
$.post(url, data).done(() => {
App.Http.Calendar.deleteUnavailable(unavailableId).done(() => {
$('#message-box').dialog('close');
// Refresh calendar event items.
@ -1530,14 +1517,7 @@ App.Utils.CalendarTableView = (function () {
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
.format('YYYY-MM-DD HH:mm:ss');
const url = App.Utils.Url.siteUrl('backend_api/ajax_save_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
appointment_data: JSON.stringify(appointment)
};
$.post(url, data).done(() => {
App.Http.Calendar.saveAppointment(appointment).done(() => {
$('#notification').hide('blind');
});
@ -1577,14 +1557,7 @@ App.Utils.CalendarTableView = (function () {
.add({minutes: -delta.minutes()})
.format('YYYY-MM-DD HH:mm:ss');
const url = App.Utils.Url.siteUrl + '/index.php/backend_api/ajax_save_unavailable';
const data = {
csrf_token: App.Vars.csrf_token,
unavailable: JSON.stringify(unavailable)
};
$.post(url, data).done(() => {
App.Http.Calendar.saveUnavailable(unavailable).done(() => {
$('#notification').hide('blind');
});
@ -1662,14 +1635,7 @@ App.Utils.CalendarTableView = (function () {
event.data.start_datetime = appointment.start_datetime;
event.data.end_datetime = appointment.end_datetime;
const url = App.Utils.Url.siteUrl('backend_api/ajax_save_appointment');
const data = {
csrf_token: App.Vars.csrf_token,
appointment_data: JSON.stringify(appointment)
};
$.post(url, data).done(() => {
App.Http.Calendar.saveAppointment(appointment).done(() => {
$('#notification').hide('blind');
});
@ -1710,14 +1676,7 @@ App.Utils.CalendarTableView = (function () {
event.data.start_datetime = unavailable.start_datetime;
event.data.end_datetime = unavailable.end_datetime;
const url = App.Utils.Url.siteUrl + '/index.php/backend_api/ajax_save_unavailable';
const data = {
csrf_token: App.Vars.csrf_token,
unavailable: JSON.stringify(unavailable)
};
$.post(url, data).done(() => {
App.Http.Calendar.saveUnavailable(unavailable).done(() => {
$('#notification').hide('blind');
});
@ -1775,36 +1734,6 @@ App.Utils.CalendarTableView = (function () {
$('.calendar-view .not-working').outerHeight((dateColumnHeight > height ? dateColumnHeight : height) - 70);
}
/**
* Get the calendar events.
*
* @param {Date} startDate The start date of the selected period.
* @param {Date} endDate The end date of the selected period.
*
* @return {jQuery.jqXHR}
*/
function getCalendarEvents(startDate, endDate) {
const url = App.Utils.Url.siteUrl('backend_api/ajax_get_calendar_events');
const data = {
csrf_token: App.Vars.csrf_token,
startDate: moment(startDate).format('YYYY-MM-DD'),
endDate: moment(endDate).format('YYYY-MM-DD')
};
return $.ajax({
url: url,
data: data,
method: 'POST',
beforeSend: () => {
// $('#loading').css('visibility', 'hidden');
},
complete: () => {
// $('#loading').css('visibility', '');
}
});
}
/**
* Initialize Page
*/

View file

@ -252,58 +252,14 @@ window.GeneralFunctions = window.GeneralFunctions || {};
* This method requires the global variable 'availableLanguages' to be initialized before the execution.
*
* @param {Object} $element Selected element button for the language selection.
*
* @deprecated Since 1.5
*/
exports.enableLanguageSelection = function ($element) {
// Select Language
var $languageList = $('<ul/>', {
'id': 'language-list',
'html': availableLanguages.map(function (availableLanguage) {
return $('<li/>', {
'class': 'language',
'data-language': availableLanguage,
'text': GeneralFunctions.upperCaseFirstLetter(availableLanguage)
});
})
});
$element.popover({
placement: 'top',
title: 'Select Language',
content: $languageList[0],
html: true,
container: 'body',
trigger: 'manual'
});
$element.on('click', function (event) {
event.stopPropagation();
if ($('#language-list').length === 0) {
$(this).popover('show');
} else {
$(this).popover('hide');
}
$(this).toggleClass('active');
});
$(document).on('click', 'li.language', function () {
// Change language with ajax call and refresh page.
var url = App.Vars.base_url + '/index.php/backend_api/ajax_change_language';
var data = {
csrf_token: App.Vars.csrf_token,
language: $(this).attr('data-language')
};
$.post(url, data).done(function () {
document.location.reload(true);
});
});
$(document).on('click', function () {
$element.popover('hide');
});
console.warn(
`Call of deprecated GeneralFunctions.enableLanguageSelection method! Please use the App.Utils.Lang.enableLanguageSelection instead as this method will be removed soon.`
);
App.Utils.Lang.enableLanguageSelection($element);
};
/**