2017-12-01 22:33:04 -05:00
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Javascript for the admin module
|
2017-12-01 22:33:04 -05:00
|
|
|
*/
|
|
|
|
$(function() {
|
2020-06-11 20:26:29 -04:00
|
|
|
let $body = $('body');
|
|
|
|
$body.on('click', '.selectall', function() {
|
2017-12-01 22:33:04 -05:00
|
|
|
selectall($(this).data('selectAll'));
|
|
|
|
});
|
2020-06-11 20:26:29 -04:00
|
|
|
$body.on('click', '.selectnone', function() {
|
2017-12-01 22:33:04 -05:00
|
|
|
selectnone($(this).data('selectNone'));
|
|
|
|
});
|
|
|
|
|
2018-04-22 14:23:24 -04:00
|
|
|
// Toggle checkbox status to all or none for all checkboxes of a specific
|
|
|
|
// css class.
|
2020-06-11 20:26:29 -04:00
|
|
|
$body.on('change', 'input[type=checkbox].selecttoggle', function() {
|
2017-12-01 22:33:04 -05:00
|
|
|
$this = $(this);
|
|
|
|
if ($this.prop('checked')) {
|
|
|
|
selectall($this.data('selectClass'));
|
|
|
|
$this.attr('title', $this.data('selectNone'));
|
|
|
|
} else {
|
|
|
|
selectnone($this.data('selectClass'));
|
|
|
|
$this.attr('title', $this.data('selectAll'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-04-22 14:23:24 -04:00
|
|
|
// Use AJAX calls to reorder the table (so we don't need to reload the page).
|
2020-06-11 20:26:29 -04:00
|
|
|
$body.on('click', '.table-order', function(e) {
|
2018-04-22 14:23:24 -04:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
// Get the parent table element.
|
|
|
|
var table = $(this).parents('table');
|
|
|
|
var orderUrl = this.getAttribute("data-order-url");
|
|
|
|
table.fadeTo("fast", 0.33);
|
|
|
|
|
2020-06-11 20:26:29 -04:00
|
|
|
$body.css("cursor", "wait");
|
2018-04-22 14:23:24 -04:00
|
|
|
|
|
|
|
$.get(orderUrl, function(data) {
|
|
|
|
// Find the table element in the html we got.
|
|
|
|
var result = $(data).find('#' + table[0].id);
|
|
|
|
// And add the new table html to the parent.
|
2020-06-11 20:26:29 -04:00
|
|
|
$(table).replaceWith(result);
|
2018-04-22 14:23:24 -04:00
|
|
|
|
2020-06-11 20:26:29 -04:00
|
|
|
$body.css("cursor", "auto");
|
2018-04-22 14:23:24 -04:00
|
|
|
});
|
|
|
|
});
|
2018-04-18 15:43:33 -04:00
|
|
|
|
2018-04-19 12:17:46 -04:00
|
|
|
function selectall(cls) {
|
|
|
|
$('.' + cls).prop('checked', true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function selectnone(cls) {
|
|
|
|
$('.' + cls).prop('checked', false);
|
|
|
|
return false;
|
|
|
|
}
|
2018-04-18 15:43:33 -04:00
|
|
|
|
|
|
|
|
2018-04-19 12:17:46 -04:00
|
|
|
});
|
|
|
|
|
2018-04-18 15:43:33 -04:00
|
|
|
// Users
|
2018-04-19 12:17:46 -04:00
|
|
|
function confirm_delete(msg, uname){
|
|
|
|
return confirm(msg.format(uname));
|
2018-04-18 15:43:33 -04:00
|
|
|
}
|
2018-04-19 12:17:46 -04:00
|
|
|
|
2018-04-18 15:43:33 -04:00
|
|
|
function details(uid) {
|
2018-04-22 14:23:24 -04:00
|
|
|
$("#user-" + uid + "-detail").toggleClass("hidden");
|
|
|
|
$("#user-" + uid).toggleClass("opened");
|
2018-04-18 15:43:33 -04:00
|
|
|
return false;
|
|
|
|
}
|