2015-07-20 22:41:24 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
2015-10-11 23:13:36 +03:00
|
|
|
*
|
2015-07-20 22:41:24 +03:00
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2016-01-02 15:47:04 +02:00
|
|
|
* @copyright Copyright (c) 2013 - 2016, Alex Tselegidis
|
2015-10-11 23:13:36 +03:00
|
|
|
* @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
|
|
|
|
* ---------------------------------------------------------------------------- */
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2016-04-24 19:58:35 +03:00
|
|
|
window.Backend = window.Backend || {};
|
2016-01-01 22:57:44 +02:00
|
|
|
|
2016-04-24 19:58:35 +03:00
|
|
|
/**
|
|
|
|
* This module contains functions that are used in the backend section of
|
|
|
|
* the application.
|
|
|
|
*
|
|
|
|
* @module Backend
|
|
|
|
*/
|
|
|
|
(function(exports) {
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2016-04-24 19:58:35 +03:00
|
|
|
'use strict';
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2016-04-24 19:58:35 +03:00
|
|
|
/**
|
|
|
|
* Main javascript code for the backend of Easy!Appointments.
|
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
if (window.console === undefined) {
|
|
|
|
window.console = function() {} // IE compatibility
|
2013-10-18 17:56:12 +03:00
|
|
|
}
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2016-04-24 19:58:35 +03:00
|
|
|
$(window).resize(function() {
|
|
|
|
Backend.placeFooterToBottom();
|
|
|
|
}).trigger('resize');
|
|
|
|
|
|
|
|
$(document).ajaxStart(function() {
|
|
|
|
$('#loading').show();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).ajaxStop(function() {
|
|
|
|
$('#loading').hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.menu-item').qtip({
|
|
|
|
position: {
|
|
|
|
my: 'top center',
|
|
|
|
at: 'bottom center'
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
classes: 'qtip-green qtip-shadow custom-qtip'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
GeneralFunctions.enableLanguageSelection($('#select-language'));
|
|
|
|
});
|
2013-06-12 18:31:16 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
/**
|
|
|
|
* 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';
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
|
|
|
* Place the backend footer always on the bottom of the page.
|
|
|
|
*/
|
2016-04-24 19:58:35 +03:00
|
|
|
exports.placeFooterToBottom = function() {
|
2013-09-20 16:58:11 +03:00
|
|
|
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
|
|
|
};
|
2013-06-18 19:06:34 +03:00
|
|
|
|
|
|
|
/**
|
2015-10-11 23:13:36 +03:00
|
|
|
* Display backend notifications to user.
|
|
|
|
*
|
2013-06-18 19:06:34 +03:00
|
|
|
* Using this method you can display notifications to the use with custom
|
2015-10-11 23:13:36 +03:00
|
|
|
* messages. If the 'actions' array is provided then an action link will
|
2013-06-18 19:06:34 +03:00
|
|
|
* be displayed too.
|
2015-10-11 23:13:36 +03:00
|
|
|
*
|
2013-06-18 19:06:34 +03:00
|
|
|
* @param {string} message Notification message
|
|
|
|
* @param {array} actions An array with custom actions that will be available
|
2015-10-11 23:13:36 +03:00
|
|
|
* to the user. Every array item is an object that contains the 'label' and
|
2013-06-18 19:06:34 +03:00
|
|
|
* 'function' key values.
|
|
|
|
*/
|
2016-04-24 19:58:35 +03:00
|
|
|
exports.displayNotification = function(message, actions) {
|
2013-09-26 19:06:57 +03:00
|
|
|
if (message == undefined) {
|
2013-06-18 19:06:34 +03:00
|
|
|
message = 'NO MESSAGE PROVIDED FOR THIS NOTIFICATION';
|
|
|
|
}
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
if (actions == undefined) {
|
2013-07-15 10:32:19 +03:00
|
|
|
actions = [];
|
2013-09-26 19:06:57 +03:00
|
|
|
setTimeout(function() {
|
|
|
|
$('#notification').slideUp('slow');
|
|
|
|
}, 7000);
|
2013-07-15 10:32:19 +03:00
|
|
|
}
|
2015-10-11 23:13:36 +03:00
|
|
|
|
|
|
|
var notificationHtml =
|
|
|
|
'<div class="notification alert">' +
|
2013-06-18 19:06:34 +03:00
|
|
|
'<strong>' + message + '</strong>';
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
$.each(actions, function(index, action) {
|
|
|
|
var actionId = action['label'].toLowerCase().replace(' ', '-');
|
2015-10-11 23:13:36 +03:00
|
|
|
notificationHtml += '<button id="' + actionId + '" class="btn btn-default btn-xs">'
|
2013-06-18 19:06:34 +03:00
|
|
|
+ action['label'] + '</button>';
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
$(document).off('click', '#' + actionId);
|
|
|
|
$(document).on('click', '#' + actionId, action['function']);
|
|
|
|
});
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-09-13 16:21:03 +03:00
|
|
|
notificationHtml += '<a class="close" data-dismiss="alert" href="#">×</a></div>';
|
2015-10-11 23:13:36 +03:00
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
$('#notification').html(notificationHtml);
|
|
|
|
$('#notification').show('blind');
|
2013-06-12 18:31:16 +03:00
|
|
|
}
|
2016-04-24 19:58:35 +03:00
|
|
|
|
|
|
|
})(window.Backend);
|