diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index eed93f0..89465b4 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -17,46 +17,56 @@ */ Drupal.behaviors.contentTypes = { attach: function (context) { - var $context = $(context); // Provide the vertical tab summaries. - $context.find('#edit-submission').drupalSetSummary(function (context) { - var vals = []; - vals.push(Drupal.checkPlain($(context).find('#edit-title-label').val()) || Drupal.t('Requires a title')); - return vals.join(', '); - }); - $context.find('#edit-workflow').drupalSetSummary(function (context) { - var vals = []; - $(context).find('input[name^="options"]:checked').parent().each(function () { - vals.push(Drupal.checkPlain($(this).text())); + var tabs = { + '#edit-submission': getSummaryEditSubmission, + '#edit-workflow': getSummaryEditWorkflow, + '#edit-language': getSummaryEditLanguage, + '#edit-display': getSummaryEditDisplay + }; + $.each(tabs, function (id, getSummary) { + $(id, context).drupalSetSummary(function (context) { + return getSummary(context).join(', '); }); - if (!$(context).find('#edit-options-status').is(':checked')) { - vals.unshift(Drupal.t('Not published')); - } - return vals.join(', '); }); - $('#edit-language', context).drupalSetSummary(function (context) { - var vals = []; + } + }; - vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text()); + function getSummaryEditSubmission(context) { + var vals = []; + vals.push(Drupal.checkPlain($('#edit-title-label', context).val()) || Drupal.t('Requires a title')); + return vals; + } - $('input:checked', context).next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); - }); + function getSummaryEditWorkflow(context) { + var vals = []; + $('input[name^="options"]:checked', context).next('label').each(function () { + vals.push(Drupal.checkPlain($(this).text())); + }); + if (!$('#edit-options-status', context).is(':checked')) { + vals.unshift(Drupal.t('Not published')); + } + return vals; + } - return vals.join(', '); - }); - $context.find('#edit-display').drupalSetSummary(function (context) { - var vals = []; - var $editContext = $(context); - $editContext.find('input:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); - }); - if (!$editContext.find('#edit-display-submitted').is(':checked')) { - vals.unshift(Drupal.t("Don't display post information")); - } - return vals.join(', '); - }); + function getSummaryEditLanguage(context) { + var vals = []; + vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text()); + $('input:checked', context).next('label').each(function () { + vals.push(Drupal.checkPlain($(this).text())); + }); + return vals; + } + + function getSummaryEditDisplay(context) { + var vals = []; + $('input:checked', context).next('label').each(function () { + vals.push(Drupal.checkPlain($(this).text())); + }); + if (!$('#edit-display-submitted', context).is(':checked')) { + vals.unshift(Drupal.t("Don't display post information")); } - }; + return vals; + } })(jQuery, Drupal);