4c664a3ded98960fa42a00e082c29eb624f24a08
[yaffs-website] / web / core / modules / media / js / type_form.es6.js
1 /**
2  * @file
3  * Defines JavaScript behaviors for the media type form.
4  */
5
6 (function ($, Drupal) {
7   /**
8    * Behaviors for setting summaries on media type form.
9    *
10    * @type {Drupal~behavior}
11    *
12    * @prop {Drupal~behaviorAttach} attach
13    *   Attaches summary behaviors on media type edit forms.
14    */
15   Drupal.behaviors.mediaTypeFormSummaries = {
16     attach(context) {
17       const $context = $(context);
18       // Provide the vertical tab summaries.
19       $context.find('#edit-workflow').drupalSetSummary((context) => {
20         const vals = [];
21         $(context).find('input[name^="options"]:checked').parent().each(function () {
22           vals.push(Drupal.checkPlain($(this).find('label').text()));
23         });
24         if (!$(context).find('#edit-options-status').is(':checked')) {
25           vals.unshift(Drupal.t('Not published'));
26         }
27         return vals.join(', ');
28       });
29       $(context).find('#edit-language').drupalSetSummary((context) => {
30         const vals = [];
31
32         vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected').text());
33
34         $(context).find('input:checked').next('label').each(function () {
35           vals.push(Drupal.checkPlain($(this).text()));
36         });
37
38         return vals.join(', ');
39       });
40     },
41   };
42 }(jQuery, Drupal));