comparison core/modules/media/js/form.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 media form.
4 */
5
6 (function ($, Drupal) {
7 /**
8 * Behaviors for summaries for tabs in the media edit form.
9 *
10 * @type {Drupal~behavior}
11 *
12 * @prop {Drupal~behaviorAttach} attach
13 * Attaches summary behavior for tabs in the media edit form.
14 */
15 Drupal.behaviors.mediaFormSummaries = {
16 attach(context) {
17 const $context = $(context);
18
19 $context.find('.media-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 };
36 }(jQuery, Drupal));