Mercurial > hg > isophonics-drupal-site
annotate core/modules/media/js/form.es6.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * @file |
Chris@0 | 3 * Defines Javascript behaviors for the media form. |
Chris@0 | 4 */ |
Chris@0 | 5 |
Chris@17 | 6 (function($, Drupal) { |
Chris@0 | 7 /** |
Chris@0 | 8 * Behaviors for summaries for tabs in the media 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 media edit form. |
Chris@0 | 14 */ |
Chris@0 | 15 Drupal.behaviors.mediaFormSummaries = { |
Chris@0 | 16 attach(context) { |
Chris@0 | 17 const $context = $(context); |
Chris@0 | 18 |
Chris@17 | 19 $context.find('.media-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@0 | 38 }; |
Chris@17 | 39 })(jQuery, Drupal); |