diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-12 08:33:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-12 08:33:19 +0000 |
commit | da87545c487eb2e46dbc6c7b9e054b2e5be4a5b0 (patch) | |
tree | 5e53cdde543197ba02b8aece02b382a137b65ba1 | |
parent | a86223cd7039756510df0f9e0f5ddf38b7e04fcf (diff) | |
download | brdo-da87545c487eb2e46dbc6c7b9e054b2e5be4a5b0.tar.gz brdo-da87545c487eb2e46dbc6c7b9e054b2e5be4a5b0.tar.bz2 |
- Patch #78941 by kkaefer and ksenzee: added missing file.
-rw-r--r-- | modules/user/user.permissions.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/user/user.permissions.js b/modules/user/user.permissions.js new file mode 100644 index 000000000..d098da54d --- /dev/null +++ b/modules/user/user.permissions.js @@ -0,0 +1,40 @@ +// $Id$ +(function ($) { + +/** + * Shows checked and disabled checkboxes for inherited permissions. + */ +Drupal.behaviors.permissions = { + attach: function (context) { + $('table#permissions:not(.permissions-processed)').each(function () { + // Create dummy checkboxes. We use dummy checkboxes instead of reusing + // the existing checkboxes here because new checkboxes don't alter the + // submitted form. If we'd automatically check existing checkboxes, the + // permission table would be polluted with redundant entries. This + // is deliberate, but desirable when we automatically check them. + $(':checkbox', this).not('[name^="2["]').not('[name^="1["]').each(function () { + $(this).addClass('real-checkbox'); + $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />') + .attr('title', Drupal.t("This permission is inherited from the authenticated user role.")) + .hide() + .insertAfter(this); + }); + + // Helper function toggles all dummy checkboxes based on the checkboxes' + // state. If the "authenticated user" checkbox is checked, the checked + // and disabled checkboxes are shown, the real checkboxes otherwise. + var toggle = function () { + $(this).closest('tr') + .find('.real-checkbox')[this.checked ? 'hide' : 'show']().end() + .find('.dummy-checkbox')[this.checked ? 'show' : 'hide'](); + }; + + // Initialize the authenticated user checkbox. + $(':checkbox[name^="2["]', this) + .click(toggle) + .each(function () { toggle.call(this); }); + }).addClass('permissions-processed'); + } +}; + +})(jQuery); |