diff options
Diffstat (limited to 'core/modules/media/js/media_type_form.js')
-rw-r--r-- | core/modules/media/js/media_type_form.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/core/modules/media/js/media_type_form.js b/core/modules/media/js/media_type_form.js new file mode 100644 index 0000000..0c1d906 --- /dev/null +++ b/core/modules/media/js/media_type_form.js @@ -0,0 +1,46 @@ +/** + * @file + * Defines JavaScript behaviors for the media type form. + */ + +(function ($, Drupal) { + + 'use strict'; + + /** + * Behaviors for setting summaries on media type form. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Attaches summary behaviors on media type edit forms. + */ + Drupal.behaviors.mediaTypeFormSummaries = { + attach: function (context) { + var $context = $(context); + // Provide the vertical tab summaries. + $context.find('#edit-workflow').drupalSetSummary(function (context) { + var vals = []; + $(context).find('input[name^="options"]:checked').parent().each(function () { + vals.push(Drupal.checkPlain($(this).find('label').text())); + }); + if (!$(context).find('#edit-options-status').is(':checked')) { + vals.unshift(Drupal.t('Not published')); + } + return vals.join(', '); + }); + $(context).find('#edit-language').drupalSetSummary(function (context) { + var vals = []; + + vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected').text()); + + $(context).find('input:checked').next('label').each(function () { + vals.push(Drupal.checkPlain($(this).text())); + }); + + return vals.join(', '); + }); + } + }; + +})(jQuery, Drupal); |