type_form.es6.js 1.3 KB

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