Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / node / node.es6.js
1 /**
2  * @file
3  * Defines Javascript behaviors for the node module.
4  */
5
6 (function($, Drupal, drupalSettings) {
7   /**
8    * Behaviors for tabs in the node edit form.
9    *
10    * @type {Drupal~behavior}
11    *
12    * @prop {Drupal~behaviorAttach} attach
13    *   Attaches summary behavior for tabs in the node edit form.
14    */
15   Drupal.behaviors.nodeDetailsSummaries = {
16     attach(context) {
17       const $context = $(context);
18
19       $context.find('.node-form-author').drupalSetSummary(context => {
20         const $authorContext = $(context);
21         const name = $authorContext.find('.field--name-uid input').val();
22         const date = $authorContext.find('.field--name-created input').val();
23
24         if (name && date) {
25           return Drupal.t('By @name on @date', {
26             '@name': name,
27             '@date': date,
28           });
29         }
30         if (name) {
31           return Drupal.t('By @name', { '@name': name });
32         }
33         if (date) {
34           return Drupal.t('Authored on @date', { '@date': date });
35         }
36       });
37
38       $context.find('.node-form-options').drupalSetSummary(context => {
39         const $optionsContext = $(context);
40         const vals = [];
41
42         if ($optionsContext.find('input').is(':checked')) {
43           $optionsContext
44             .find('input:checked')
45             .next('label')
46             .each(function() {
47               vals.push(Drupal.checkPlain($.trim($(this).text())));
48             });
49           return vals.join(', ');
50         }
51
52         return Drupal.t('Not promoted');
53       });
54     },
55   };
56 })(jQuery, Drupal, drupalSettings);