2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, Drupal, drupalSettings) {
9 Drupal.behaviors.contentTranslationDependentOptions = {
10 attach: function attach(context) {
11 var $context = $(context);
12 var options = drupalSettings.contentTranslationDependentOptions;
14 var dependent_columns = void 0;
16 function fieldsChangeHandler($fields, dependent_columns) {
18 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns, $(e.target));
22 if (options && options.dependent_selectors) {
23 for (var field in options.dependent_selectors) {
24 if (options.dependent_selectors.hasOwnProperty(field)) {
25 $fields = $context.find('input[name^="' + field + '"]');
26 dependent_columns = options.dependent_selectors[field];
28 $fields.on('change', fieldsChangeHandler($fields, dependent_columns));
29 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns);
34 check: function check($fields, dependent_columns, $changed) {
35 var $element = $changed;
38 function filterFieldsList(index, field) {
39 return $(field).val() === column;
42 for (var index in dependent_columns) {
43 if (dependent_columns.hasOwnProperty(index)) {
44 column = dependent_columns[index];
47 $element = $fields.filter(filterFieldsList);
50 if ($element.is('input[value="' + column + '"]:checked')) {
51 $fields.prop('checked', true).not($element).prop('disabled', true);
53 $fields.prop('disabled', false);
60 Drupal.behaviors.contentTranslation = {
61 attach: function attach(context) {
62 $(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () {
64 var $bundleSettings = $input.closest('.bundle-settings');
65 if (!$input.is(':checked')) {
66 $bundleSettings.nextUntil('.bundle-settings').hide();
68 $bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
72 $('body').once('translation-entity-admin-bind').on('click', 'table .bundle-settings .translatable :input', function (e) {
73 var $target = $(e.target);
74 var $bundleSettings = $target.closest('.bundle-settings');
75 var $settings = $bundleSettings.nextUntil('.bundle-settings');
76 var $fieldSettings = $settings.filter('.field-settings');
77 if ($target.is(':checked')) {
78 $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true);
79 $fieldSettings.find('.translatable :input').prop('checked', true);
84 }).on('click', 'table .field-settings .translatable :input', function (e) {
85 var $target = $(e.target);
86 var $fieldSettings = $target.closest('.field-settings');
87 var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings');
88 if ($target.is(':checked')) {
89 $columnSettings.show();
91 $columnSettings.hide();
96 })(jQuery, Drupal, drupalSettings);