X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fcontent_translation%2Fcontent_translation.admin.js;h=33e3fbd45be22de21ae9b65cf18500650e6e19a2;hb=9424afc6c1f518c301bf87a23c047d1873435d05;hp=fcbf699f73829412eafb49326cae015a0dba75d4;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/content_translation/content_translation.admin.js b/web/core/modules/content_translation/content_translation.admin.js index fcbf699f7..33e3fbd45 100644 --- a/web/core/modules/content_translation/content_translation.admin.js +++ b/web/core/modules/content_translation/content_translation.admin.js @@ -1,105 +1,69 @@ /** - * @file - * Content Translation admin behaviors. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Drupal, drupalSettings) { - - 'use strict'; - - /** - * Forces applicable options to be checked as translatable. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches content translation dependent options to the UI. - */ Drupal.behaviors.contentTranslationDependentOptions = { - attach: function (context) { + attach: function attach(context) { var $context = $(context); var options = drupalSettings.contentTranslationDependentOptions; - var $fields; - var dependent_columns; + var $fields = void 0; - function fieldsChangeHandler($fields, dependent_columns) { + function fieldsChangeHandler($fields, dependentColumns) { return function (e) { - Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns, $(e.target)); + Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns, $(e.target)); }; } - // We're given a generic name to look for so we find all inputs containing - // that name and copy over the input values that require all columns to be - // translatable. if (options && options.dependent_selectors) { - for (var field in options.dependent_selectors) { - if (options.dependent_selectors.hasOwnProperty(field)) { - $fields = $context.find('input[name^="' + field + '"]'); - dependent_columns = options.dependent_selectors[field]; + Object.keys(options.dependent_selectors).forEach(function (field) { + $fields = $context.find('input[name^="' + field + '"]'); + var dependentColumns = options.dependent_selectors[field]; - $fields.on('change', fieldsChangeHandler($fields, dependent_columns)); - Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependent_columns); - } - } + $fields.on('change', fieldsChangeHandler($fields, dependentColumns)); + Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns); + }); } }, - check: function ($fields, dependent_columns, $changed) { + check: function check($fields, dependentColumns, $changed) { var $element = $changed; - var column; + var column = void 0; function filterFieldsList(index, field) { return $(field).val() === column; } - // A field that has many different translatable parts can also define one - // or more columns that require all columns to be translatable. - for (var index in dependent_columns) { - if (dependent_columns.hasOwnProperty(index)) { - column = dependent_columns[index]; + Object.keys(dependentColumns || {}).forEach(function (index) { + column = dependentColumns[index]; - if (!$changed) { - $element = $fields.filter(filterFieldsList); - } - - if ($element.is('input[value="' + column + '"]:checked')) { - $fields.prop('checked', true) - .not($element).prop('disabled', true); - } - else { - $fields.prop('disabled', false); - } + if (!$changed) { + $element = $fields.filter(filterFieldsList); + } + if ($element.is('input[value="' + column + '"]:checked')) { + $fields.prop('checked', true).not($element).prop('disabled', true); + } else { + $fields.prop('disabled', false); } - } + }); } }; - /** - * Makes field translatability inherit bundle translatability. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches content translation behavior. - */ Drupal.behaviors.contentTranslation = { - attach: function (context) { - // Initially hide all field rows for non translatable bundles and all - // column rows for non translatable fields. + attach: function attach(context) { $(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () { var $input = $(this); var $bundleSettings = $input.closest('.bundle-settings'); if (!$input.is(':checked')) { $bundleSettings.nextUntil('.bundle-settings').hide(); - } - else { + } 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', function (e) { var $target = $(e.target); var $bundleSettings = $target.closest('.bundle-settings'); @@ -109,23 +73,19 @@ $bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true); $fieldSettings.find('.translatable :input').prop('checked', true); $settings.show(); - } - else { + } else { $settings.hide(); } - }) - .on('click', 'table .field-settings .translatable :input', function (e) { - var $target = $(e.target); - var $fieldSettings = $target.closest('.field-settings'); - var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings'); - if ($target.is(':checked')) { - $columnSettings.show(); - } - else { - $columnSettings.hide(); - } - }); + }).on('click', 'table .field-settings .translatable :input', function (e) { + var $target = $(e.target); + var $fieldSettings = $target.closest('.field-settings'); + var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings'); + if ($target.is(':checked')) { + $columnSettings.show(); + } else { + $columnSettings.hide(); + } + }); } }; - -})(jQuery, Drupal, drupalSettings); +})(jQuery, Drupal, drupalSettings); \ No newline at end of file