2015-07-20 22:41:24 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2013 - 2015, Alex Tselegidis
|
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.0.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2013-06-12 18:31:16 +03:00
|
|
|
/**
|
2013-07-03 20:27:00 +03:00
|
|
|
* Main javascript code for the backend of Easy!Appointments.
|
2013-06-12 18:31:16 +03:00
|
|
|
*/
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(window).resize(function() {
|
2013-06-13 19:25:34 +03:00
|
|
|
Backend.placeFooterToBottom();
|
2013-06-12 18:31:16 +03:00
|
|
|
}).trigger('resize');
|
2013-06-28 17:23:17 +03:00
|
|
|
|
|
|
|
$(document).ajaxStart(function() {
|
|
|
|
$('#loading').show();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).ajaxStop(function() {
|
|
|
|
$('#loading').hide();
|
|
|
|
});
|
2013-10-18 17:56:12 +03:00
|
|
|
|
|
|
|
$('.menu-item').qtip({
|
|
|
|
position: {
|
|
|
|
my: 'top center',
|
|
|
|
at: 'bottom center'
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
classes: 'qtip-green qtip-shadow custom-qtip'
|
|
|
|
}
|
|
|
|
});
|
2013-12-23 18:55:42 +02:00
|
|
|
|
|
|
|
GeneralFunctions.enableLanguageSelection($('#select-language'));
|
2013-06-12 18:31:16 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2013-06-13 19:25:34 +03:00
|
|
|
* This namespace contains functions that are used in the backend section of
|
|
|
|
* the applications.
|
|
|
|
*
|
|
|
|
* @namespace Backend
|
2013-06-12 18:31:16 +03:00
|
|
|
*/
|
2013-06-13 19:25:34 +03:00
|
|
|
var Backend = {
|
2013-07-09 17:46:48 +03:00
|
|
|
/**
|
|
|
|
* Backend Constants
|
|
|
|
*/
|
2013-09-14 19:10:59 +03:00
|
|
|
DB_SLUG_ADMIN: 'admin',
|
|
|
|
DB_SLUG_PROVIDER: 'provider',
|
|
|
|
DB_SLUG_SECRETARY: 'secretary',
|
|
|
|
DB_SLUG_CUSTOMER: 'customer',
|
2013-07-09 17:46:48 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
PRIV_VIEW: 1,
|
|
|
|
PRIV_ADD: 2,
|
|
|
|
PRIV_EDIT: 4,
|
|
|
|
PRIV_DELETE: 8,
|
|
|
|
|
2013-09-27 15:49:29 +03:00
|
|
|
PRIV_APPOINTMENTS: 'appointments',
|
|
|
|
PRIV_CUSTOMERS: 'customers',
|
|
|
|
PRIV_SERVICES: 'services',
|
|
|
|
PRIV_USERS: 'users',
|
|
|
|
PRIV_SYSTEM_SETTINGS: 'system_settings',
|
|
|
|
PRIV_USER_SETTINGS: 'user_settings',
|
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
|
|
|
* Place the backend footer always on the bottom of the page.
|
|
|
|
*/
|
|
|
|
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'
|
|
|
|
});
|
|
|
|
}
|
2013-06-18 19:06:34 +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.
|
|
|
|
*/
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
var notificationHtml =
|
|
|
|
'<div class="notification alert">' +
|
|
|
|
'<strong>' + message + '</strong>';
|
|
|
|
|
|
|
|
$.each(actions, function(index, action) {
|
|
|
|
var actionId = action['label'].toLowerCase().replace(' ', '-');
|
2015-07-22 23:24:31 +03:00
|
|
|
notificationHtml += '<button id="' + actionId + '" class="btn btn-xs">'
|
2013-06-18 19:06:34 +03:00
|
|
|
+ action['label'] + '</button>';
|
|
|
|
|
|
|
|
$(document).off('click', '#' + actionId);
|
|
|
|
$(document).on('click', '#' + actionId, action['function']);
|
|
|
|
});
|
|
|
|
|
2013-09-13 16:21:03 +03:00
|
|
|
notificationHtml += '<a class="close" data-dismiss="alert" href="#">×</a></div>';
|
2013-06-18 19:06:34 +03:00
|
|
|
|
|
|
|
$('#notification').html(notificationHtml);
|
|
|
|
$('#notification').show('blind');
|
2013-06-12 18:31:16 +03:00
|
|
|
}
|
2013-06-18 19:06:34 +03:00
|
|
|
};
|