mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Using PermissionCheckboxSetField.js instead of MemberTableField.js
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100791 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7e7cdab53e
commit
e7c74e0107
34
javascript/PermissionCheckboxSetField.js
Normal file
34
javascript/PermissionCheckboxSetField.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
(function($) {
|
||||||
|
Behaviour.register({
|
||||||
|
/**
|
||||||
|
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
||||||
|
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
||||||
|
* checking all boxes is purely presentational.
|
||||||
|
*/
|
||||||
|
'.permissioncheckboxset .valADMIN input': {
|
||||||
|
initialize: function() {
|
||||||
|
this.toggleCheckboxes();
|
||||||
|
},
|
||||||
|
onclick: function(e) {
|
||||||
|
this.toggleCheckboxes();
|
||||||
|
},
|
||||||
|
toggleCheckboxes: function() {
|
||||||
|
var checkboxes = $(this).parents('.field:eq(0)').find('.checkbox').not(this);
|
||||||
|
|
||||||
|
if($(this).is(':checked')) {
|
||||||
|
checkboxes.each(function() {
|
||||||
|
$(this).data('SecurityAdmin.oldChecked', $(this).attr('checked'));
|
||||||
|
$(this).data('SecurityAdmin.oldDisabled', $(this).attr('disabled'));
|
||||||
|
$(this).attr('disabled', 'disabled');
|
||||||
|
$(this).attr('checked', 'checked');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
checkboxes.each(function() {
|
||||||
|
$(this).attr('checked', $(this).data('SecurityAdmin.oldChecked'));
|
||||||
|
$(this).attr('disabled', $(this).data('SecurityAdmin.oldDisabled'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}(jQuery));
|
@ -72,6 +72,7 @@ class PermissionCheckboxSetField extends FormField {
|
|||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css');
|
Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css');
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||||
|
|
||||||
$uninheritedCodes = array();
|
$uninheritedCodes = array();
|
||||||
$inheritedCodes = array();
|
$inheritedCodes = array();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user