"use strict";
jQuery(function($) {
var running = 0;
$(document).ajaxStart(function() {
running++;
NProgress.start();
});
$(document).ajaxStop(function() {
if(--running <= 0) {
NProgress.done();
running = 0;
} else {
NProgress.inc();
}
});
$(document).ajaxError(function() {
noty({
type: 'error',
text: 'An error occurred while processing your request.
If the problem persists please call the ' +
'helpdesk at (414) 277-7288 or submit a ticket.',
timeout: 10000
});
});
$(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
if (ajaxOptions.crossDomain === false && ajaxOptions.type === "POST") {
if (typeof ajaxOptions.data != "undefined" && ajaxOptions.data.length > 0) {
ajaxOptions.data += '&' + yii.getCsrfParam() + '=' + yii.getCsrfToken();
} else {
ajaxOptions.data += yii.getCsrfParam() + '=' + yii.getCsrfToken();
}
}
});
});