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 var dependent_columns = void 0;
|
Chris@0
|
15
|
Chris@0
|
16 function fieldsChangeHandler($fields, dependent_columns) {
|
Chris@0
|
17 return function (e) {
|
Chris@0
|
18 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns, $(e.target));
|
Chris@0
|
19 };
|
Chris@0
|
20 }
|
Chris@0
|
21
|
Chris@0
|
22 if (options && options.dependent_selectors) {
|
Chris@0
|
23 for (var field in options.dependent_selectors) {
|
Chris@0
|
24 if (options.dependent_selectors.hasOwnProperty(field)) {
|
Chris@0
|
25 $fields = $context.find('input[name^="' + field + '"]');
|
Chris@0
|
26 dependent_columns = options.dependent_selectors[field];
|
Chris@0
|
27
|
Chris@0
|
28 $fields.on('change', fieldsChangeHandler($fields, dependent_columns));
|
Chris@0
|
29 Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns);
|
Chris@0
|
30 }
|
Chris@0
|
31 }
|
Chris@0
|
32 }
|
Chris@0
|
33 },
|
Chris@0
|
34 check: function check($fields, dependent_columns, $changed) {
|
Chris@0
|
35 var $element = $changed;
|
Chris@0
|
36 var column = void 0;
|
Chris@0
|
37
|
Chris@0
|
38 function filterFieldsList(index, field) {
|
Chris@0
|
39 return $(field).val() === column;
|
Chris@0
|
40 }
|
Chris@0
|
41
|
Chris@0
|
42 for (var index in dependent_columns) {
|
Chris@0
|
43 if (dependent_columns.hasOwnProperty(index)) {
|
Chris@0
|
44 column = dependent_columns[index];
|
Chris@0
|
45
|
Chris@0
|
46 if (!$changed) {
|
Chris@0
|
47 $element = $fields.filter(filterFieldsList);
|
Chris@0
|
48 }
|
Chris@0
|
49
|
Chris@0
|
50 if ($element.is('input[value="' + column + '"]:checked')) {
|
Chris@0
|
51 $fields.prop('checked', true).not($element).prop('disabled', true);
|
Chris@0
|
52 } else {
|
Chris@0
|
53 $fields.prop('disabled', false);
|
Chris@0
|
54 }
|
Chris@0
|
55 }
|
Chris@0
|
56 }
|
Chris@0
|
57 }
|
Chris@0
|
58 };
|
Chris@0
|
59
|
Chris@0
|
60 Drupal.behaviors.contentTranslation = {
|
Chris@0
|
61 attach: function attach(context) {
|
Chris@0
|
62 $(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () {
|
Chris@0
|
63 var $input = $(this);
|
Chris@0
|
64 var $bundleSettings = $input.closest('.bundle-settings');
|
Chris@0
|
65 if (!$input.is(':checked')) {
|
Chris@0
|
66 $bundleSettings.nextUntil('.bundle-settings').hide();
|
Chris@0
|
67 } else {
|
Chris@0
|
68 $bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
|
Chris@0
|
69 }
|
Chris@0
|
70 });
|
Chris@0
|
71
|
Chris@0
|
72 $('body').once('translation-entity-admin-bind').on('click', 'table .bundle-settings .translatable :input', function (e) {
|
Chris@0
|
73 var $target = $(e.target);
|
Chris@0
|
74 var $bundleSettings = $target.closest('.bundle-settings');
|
Chris@0
|
75 var $settings = $bundleSettings.nextUntil('.bundle-settings');
|
Chris@0
|
76 var $fieldSettings = $settings.filter('.field-settings');
|
Chris@0
|
77 if ($target.is(':checked')) {
|
Chris@0
|
78 $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true);
|
Chris@0
|
79 $fieldSettings.find('.translatable :input').prop('checked', true);
|
Chris@0
|
80 $settings.show();
|
Chris@0
|
81 } else {
|
Chris@0
|
82 $settings.hide();
|
Chris@0
|
83 }
|
Chris@0
|
84 }).on('click', 'table .field-settings .translatable :input', function (e) {
|
Chris@0
|
85 var $target = $(e.target);
|
Chris@0
|
86 var $fieldSettings = $target.closest('.field-settings');
|
Chris@0
|
87 var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings');
|
Chris@0
|
88 if ($target.is(':checked')) {
|
Chris@0
|
89 $columnSettings.show();
|
Chris@0
|
90 } else {
|
Chris@0
|
91 $columnSettings.hide();
|
Chris@0
|
92 }
|
Chris@0
|
93 });
|
Chris@0
|
94 }
|
Chris@0
|
95 };
|
Chris@0
|
96 })(jQuery, Drupal, drupalSettings); |