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