content_types.es6.js 2.0 KB

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