2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2013-10-09 05:04:56 +00:00
|
|
|
(function ($, Drupal, drupalSettings) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.contentTranslationDependentOptions = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context) {
|
|
|
|
const $context = $(context);
|
|
|
|
const options = drupalSettings.contentTranslationDependentOptions;
|
|
|
|
let $fields;
|
2013-10-09 05:04:56 +00:00
|
|
|
|
2017-12-03 16:02:05 +00:00
|
|
|
function fieldsChangeHandler($fields, dependentColumns) {
|
2014-01-27 21:41:32 +00:00
|
|
|
return function (e) {
|
2017-12-03 16:02:05 +00:00
|
|
|
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target));
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
}
|
2013-03-10 06:18:48 +00:00
|
|
|
|
2016-02-25 15:54:27 +00:00
|
|
|
if (options && options.dependent_selectors) {
|
2021-12-18 06:12:16 +00:00
|
|
|
Object.keys(options.dependent_selectors).forEach(field => {
|
|
|
|
$fields = $context.find(`input[name^="${field}"]`);
|
|
|
|
const dependentColumns = options.dependent_selectors[field];
|
2018-01-03 23:25:46 +00:00
|
|
|
$fields.on('change', fieldsChangeHandler($fields, dependentColumns));
|
|
|
|
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns);
|
|
|
|
});
|
2013-10-09 05:04:56 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
|
|
|
check($fields, dependentColumns, $changed) {
|
|
|
|
let $element = $changed;
|
|
|
|
let column;
|
2013-03-10 06:18:48 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function filterFieldsList(index, field) {
|
2022-01-17 16:08:33 +00:00
|
|
|
return field.value === column;
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
Object.keys(dependentColumns || {}).forEach(index => {
|
2018-01-03 23:25:46 +00:00
|
|
|
column = dependentColumns[index];
|
2013-03-10 06:18:48 +00:00
|
|
|
|
2018-01-03 23:25:46 +00:00
|
|
|
if (!$changed) {
|
|
|
|
$element = $fields.filter(filterFieldsList);
|
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
if ($element.is(`input[value="${column}"]:checked`)) {
|
2018-01-03 23:25:46 +00:00
|
|
|
$fields.prop('checked', true).not($element).prop('disabled', true);
|
|
|
|
} else {
|
|
|
|
$fields.prop('disabled', false);
|
2013-10-09 05:04:56 +00:00
|
|
|
}
|
2018-01-03 23:25:46 +00:00
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.contentTranslation = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context) {
|
|
|
|
once('translation-entity-admin-hide', $(context).find('table .bundle-settings .translatable :input')).forEach(input => {
|
|
|
|
const $input = $(input);
|
|
|
|
const $bundleSettings = $input.closest('.bundle-settings');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (!$input.is(':checked')) {
|
|
|
|
$bundleSettings.nextUntil('.bundle-settings').hide();
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
$bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
|
2013-10-09 05:04:56 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2021-12-18 06:12:16 +00:00
|
|
|
$(once('translation-entity-admin-bind', 'body')).on('click', 'table .bundle-settings .translatable :input', e => {
|
|
|
|
const $target = $(e.target);
|
|
|
|
const $bundleSettings = $target.closest('.bundle-settings');
|
|
|
|
const $settings = $bundleSettings.nextUntil('.bundle-settings');
|
|
|
|
const $fieldSettings = $settings.filter('.field-settings');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ($target.is(':checked')) {
|
2014-12-08 16:25:00 +00:00
|
|
|
$bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true);
|
2014-01-27 21:41:32 +00:00
|
|
|
$fieldSettings.find('.translatable :input').prop('checked', true);
|
|
|
|
$settings.show();
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2014-01-27 21:41:32 +00:00
|
|
|
$settings.hide();
|
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
}).on('click', 'table .field-settings .translatable :input', e => {
|
|
|
|
const $target = $(e.target);
|
|
|
|
const $fieldSettings = $target.closest('.field-settings');
|
|
|
|
const $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
if ($target.is(':checked')) {
|
|
|
|
$columnSettings.show();
|
|
|
|
} else {
|
|
|
|
$columnSettings.hide();
|
|
|
|
}
|
|
|
|
});
|
2013-10-09 05:04:56 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, drupalSettings);
|