website/core/misc/details-summarized-contentdfb4.js

39 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-09-30 09:40:37 +02:00
/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal) {
function DetailsSummarizedContent(node) {
this.$node = $(node);
this.setupSummary();
}
$.extend(DetailsSummarizedContent, {
instances: []
});
$.extend(DetailsSummarizedContent.prototype, {
setupSummary: function setupSummary() {
this.$detailsSummarizedContentWrapper = $(Drupal.theme('detailsSummarizedContentWrapper'));
this.$node.on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)).trigger('summaryUpdated').find('> summary').append(this.$detailsSummarizedContentWrapper);
},
onSummaryUpdated: function onSummaryUpdated() {
var text = this.$node.drupalGetSummary();
this.$detailsSummarizedContentWrapper.html(Drupal.theme('detailsSummarizedContentText', text));
}
});
Drupal.behaviors.detailsSummary = {
attach: function attach(context) {
DetailsSummarizedContent.instances = DetailsSummarizedContent.instances.concat(once('details', 'details', context).map(function (details) {
return new DetailsSummarizedContent(details);
}));
}
};
Drupal.DetailsSummarizedContent = DetailsSummarizedContent;
Drupal.theme.detailsSummarizedContentWrapper = function () {
return "<span class=\"summary\"></span>";
};
Drupal.theme.detailsSummarizedContentText = function (text) {
return text ? " (".concat(text, ")") : '';
};
})(jQuery, Drupal);