diff --git a/core/core.libraries.yml b/core/core.libraries.yml index 0b3b12855f..ecaea2907f 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -122,7 +122,7 @@ drupal.checkbox: drupal.collapse: version: VERSION js: - misc/details-content-synopsis.js: {} + misc/details-summary-outline.js: {} misc/details-aria.js: {} misc/collapse.js: {} dependencies: diff --git a/core/misc/details-content-synopsis.es6.js b/core/misc/details-summary-outline.es6.js similarity index 50% rename from core/misc/details-content-synopsis.es6.js rename to core/misc/details-summary-outline.es6.js index b724a279e0..442fdf42ce 100644 --- a/core/misc/details-content-synopsis.es6.js +++ b/core/misc/details-summary-outline.es6.js @@ -1,37 +1,37 @@ /** * @file - * Adds a synopsis of a details element's contents to its summary. + * Adds an outline of a details element's contents to its summary. */ (($, Drupal) => { /** - * The DetailsContentSynopsis object represents a single details element. + * The DetailsSummaryOutline object represents a single details element. * - * @constructor Drupal.DetailsContentSynopsis + * @constructor Drupal.DetailsSummaryOutline * * @param {HTMLElement} node * A details element, the summary of which may have supplemental text. - * The supplemental text is a synopsis of the details element's contents. + * The supplemental text is summarizes the details element's contents. */ - function DetailsContentSynopsis(node) { + function DetailsSummaryOutline(node) { this.$node = $(node); this.setupSummary(); } $.extend( - DetailsContentSynopsis, - /** @lends Drupal.DetailsContentSynopsis */ { + DetailsSummaryOutline, + /** @lends Drupal.DetailsSummaryOutline */ { /** - * Holds references to instantiated DetailsContentSynopsis objects. + * Holds references to instantiated DetailsSummaryOutline objects. * - * @type {Array.} + * @type {Array.} */ instances: [], }, ); $.extend( - DetailsContentSynopsis.prototype, - /** @lends Drupal.DetailsContentSynopsis# */ { + DetailsSummaryOutline.prototype, + /** @lends Drupal.DetailsSummaryOutline# */ { /** * Initialize and setup summary events and markup. * @@ -40,14 +40,14 @@ * @listens event:summaryUpdated */ setupSummary() { - this.$synopsizedDetailsContentWrapper = $( - Drupal.theme('synopsizedDetailsContentWrapper'), + this.$detailsSummaryOutlineWrapper = $( + Drupal.theme('detailsSummaryOutlineWrapper'), ); this.$node .on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)) .trigger('summaryUpdated') .find('> summary') - .append(this.$synopsizedDetailsContentWrapper); + .append(this.$detailsSummaryOutlineWrapper); }, /** @@ -55,15 +55,15 @@ */ onSummaryUpdated() { const text = $.trim(this.$node.drupalGetSummary()); - this.$synopsizedDetailsContentWrapper.html( - Drupal.theme('synopsizedDetailsContent', text), + this.$detailsSummaryOutlineWrapper.html( + Drupal.theme('detailsSummaryOutlineContent', text), ); }, }, ); /** - * Adds a synopsis of a details element's contents to its summary. + * Adds an outline of a details element's contents to its summary. * * @type {Drupal~behavior} * @@ -78,27 +78,28 @@ $detailsElements.map( (index, details) => // eslint-disable-next-line no-new - new DetailsContentSynopsis(details), + new DetailsSummaryOutline(details), ); }, }; /** - * The element containing the synopsis of the detail element's contents. + * The element containing the outline of the detail element's contents. * * @return {string} - * The markup for the element that will contain the synopsis text. + * The markup for the element that will contain the outline text. */ - Drupal.theme.synopsizedDetailsContentWrapper = () => + Drupal.theme.detailsSummaryOutlineWrapper = () => ``; /** - * Formats a summary's synopsis text. + * Formats a summary's outline text. * * @param {string|null} [text] - * (optional) The synopsis text displayed by the summary. + * (optional) The outline text displayed by the summary. * @return {string} - * The formatted synopsis text. + * The formatted outline text. */ - Drupal.theme.synopsizedDetailsContent = text => (text ? ` (${text})` : ''); + Drupal.theme.detailsSummaryOutlineContent = text => + text ? ` (${text})` : ''; })(jQuery, Drupal); diff --git a/core/misc/details-content-synopsis.js b/core/misc/details-summary-outline.js similarity index 61% rename from core/misc/details-content-synopsis.js rename to core/misc/details-summary-outline.js index f3b60768c3..374f080292 100644 --- a/core/misc/details-content-synopsis.js +++ b/core/misc/details-summary-outline.js @@ -6,38 +6,38 @@ **/ (function ($, Drupal) { - function DetailsContentSynopsis(node) { + function DetailsSummaryOutline(node) { this.$node = $(node); this.setupSummary(); } - $.extend(DetailsContentSynopsis, { + $.extend(DetailsSummaryOutline, { instances: [] }); - $.extend(DetailsContentSynopsis.prototype, { + $.extend(DetailsSummaryOutline.prototype, { setupSummary: function setupSummary() { - this.$synopsizedDetailsContentWrapper = $(Drupal.theme('synopsizedDetailsContentWrapper')); - this.$node.on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)).trigger('summaryUpdated').find('> summary').append(this.$synopsizedDetailsContentWrapper); + this.$detailsSummaryOutlineWrapper = $(Drupal.theme('detailsSummaryOutlineWrapper')); + this.$node.on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)).trigger('summaryUpdated').find('> summary').append(this.$detailsSummaryOutlineWrapper); }, onSummaryUpdated: function onSummaryUpdated() { var text = $.trim(this.$node.drupalGetSummary()); - this.$synopsizedDetailsContentWrapper.html(Drupal.theme('synopsizedDetailsContent', text)); + this.$detailsSummaryOutlineWrapper.html(Drupal.theme('detailsSummaryOutlineContent', text)); } }); Drupal.behaviors.detailsSummary = { attach: function attach(context) { var $detailsElements = $(context).find('details').once('details'); $detailsElements.map(function (index, details) { - return new DetailsContentSynopsis(details); + return new DetailsSummaryOutline(details); }); } }; - Drupal.theme.synopsizedDetailsContentWrapper = function () { + Drupal.theme.detailsSummaryOutlineWrapper = function () { return ""; }; - Drupal.theme.synopsizedDetailsContent = function (text) { + Drupal.theme.detailsSummaryOutlineContent = function (text) { return text ? " (".concat(text, ")") : ''; }; })(jQuery, Drupal); \ No newline at end of file diff --git a/core/modules/node/tests/src/FunctionalJavascript/CollapsedSummariesTest.php b/core/modules/node/tests/src/FunctionalJavascript/CollapsedSummariesTest.php index 1b1b743833..e6736c9ea6 100644 --- a/core/modules/node/tests/src/FunctionalJavascript/CollapsedSummariesTest.php +++ b/core/modules/node/tests/src/FunctionalJavascript/CollapsedSummariesTest.php @@ -5,7 +5,7 @@ use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** - * Tests that summaries of form values are displayed on meta details elements. + * Tests that outlines of node meta values are displayed in summaries and tabs. * * @group node */ diff --git a/core/themes/claro/js/details.es6.js b/core/themes/claro/js/details.es6.js index ff25f0453c..33a0708aca 100644 --- a/core/themes/claro/js/details.es6.js +++ b/core/themes/claro/js/details.es6.js @@ -57,21 +57,21 @@ }; /** - * Theme override of element containing supplemental summary text. + * Theme override providing a wrapper for a detail element's content outline. * * @return {string} - * The markup for the element that will contain supplemental summary text. + * The markup for the element that will contain the content outline. */ - Drupal.theme.detailsSummarySummary = () => + Drupal.theme.detailsSummaryOutlineWrapper = () => ``; /** - * Theme override of supplemental summary text. + * Theme override of a summary's outline text. * * @param {string|null} [text] - * (optional) The additional text displayed by the summary. + * (optional) The outline text displayed by the summary. * @return {string} - * The formatted text that will be appended to the summary element. + * The formatted outline text. */ - Drupal.theme.detailsSummarySummaryText = text => text || ''; + Drupal.theme.detailsSummaryOutlineContent = text => text || ''; })(jQuery, Modernizr, Drupal); diff --git a/core/themes/claro/js/details.js b/core/themes/claro/js/details.js index bb9462446c..ead19595ea 100644 --- a/core/themes/claro/js/details.js +++ b/core/themes/claro/js/details.js @@ -32,11 +32,11 @@ } }; - Drupal.theme.detailsSummarySummary = function () { + Drupal.theme.detailsSummaryOutlineWrapper = function () { return ""; }; - Drupal.theme.detailsSummarySummaryText = function (text) { + Drupal.theme.detailsSummaryOutlineContent = function (text) { return text || ''; }; })(jQuery, Modernizr, Drupal); \ No newline at end of file