content_types.es6.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file
  3. * Javascript for the node content editing form.
  4. */
  5. (function($, Drupal) {
  6. /**
  7. * Behaviors for setting summaries on content type form.
  8. *
  9. * @type {Drupal~behavior}
  10. *
  11. * @prop {Drupal~behaviorAttach} attach
  12. * Attaches summary behaviors on content type edit forms.
  13. */
  14. Drupal.behaviors.contentTypes = {
  15. attach(context) {
  16. const $context = $(context);
  17. // Provide the vertical tab summaries.
  18. $context.find('#edit-submission').drupalSetSummary(context => {
  19. const vals = [];
  20. vals.push(
  21. Drupal.checkPlain(
  22. $(context)
  23. .find('#edit-title-label')
  24. .val(),
  25. ) || Drupal.t('Requires a title'),
  26. );
  27. return vals.join(', ');
  28. });
  29. $context.find('#edit-workflow').drupalSetSummary(context => {
  30. const vals = [];
  31. $(context)
  32. .find('input[name^="options"]:checked')
  33. .next('label')
  34. .each(function() {
  35. vals.push(Drupal.checkPlain($(this).text()));
  36. });
  37. if (
  38. !$(context)
  39. .find('#edit-options-status')
  40. .is(':checked')
  41. ) {
  42. vals.unshift(Drupal.t('Not published'));
  43. }
  44. return vals.join(', ');
  45. });
  46. $('#edit-language', context).drupalSetSummary(context => {
  47. const vals = [];
  48. vals.push(
  49. $(
  50. '.js-form-item-language-configuration-langcode select option:selected',
  51. context,
  52. ).text(),
  53. );
  54. $('input:checked', context)
  55. .next('label')
  56. .each(function() {
  57. vals.push(Drupal.checkPlain($(this).text()));
  58. });
  59. return vals.join(', ');
  60. });
  61. $context.find('#edit-display').drupalSetSummary(context => {
  62. const vals = [];
  63. const $editContext = $(context);
  64. $editContext
  65. .find('input:checked')
  66. .next('label')
  67. .each(function() {
  68. vals.push(Drupal.checkPlain($(this).text()));
  69. });
  70. if (!$editContext.find('#edit-display-submitted').is(':checked')) {
  71. vals.unshift(Drupal.t("Don't display post information"));
  72. }
  73. return vals.join(', ');
  74. });
  75. },
  76. };
  77. })(jQuery, Drupal);