comparison core/modules/node/node.es6.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
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', { '@name': name, '@date': date });
26 }
27 else if (name) {
28 return Drupal.t('By @name', { '@name': name });
29 }
30 else if (date) {
31 return Drupal.t('Authored on @date', { '@date': date });
32 }
33 });
34
35 $context.find('.node-form-options').drupalSetSummary((context) => {
36 const $optionsContext = $(context);
37 const vals = [];
38
39 if ($optionsContext.find('input').is(':checked')) {
40 $optionsContext.find('input:checked').next('label').each(function () {
41 vals.push(Drupal.checkPlain($.trim($(this).text())));
42 });
43 return vals.join(', ');
44 }
45
46 return Drupal.t('Not promoted');
47 });
48 },
49 };
50 }(jQuery, Drupal, drupalSettings));