X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fuser%2Fuser.permissions.js;h=f0e6a2ac7129dcf0ee4640907bdcb60233760ed2;hb=refs%2Fheads%2Ft2;hp=c3dc24f1f0a6c210734095b43b578bedd79059a3;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/user/user.permissions.js b/web/core/modules/user/user.permissions.js index c3dc24f1f..f0e6a2ac7 100644 --- a/web/core/modules/user/user.permissions.js +++ b/web/core/modules/user/user.permissions.js @@ -1,88 +1,46 @@ /** - * @file - * User permission page behaviors. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Drupal) { - - 'use strict'; - - /** - * Shows checked and disabled checkboxes for inherited permissions. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches functionality to the permissions table. - */ Drupal.behaviors.permissions = { - attach: function (context) { + attach: function attach(context) { var self = this; $('table#permissions').once('permissions').each(function () { - // On a site with many roles and permissions, this behavior initially - // has to perform thousands of DOM manipulations to inject checkboxes - // and hide them. By detaching the table from the DOM, all operations - // can be performed without triggering internal layout and re-rendering - // processes in the browser. var $table = $(this); - var $ancestor; - var method; + var $ancestor = void 0; + var method = void 0; if ($table.prev().length) { $ancestor = $table.prev(); method = 'after'; - } - else { + } else { $ancestor = $table.parent(); method = 'append'; } $table.detach(); - // 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. - var $dummy = $('') - .attr('title', Drupal.t('This permission is inherited from the authenticated user role.')) - .hide(); + var $dummy = $('').attr('title', Drupal.t('This permission is inherited from the authenticated user role.')).hide(); - $table - .find('input[type="checkbox"]') - .not('.js-rid-anonymous, .js-rid-authenticated') - .addClass('real-checkbox js-real-checkbox') - .after($dummy); + $table.find('input[type="checkbox"]').not('.js-rid-anonymous, .js-rid-authenticated').addClass('real-checkbox js-real-checkbox').after($dummy); - // Initialize the authenticated user checkbox. - $table.find('input[type=checkbox].js-rid-authenticated') - .on('click.permissions', self.toggle) - // .triggerHandler() cannot be used here, as it only affects the first - // element. - .each(self.toggle); + $table.find('input[type=checkbox].js-rid-authenticated').on('click.permissions', self.toggle).each(self.toggle); - // Re-insert the table into the DOM. $ancestor[method]($table); }); }, - - /** - * 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. - */ - toggle: function () { + toggle: function toggle() { var authCheckbox = this; var $row = $(this).closest('tr'); - // jQuery performs too many layout calculations for .hide() and .show(), - // leading to a major page rendering lag on sites with many roles and - // permissions. Therefore, we toggle visibility directly. + $row.find('.js-real-checkbox').each(function () { - this.style.display = (authCheckbox.checked ? 'none' : ''); + this.style.display = authCheckbox.checked ? 'none' : ''; }); $row.find('.js-dummy-checkbox').each(function () { - this.style.display = (authCheckbox.checked ? '' : 'none'); + this.style.display = authCheckbox.checked ? '' : 'none'; }); } }; - -})(jQuery, Drupal); +})(jQuery, Drupal); \ No newline at end of file