3 * Defines Javascript behaviors for the block_content module.
6 (function ($, Drupal) {
11 * Sets summaries about revision and translation of entities.
13 * @type {Drupal~behavior}
15 * @prop {Drupal~behaviorAttach} attach
16 * Attaches summary behaviour entity form tabs.
18 * Specifically, it updates summaries to the revision information and the
19 * translation options.
21 Drupal.behaviors.entityContentDetailsSummaries = {
22 attach: function (context) {
23 var $context = $(context);
24 $context.find('.entity-content-form-revision-information').drupalSetSummary(function (context) {
25 var $revisionContext = $(context);
26 var revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
28 // Return 'New revision' if the 'Create new revision' checkbox is checked,
29 // or if the checkbox doesn't exist, but the revision log does. For users
30 // without the "Administer content" permission the checkbox won't appear,
31 // but the revision log will if the content type is set to auto-revision.
32 if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
33 return Drupal.t('New revision');
36 return Drupal.t('No revision');
39 $context.find('details.entity-translation-options').drupalSetSummary(function (context) {
40 var $translationContext = $(context);
42 var $checkbox = $translationContext.find('.js-form-item-translation-translate input');
44 if ($checkbox.length) {
45 translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
48 $checkbox = $translationContext.find('.js-form-item-translation-retranslate input');
49 translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');