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