Chris@0: /** Chris@0: * @file Chris@0: * Language admin behavior. Chris@0: */ Chris@0: Chris@17: (function($, Drupal) { Chris@0: /** Chris@0: * Makes language negotiation inherit user interface negotiation. Chris@0: * Chris@0: * @type {Drupal~behavior} Chris@0: * Chris@0: * @prop {Drupal~behaviorAttach} attach Chris@0: * Attach behavior to language negotiation admin user interface. Chris@0: */ Chris@0: Drupal.behaviors.negotiationLanguage = { Chris@0: attach() { Chris@0: const $configForm = $('#language-negotiation-configure-form'); Chris@0: const inputSelector = 'input[name$="[configurable]"]'; Chris@0: // Given a customization checkbox derive the language type being changed. Chris@0: function toggleTable(checkbox) { Chris@0: const $checkbox = $(checkbox); Chris@0: // Get the language detection type such as Interface text language Chris@0: // detection or Content language detection. Chris@17: $checkbox Chris@17: .closest('.table-language-group') Chris@0: .find('table, .tabledrag-toggle-weight') Chris@0: .toggle($checkbox.prop('checked')); Chris@0: } Chris@0: Chris@0: // Bind hide/show and rearrange customization checkboxes. Chris@17: $configForm Chris@17: .once('negotiation-language-admin-bind') Chris@17: .on('change', inputSelector, event => { Chris@17: toggleTable(event.target); Chris@17: }); Chris@0: // Initially, hide language detection types that are not customized. Chris@17: $configForm Chris@17: .find(`${inputSelector}:not(:checked)`) Chris@17: .each((index, element) => { Chris@17: toggleTable(element); Chris@17: }); Chris@0: }, Chris@0: }; Chris@17: })(jQuery, Drupal);