Chris@0
|
1 /**
|
Chris@0
|
2 * DO NOT EDIT THIS FILE.
|
Chris@0
|
3 * See the following change record for more information,
|
Chris@0
|
4 * https://www.drupal.org/node/2815083
|
Chris@0
|
5 * @preserve
|
Chris@0
|
6 **/
|
Chris@0
|
7
|
Chris@0
|
8 (function ($, Drupal, drupalSettings) {
|
Chris@0
|
9 Drupal.behaviors.contentTranslationDependentOptions = {
|
Chris@0
|
10 attach: function attach(context) {
|
Chris@0
|
11 var $context = $(context);
|
Chris@0
|
12 var options = drupalSettings.contentTranslationDependentOptions;
|
Chris@0
|
13 var $fields = void 0;
|
Chris@0
|
14
|
Chris@14
|
15 function fieldsChangeHandler($fields, dependentColumns) {
|
Chris@0
|
16 return function (e) {
|
Chris@14
|
17 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target));
|
Chris@0
|
18 };
|
Chris@0
|
19 }
|
Chris@0
|
20
|
Chris@0
|
21 if (options && options.dependent_selectors) {
|
Chris@14
|
22 Object.keys(options.dependent_selectors).forEach(function (field) {
|
Chris@14
|
23 $fields = $context.find('input[name^="' + field + '"]');
|
Chris@14
|
24 var dependentColumns = options.dependent_selectors[field];
|
Chris@0
|
25
|
Chris@14
|
26 $fields.on('change', fieldsChangeHandler($fields, dependentColumns));
|
Chris@14
|
27 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns);
|
Chris@14
|
28 });
|
Chris@0
|
29 }
|
Chris@0
|
30 },
|
Chris@14
|
31 check: function check($fields, dependentColumns, $changed) {
|
Chris@0
|
32 var $element = $changed;
|
Chris@0
|
33 var column = void 0;
|
Chris@0
|
34
|
Chris@0
|
35 function filterFieldsList(index, field) {
|
Chris@0
|
36 return $(field).val() === column;
|
Chris@0
|
37 }
|
Chris@0
|
38
|
Chris@14
|
39 Object.keys(dependentColumns || {}).forEach(function (index) {
|
Chris@14
|
40 column = dependentColumns[index];
|
Chris@0
|
41
|
Chris@14
|
42 if (!$changed) {
|
Chris@14
|
43 $element = $fields.filter(filterFieldsList);
|
Chris@14
|
44 }
|
Chris@0
|
45
|
Chris@14
|
46 if ($element.is('input[value="' + column + '"]:checked')) {
|
Chris@14
|
47 $fields.prop('checked', true).not($element).prop('disabled', true);
|
Chris@14
|
48 } else {
|
Chris@14
|
49 $fields.prop('disabled', false);
|
Chris@0
|
50 }
|
Chris@14
|
51 });
|
Chris@0
|
52 }
|
Chris@0
|
53 };
|
Chris@0
|
54
|
Chris@0
|
55 Drupal.behaviors.contentTranslation = {
|
Chris@0
|
56 attach: function attach(context) {
|
Chris@0
|
57 $(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () {
|
Chris@0
|
58 var $input = $(this);
|
Chris@0
|
59 var $bundleSettings = $input.closest('.bundle-settings');
|
Chris@0
|
60 if (!$input.is(':checked')) {
|
Chris@0
|
61 $bundleSettings.nextUntil('.bundle-settings').hide();
|
Chris@0
|
62 } else {
|
Chris@0
|
63 $bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
|
Chris@0
|
64 }
|
Chris@0
|
65 });
|
Chris@0
|
66
|
Chris@0
|
67 $('body').once('translation-entity-admin-bind').on('click', 'table .bundle-settings .translatable :input', function (e) {
|
Chris@0
|
68 var $target = $(e.target);
|
Chris@0
|
69 var $bundleSettings = $target.closest('.bundle-settings');
|
Chris@0
|
70 var $settings = $bundleSettings.nextUntil('.bundle-settings');
|
Chris@0
|
71 var $fieldSettings = $settings.filter('.field-settings');
|
Chris@0
|
72 if ($target.is(':checked')) {
|
Chris@0
|
73 $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true);
|
Chris@0
|
74 $fieldSettings.find('.translatable :input').prop('checked', true);
|
Chris@0
|
75 $settings.show();
|
Chris@0
|
76 } else {
|
Chris@0
|
77 $settings.hide();
|
Chris@0
|
78 }
|
Chris@0
|
79 }).on('click', 'table .field-settings .translatable :input', function (e) {
|
Chris@0
|
80 var $target = $(e.target);
|
Chris@0
|
81 var $fieldSettings = $target.closest('.field-settings');
|
Chris@0
|
82 var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings');
|
Chris@0
|
83 if ($target.is(':checked')) {
|
Chris@0
|
84 $columnSettings.show();
|
Chris@0
|
85 } else {
|
Chris@0
|
86 $columnSettings.hide();
|
Chris@0
|
87 }
|
Chris@0
|
88 });
|
Chris@0
|
89 }
|
Chris@0
|
90 };
|
Chris@0
|
91 })(jQuery, Drupal, drupalSettings); |