summaryrefslogtreecommitdiffstats
path: root/core/modules/media/js/media_form.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/media/js/media_form.js')
-rw-r--r--core/modules/media/js/media_form.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/modules/media/js/media_form.js b/core/modules/media/js/media_form.js
new file mode 100644
index 0000000..c93eac6
--- /dev/null
+++ b/core/modules/media/js/media_form.js
@@ -0,0 +1,40 @@
+/**
+ * @file
+ * Defines Javascript behaviors for the media form.
+ */
+
+(function ($, Drupal) {
+
+ 'use strict';
+
+ /**
+ * Behaviors for summaries for tabs in the media edit form.
+ *
+ * @type {Drupal~behavior}
+ *
+ * @prop {Drupal~behaviorAttach} attach
+ * Attaches summary behavior for tabs in the media edit form.
+ */
+ Drupal.behaviors.mediaFormSummaries = {
+ attach: function (context) {
+ var $context = $(context);
+
+ $context.find('.media-form-author').drupalSetSummary(function (context) {
+ var $authorContext = $(context);
+ var name = $authorContext.find('.field--name-uid input').val();
+ var date = $authorContext.find('.field--name-created input').val();
+
+ if (name && date) {
+ return Drupal.t('By @name on @date', {'@name': name, '@date': date});
+ }
+ else if (name) {
+ return Drupal.t('By @name', {'@name': name});
+ }
+ else if (date) {
+ return Drupal.t('Authored on @date', {'@date': date});
+ }
+ });
+ }
+ };
+
+})(jQuery, Drupal);