MaketRandevu/assets/js/backend.js

138 lines
3.9 KiB
JavaScript
Raw Normal View History

2015-07-20 22:41:24 +03:00
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
2015-07-20 22:41:24 +03:00
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
2015-07-20 22:41:24 +03:00
* @link http://easyappointments.org
* @since v1.0.0
* ---------------------------------------------------------------------------- */
2016-04-24 19:58:35 +03:00
window.Backend = window.Backend || {};
2016-01-01 22:57:44 +02:00
2018-01-23 12:08:37 +03:00
/**
* Backend
*
* This module contains functions that are used in the backend section of the application.
*
* @module Backend
*/
(function (exports) {
2016-04-24 19:58:35 +03:00
'use strict';
2016-04-24 19:58:35 +03:00
/**
* Main javascript code for the backend of Easy!Appointments.
*/
2020-10-22 12:29:09 +03:00
$(function () {
$(window)
2018-01-23 12:08:37 +03:00
.on('resize', function () {
Backend.placeFooterToBottom();
})
.trigger('resize');
2016-04-24 19:58:35 +03:00
2018-01-23 12:08:37 +03:00
$(document).ajaxStart(function () {
2016-04-24 19:58:35 +03:00
$('#loading').show();
});
2018-01-23 12:08:37 +03:00
$(document).ajaxStop(function () {
2016-04-24 19:58:35 +03:00
$('#loading').hide();
});
2020-10-22 12:29:09 +03:00
tippy('[data-tippy-content]');
2016-04-24 19:58:35 +03:00
GeneralFunctions.enableLanguageSelection($('#select-language'));
});
/**
* Backend Constants
*/
2016-04-24 19:58:35 +03:00
exports.DB_SLUG_ADMIN = 'admin';
exports.DB_SLUG_PROVIDER = 'provider';
exports.DB_SLUG_SECRETARY = 'secretary';
exports.DB_SLUG_CUSTOMER = 'customer';
exports.PRIV_VIEW = 1;
exports.PRIV_ADD = 2;
exports.PRIV_EDIT = 4;
exports.PRIV_DELETE = 8;
exports.PRIV_APPOINTMENTS = 'appointments';
exports.PRIV_CUSTOMERS = 'customers';
exports.PRIV_SERVICES = 'services';
exports.PRIV_USERS = 'users';
exports.PRIV_SYSTEM_SETTINGS = 'system_settings';
exports.PRIV_USER_SETTINGS = 'user_settings';
/**
* Place the backend footer always on the bottom of the page.
*/
2018-01-23 12:08:37 +03:00
exports.placeFooterToBottom = function () {
var $footer = $('#footer');
if (window.innerHeight > $('body').height()) {
$footer.css({
'position': 'absolute',
'width': '100%',
'bottom': '0px'
});
} else {
$footer.css({
'position': 'static'
});
}
2016-04-24 19:58:35 +03:00
};
/**
* Display backend notifications to user.
*
* Using this method you can display notifications to the use with custom messages. If the 'actions' array is
* provided then an action link will be displayed too.
*
* @param {String} message Notification message
* @param {Array} [actions] An array with custom actions that will be available to the user. Every array item is an
* object that contains the 'label' and 'function' key values.
*/
2018-01-23 12:08:37 +03:00
exports.displayNotification = function (message, actions) {
message = message || '- No message provided for this notification -';
var $notification = $('#notification');
if (!actions) {
actions = [];
2018-01-23 12:08:37 +03:00
setTimeout(function () {
$notification.fadeOut();
}, 5000);
}
$notification.empty();
var $instance = $('<div/>', {
'class': 'notification alert',
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn-close',
'data-dismiss': 'alert'
}),
$('<strong/>', {
'html': message
})
]
}).appendTo($notification);
2020-12-09 15:17:45 +03:00
actions.forEach(function (action) {
$('<button/>', {
'class': 'btn btn-outline-secondary btn-xs',
'text': action.label,
'on': {
'click': action.function
}
}).appendTo($instance);
});
$notification.show('fade');
};
2016-04-24 19:58:35 +03:00
})(window.Backend);