user.permissions.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. (function ($, Drupal) {
  8. Drupal.behaviors.permissions = {
  9. attach: function attach(context) {
  10. var self = this;
  11. $('table#permissions').once('permissions').each(function () {
  12. var $table = $(this);
  13. var $ancestor = void 0;
  14. var method = void 0;
  15. if ($table.prev().length) {
  16. $ancestor = $table.prev();
  17. method = 'after';
  18. } else {
  19. $ancestor = $table.parent();
  20. method = 'append';
  21. }
  22. $table.detach();
  23. var $dummy = $(Drupal.theme('checkbox')).removeClass('form-checkbox').addClass('dummy-checkbox js-dummy-checkbox').attr('disabled', 'disabled').attr('checked', 'checked').attr('title', Drupal.t('This permission is inherited from the authenticated user role.')).hide();
  24. $table.find('input[type="checkbox"]').not('.js-rid-anonymous, .js-rid-authenticated').addClass('real-checkbox js-real-checkbox').after($dummy);
  25. $table.find('input[type=checkbox].js-rid-authenticated').on('click.permissions', self.toggle).each(self.toggle);
  26. $ancestor[method]($table);
  27. });
  28. },
  29. toggle: function toggle() {
  30. var authCheckbox = this;
  31. var $row = $(this).closest('tr');
  32. $row.find('.js-real-checkbox').each(function () {
  33. this.style.display = authCheckbox.checked ? 'none' : '';
  34. });
  35. $row.find('.js-dummy-checkbox').each(function () {
  36. this.style.display = authCheckbox.checked ? '' : 'none';
  37. });
  38. }
  39. };
  40. })(jQuery, Drupal);