Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/feedback.js
2018-12-30 18:44:45 +01:00

55 lines
1.7 KiB
JavaScript

$('#statusModal').on('show.bs.modal', (e) => {
const btn = $(e.relatedTarget);
const id = btn.data('id');
const state = btn.data('state');
const modal = $('#statusModal');
$('#feedbackState option').each(() => {
$(this).removeAttr('disabled').removeAttr('selected');
});
const activeOption = $('#feedbackState option[value=' + state + ']');
activeOption.attr('selected', 'selected');
let curOption = activeOption;
for (let i = 0; i < 6; i++) {
curOption = curOption.prev();
if (curOption.length === 0) {
break;
}
curOption.attr('disabled', 'disabled');
}
$('form', modal).attr('action', '/admin/feedback/change/' + id);
});
function archiveFeedback(id) {
const row = $('#entry-' + id);
$.ajax({
url: '/admin/feedback/archive',
method: 'post',
data: {
id
},
success: (result) => {
if (result.type === 'success') {
setTimeout(() => {
row.find('#loader').css({
color: '#fff',
backgroundColor: '#2ecc71'
});
row.find('#loader .fa').removeClass('fa-spinner').removeClass('fa-spin').addClass('fa-check');
setTimeout(() => {
row.fadeOut(1000);
setTimeout(() => row.remove(), 3000);
}, 2000)
}, 1000);
} else {
}
},
beforeSend: () => {
row.children().hide();
row.append('<td id="loader" colspan="12" style="text-align:center;"><i class="fa fa-spinner fa-spin"></i></td>');
}
});
}