From cc8c1e3031dc5b5694006c1d539ef07424044dba Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 23 Feb 2010 03:44:38 +0000 Subject: [PATCH] ENHANCEMENT Disabling/checking permission checkboxes in admin/security when 'ADMIN' permission is selected git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99692 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/MemberTableField.js | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/javascript/MemberTableField.js b/javascript/MemberTableField.js index f376a882..f9ca0b49 100755 --- a/javascript/MemberTableField.js +++ b/javascript/MemberTableField.js @@ -279,3 +279,38 @@ MemberFilterButton.prototype = { Behaviour.register({ '#Form_EditForm div.MemberTableField table.data input.text' : AjaxMemberLookup }); + +(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. + */ + '#Permissions .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)); \ No newline at end of file