comparison core/modules/user/user.permissions.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal) {
9 Drupal.behaviors.permissions = {
10 attach: function attach(context) {
11 var self = this;
12 $('table#permissions').once('permissions').each(function () {
13 var $table = $(this);
14 var $ancestor = void 0;
15 var method = void 0;
16 if ($table.prev().length) {
17 $ancestor = $table.prev();
18 method = 'after';
19 } else {
20 $ancestor = $table.parent();
21 method = 'append';
22 }
23 $table.detach();
24
25 var $dummy = $('<input type="checkbox" class="dummy-checkbox js-dummy-checkbox" disabled="disabled" checked="checked" />').attr('title', Drupal.t('This permission is inherited from the authenticated user role.')).hide();
26
27 $table.find('input[type="checkbox"]').not('.js-rid-anonymous, .js-rid-authenticated').addClass('real-checkbox js-real-checkbox').after($dummy);
28
29 $table.find('input[type=checkbox].js-rid-authenticated').on('click.permissions', self.toggle).each(self.toggle);
30
31 $ancestor[method]($table);
32 });
33 },
34 toggle: function toggle() {
35 var authCheckbox = this;
36 var $row = $(this).closest('tr');
37
38 $row.find('.js-real-checkbox').each(function () {
39 this.style.display = authCheckbox.checked ? 'none' : '';
40 });
41 $row.find('.js-dummy-checkbox').each(function () {
42 this.style.display = authCheckbox.checked ? '' : 'none';
43 });
44 }
45 };
46 })(jQuery, Drupal);