type_form.es6.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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)
  21. .find('input[name^="options"]:checked')
  22. .parent()
  23. .each(function() {
  24. vals.push(
  25. Drupal.checkPlain(
  26. $(this)
  27. .find('label')
  28. .text(),
  29. ),
  30. );
  31. });
  32. if (
  33. !$(context)
  34. .find('#edit-options-status')
  35. .is(':checked')
  36. ) {
  37. vals.unshift(Drupal.t('Not published'));
  38. }
  39. return vals.join(', ');
  40. });
  41. $(context)
  42. .find('#edit-language')
  43. .drupalSetSummary(context => {
  44. const vals = [];
  45. vals.push(
  46. $(context)
  47. .find(
  48. '.js-form-item-language-configuration-langcode select option:selected',
  49. )
  50. .text(),
  51. );
  52. $(context)
  53. .find('input:checked')
  54. .next('label')
  55. .each(function() {
  56. vals.push(Drupal.checkPlain($(this).text()));
  57. });
  58. return vals.join(', ');
  59. });
  60. },
  61. };
  62. })(jQuery, Drupal);