2018-04-09 23:33:42 -04:00
|
|
|
|
function hideLoader() {
|
|
|
|
|
$('.layout-loading-icon').fadeOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showLoader() {
|
|
|
|
|
$('.layout-loading-icon').attr('style', 'visibility:visible');
|
|
|
|
|
$('.layout-loading-icon').removeClass('text-danger');
|
2018-05-04 00:22:10 -04:00
|
|
|
|
$('.layout-loading-icon').removeClass('text-muted');
|
2018-04-09 23:33:42 -04:00
|
|
|
|
$('.layout-loading-icon').fadeIn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function errorLoader() {
|
|
|
|
|
$('.layout-loading-icon').addClass('text-danger');
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-04 00:22:10 -04:00
|
|
|
|
function staleLoader() {
|
|
|
|
|
$('.layout-loading-icon').addClass('text-muted');
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 23:33:42 -04:00
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
hideLoader();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* hide loader when clicking
|
|
|
|
|
*/
|
|
|
|
|
$(document).click(function (e) {
|
2018-09-02 17:59:27 -04:00
|
|
|
|
//hideLoader()
|
2018-04-09 23:33:42 -04:00
|
|
|
|
});
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
/*
|
|
|
|
|
* handle action modal
|
|
|
|
|
*/
|
|
|
|
|
$('.profile-action').click(function (e) {
|
|
|
|
|
const actionType = $(this).data('action');
|
|
|
|
|
$.get('/Action/' + actionType + 'Form')
|
|
|
|
|
.done(function (response) {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
$('#actionModal .modal-body-content').html(response);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2018-09-02 17:59:27 -04:00
|
|
|
|
$('#actionModal .modal-message').text('Error — ' + error);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* handle action submit
|
|
|
|
|
*/
|
|
|
|
|
$(document).on('submit', '.action-form', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
$(this).append($('#target_id input'));
|
|
|
|
|
const data = $(this).serialize();
|
2018-04-09 23:33:42 -04:00
|
|
|
|
showLoader();
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$.get($(this).attr('action') + '/?' + data)
|
|
|
|
|
.done(function (response) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
hideLoader();
|
2018-04-04 15:38:34 -04:00
|
|
|
|
// success without content
|
|
|
|
|
if (response.length === 0) {
|
|
|
|
|
location.reload();
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
$('#actionModal .modal-body-content').html(response);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
$('#actionModal').modal();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
errorLoader();
|
|
|
|
|
hideLoader();
|
2018-04-05 00:38:45 -04:00
|
|
|
|
if ($('#actionModal .modal-message').text.length > 0) {
|
|
|
|
|
$('#actionModal .modal-message').fadeOut('fast');
|
|
|
|
|
}
|
|
|
|
|
if (jqxhr.status === 401) {
|
|
|
|
|
$('#actionModal .modal-message').text('Invalid login credentials');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').text('Error — ' + error);
|
2018-04-04 15:38:34 -04:00
|
|
|
|
}
|
2018-04-05 00:38:45 -04:00
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|