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