Mercurial > hg > cmmr2012-drupal-site
annotate 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 |
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@0 | 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@0 | 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@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 }; |
Chris@0 | 36 }(jQuery, Drupal)); |