X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_translation%2Fcontent_translation.admin.es6.js;h=cf4b2083c98374fd32631046ccdd49bb23dec0b1;hb=9424afc6c1f518c301bf87a23c047d1873435d05;hp=53ace084db0394cb8fc0619879dc50afcb704f83;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/modules/content_translation/content_translation.admin.es6.js b/web/core/modules/content_translation/content_translation.admin.es6.js index 53ace084d..cf4b2083c 100644 --- a/web/core/modules/content_translation/content_translation.admin.es6.js +++ b/web/core/modules/content_translation/content_translation.admin.es6.js @@ -3,7 +3,7 @@ * Content Translation admin behaviors. */ -(function ($, Drupal, drupalSettings) { +(function($, Drupal, drupalSettings) { /** * Forces applicable options to be checked as translatable. * @@ -19,8 +19,12 @@ let $fields; function fieldsChangeHandler($fields, dependentColumns) { - return function (e) { - Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target)); + return function(e) { + Drupal.behaviors.contentTranslationDependentOptions.check( + $fields, + dependentColumns, + $(e.target), + ); }; } @@ -28,12 +32,15 @@ // that name and copy over the input values that require all columns to be // translatable. if (options && options.dependent_selectors) { - Object.keys(options.dependent_selectors).forEach((field) => { + Object.keys(options.dependent_selectors).forEach(field => { $fields = $context.find(`input[name^="${field}"]`); const dependentColumns = options.dependent_selectors[field]; $fields.on('change', fieldsChangeHandler($fields, dependentColumns)); - Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns); + Drupal.behaviors.contentTranslationDependentOptions.check( + $fields, + dependentColumns, + ); }); } }, @@ -47,7 +54,7 @@ // A field that has many different translatable parts can also define one // or more columns that require all columns to be translatable. - Object.keys(dependentColumns || {}).forEach((index) => { + Object.keys(dependentColumns || {}).forEach(index => { column = dependentColumns[index]; if (!$changed) { @@ -55,10 +62,11 @@ } if ($element.is(`input[value="${column}"]:checked`)) { - $fields.prop('checked', true) - .not($element).prop('disabled', true); - } - else { + $fields + .prop('checked', true) + .not($element) + .prop('disabled', true); + } else { $fields.prop('disabled', false); } }); @@ -77,50 +85,56 @@ attach(context) { // Initially hide all field rows for non translatable bundles and all // column rows for non translatable fields. - $(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () { - const $input = $(this); - const $bundleSettings = $input.closest('.bundle-settings'); - if (!$input.is(':checked')) { - $bundleSettings.nextUntil('.bundle-settings').hide(); - } - else { - $bundleSettings - .nextUntil('.bundle-settings', '.field-settings') - .find('.translatable :input:not(:checked)') - .closest('.field-settings') - .nextUntil(':not(.column-settings)') - .hide(); - } - }); + $(context) + .find('table .bundle-settings .translatable :input') + .once('translation-entity-admin-hide') + .each(function() { + const $input = $(this); + const $bundleSettings = $input.closest('.bundle-settings'); + if (!$input.is(':checked')) { + $bundleSettings.nextUntil('.bundle-settings').hide(); + } else { + $bundleSettings + .nextUntil('.bundle-settings', '.field-settings') + .find('.translatable :input:not(:checked)') + .closest('.field-settings') + .nextUntil(':not(.column-settings)') + .hide(); + } + }); // When a bundle is made translatable all of its fields should inherit // this setting. Instead when it is made non translatable its fields are // hidden, since their translatability no longer matters. - $('body').once('translation-entity-admin-bind').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'); - if ($target.is(':checked')) { - $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true); - $fieldSettings.find('.translatable :input').prop('checked', true); - $settings.show(); - } - else { - $settings.hide(); - } - }) - .on('click', 'table .field-settings .translatable :input', (e) => { + $('body') + .once('translation-entity-admin-bind') + .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'); + if ($target.is(':checked')) { + $bundleSettings + .find('.operations :input[name$="[language_alterable]"]') + .prop('checked', true); + $fieldSettings.find('.translatable :input').prop('checked', true); + $settings.show(); + } else { + $settings.hide(); + } + }) + .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'); + const $columnSettings = $fieldSettings.nextUntil( + '.field-settings, .bundle-settings', + ); if ($target.is(':checked')) { $columnSettings.show(); - } - else { + } else { $columnSettings.hide(); } }); }, }; -}(jQuery, Drupal, drupalSettings)); +})(jQuery, Drupal, drupalSettings);