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-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
|
|
|
|
*/
|
|
|
|
EXCEPTIONS_TITLE: 'Unexpected Issues',
|
|
|
|
EXCEPTIONS_MESSAGE: 'The operation could not complete due to unexpected issues. ',
|
|
|
|
WARNINGS_TITLE: 'Unexpected Warnings',
|
|
|
|
WARNINGS_MESSAGE: 'The operation completed but some warnings appeared. ',
|
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
|
|
|
* Place the backend footer always on the bottom of the page.
|
|
|
|
*/
|
|
|
|
placeFooterToBottom: function() {
|
2013-07-06 03:00:04 +03:00
|
|
|
var $footer = $('#footer');
|
2013-06-13 19:25:34 +03:00
|
|
|
|
|
|
|
if (window.innerHeight > $('body').height()) {
|
2013-07-06 03:00:04 +03:00
|
|
|
$footer.css({
|
2013-07-03 20:27:00 +03:00
|
|
|
'position': 'absolute',
|
|
|
|
'width': '100%',
|
|
|
|
'bottom': '0px'
|
2013-06-13 19:25:34 +03:00
|
|
|
});
|
|
|
|
} else {
|
2013-07-06 03:00:04 +03:00
|
|
|
$footer.css({
|
2013-07-03 20:27:00 +03:00
|
|
|
'position': 'static'
|
2013-06-13 19:25:34 +03:00
|
|
|
});
|
|
|
|
}
|
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) {
|
|
|
|
if (message === undefined) {
|
|
|
|
message = 'NO MESSAGE PROVIDED FOR THIS NOTIFICATION';
|
|
|
|
}
|
|
|
|
|
|
|
|
var notificationHtml =
|
|
|
|
'<div class="notification alert">' +
|
|
|
|
'<strong>' + message + '</strong>';
|
|
|
|
|
|
|
|
$.each(actions, function(index, action) {
|
|
|
|
var actionId = action['label'].toLowerCase().replace(' ', '-');
|
|
|
|
notificationHtml += '<button id="' + actionId + '" class="btn">'
|
|
|
|
+ action['label'] + '</button>';
|
|
|
|
|
|
|
|
$(document).off('click', '#' + actionId);
|
|
|
|
$(document).on('click', '#' + actionId, action['function']);
|
|
|
|
});
|
|
|
|
|
|
|
|
notificationHtml += '</div>';
|
|
|
|
|
|
|
|
$('#notification').html(notificationHtml);
|
|
|
|
$('#notification').show('blind');
|
2013-06-12 18:31:16 +03:00
|
|
|
}
|
2013-06-18 19:06:34 +03:00
|
|
|
};
|