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