language.admin.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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);