annotate 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
rev   line source
Chris@0 1 /**
Chris@0 2 * @file
Chris@0 3 * Defines Javascript behaviors for the node module.
Chris@0 4 */
Chris@0 5
Chris@0 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@0 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@0 25 return Drupal.t('By @name on @date', { '@name': name, '@date': date });
Chris@0 26 }
Chris@0 27 else if (name) {
Chris@0 28 return Drupal.t('By @name', { '@name': name });
Chris@0 29 }
Chris@0 30 else if (date) {
Chris@0 31 return Drupal.t('Authored on @date', { '@date': date });
Chris@0 32 }
Chris@0 33 });
Chris@0 34
Chris@0 35 $context.find('.node-form-options').drupalSetSummary((context) => {
Chris@0 36 const $optionsContext = $(context);
Chris@0 37 const vals = [];
Chris@0 38
Chris@0 39 if ($optionsContext.find('input').is(':checked')) {
Chris@0 40 $optionsContext.find('input:checked').next('label').each(function () {
Chris@0 41 vals.push(Drupal.checkPlain($.trim($(this).text())));
Chris@0 42 });
Chris@0 43 return vals.join(', ');
Chris@0 44 }
Chris@0 45
Chris@0 46 return Drupal.t('Not promoted');
Chris@0 47 });
Chris@0 48 },
Chris@0 49 };
Chris@0 50 }(jQuery, Drupal, drupalSettings));