Chris@0: /** Chris@0: * @file Chris@0: * Defines Javascript behaviors for the node module. Chris@0: */ Chris@0: Chris@0: (function ($, Drupal, drupalSettings) { Chris@0: /** Chris@0: * Behaviors for tabs in the node edit form. Chris@0: * Chris@0: * @type {Drupal~behavior} Chris@0: * Chris@0: * @prop {Drupal~behaviorAttach} attach Chris@0: * Attaches summary behavior for tabs in the node edit form. Chris@0: */ Chris@0: Drupal.behaviors.nodeDetailsSummaries = { Chris@0: attach(context) { Chris@0: const $context = $(context); Chris@0: Chris@0: $context.find('.node-form-author').drupalSetSummary((context) => { Chris@0: const $authorContext = $(context); Chris@0: const name = $authorContext.find('.field--name-uid input').val(); Chris@0: const date = $authorContext.find('.field--name-created input').val(); Chris@0: Chris@0: if (name && date) { Chris@0: return Drupal.t('By @name on @date', { '@name': name, '@date': date }); Chris@0: } Chris@0: else if (name) { Chris@0: return Drupal.t('By @name', { '@name': name }); Chris@0: } Chris@0: else if (date) { Chris@0: return Drupal.t('Authored on @date', { '@date': date }); Chris@0: } Chris@0: }); Chris@0: Chris@0: $context.find('.node-form-options').drupalSetSummary((context) => { Chris@0: const $optionsContext = $(context); Chris@0: const vals = []; Chris@0: Chris@0: if ($optionsContext.find('input').is(':checked')) { Chris@0: $optionsContext.find('input:checked').next('label').each(function () { Chris@0: vals.push(Drupal.checkPlain($.trim($(this).text()))); Chris@0: }); Chris@0: return vals.join(', '); Chris@0: } Chris@0: Chris@0: return Drupal.t('Not promoted'); Chris@0: }); Chris@0: }, Chris@0: }; Chris@0: }(jQuery, Drupal, drupalSettings));