Drupal investigation

language.admin.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @file
  3. * Language admin behavior.
  4. */
  5. (function ($, Drupal) {
  6. 'use strict';
  7. /**
  8. * Makes language negotiation inherit user interface negotiation.
  9. *
  10. * @type {Drupal~behavior}
  11. *
  12. * @prop {Drupal~behaviorAttach} attach
  13. * Attach behavior to language negotiation admin user interface.
  14. */
  15. Drupal.behaviors.negotiationLanguage = {
  16. attach: function () {
  17. var $configForm = $('#language-negotiation-configure-form');
  18. var inputSelector = 'input[name$="[configurable]"]';
  19. // Given a customization checkbox derive the language type being changed.
  20. function toggleTable(checkbox) {
  21. var $checkbox = $(checkbox);
  22. // Get the language detection type such as Interface text language
  23. // detection or Content language detection.
  24. $checkbox.closest('.table-language-group')
  25. .find('table, .tabledrag-toggle-weight')
  26. .toggle($checkbox.prop('checked'));
  27. }
  28. // Bind hide/show and rearrange customization checkboxes.
  29. $configForm.once('negotiation-language-admin-bind').on('change', inputSelector, function (event) {
  30. toggleTable(event.target);
  31. });
  32. // Initially, hide language detection types that are not customized.
  33. $configForm.find(inputSelector + ':not(:checked)').each(function (index, element) {
  34. toggleTable(element);
  35. });
  36. }
  37. };
  38. })(jQuery, Drupal);