1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #608: Add "toggle all" button to device and device type components

This commit is contained in:
Jeremy Stretch
2016-10-19 15:45:26 -04:00
parent 54a0639a6e
commit 4405bc4182
3 changed files with 47 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
$(document).ready(function() {
// "Toggle all" checkbox in a table header
// "Toggle all" checkbox (table header)
$('#toggle_all').click(function (event) {
$('td input:checkbox[name=pk]').prop('checked', $(this).prop('checked'));
if ($(this).is(':checked')) {
@@ -16,6 +16,15 @@ $(document).ready(function() {
}
});
// Simple "Toggle all" button (panel)
$('button.toggle').click(function (event) {
var selected = $(this).attr('selected');
$(this).closest('form').find('input:checkbox[name=pk]').prop('checked', !selected);
$(this).attr('selected', !selected);
$(this).children('span').toggleClass('glyphicon-unchecked glyphicon-check');
return false;
});
// Slugify
function slugify(s, num_chars) {
s = s.replace(/[^\-\.\w\s]/g, ''); // Remove unneeded chars