Last active
August 29, 2015 14:11
-
-
Save Jaesin/cef2ad9110658671eff5 to your computer and use it in GitHub Desktop.
Add Select All on the drupal permissions page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var columns = $("#permissions tr.even").first().find("input.form-checkbox").length; | |
var heads = $("#permissions thead th"); | |
for (var i=1; i<columns+1; i++) { | |
var cbToggler = $("<input type=checkbox>").data('column', i); | |
cbToggler.click(function(e) { | |
var checked = this.checked; | |
var allCheckboxes = $("#permissions tbody input.form-checkbox"); | |
for (var n=$(this).data('column')-1; n<allCheckboxes.length; n+=columns) { | |
var chkbox = allCheckboxes.get(n); | |
chkbox.checked = checked; | |
} | |
}); | |
heads.eq(i).append( $('<div class="checkbox-toggler"/>').append(cbToggler) ); | |
} | |
// Also add hover toggling (The Jedi Effect) | |
$('input[type=checkbox]').mouseenter(function() { | |
$(this).attr('checked', (!$(this).attr('checked') ? 'checked' : false)); | |
}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment