book.es6.js 796 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @file
  3. * Javascript behaviors for the Book module.
  4. */
  5. (function ($, Drupal) {
  6. /**
  7. * Adds summaries to the book outline form.
  8. *
  9. * @type {Drupal~behavior}
  10. *
  11. * @prop {Drupal~behaviorAttach} attach
  12. * Attaches summary behavior to book outline forms.
  13. */
  14. Drupal.behaviors.bookDetailsSummaries = {
  15. attach(context) {
  16. $(context).find('.book-outline-form').drupalSetSummary((context) => {
  17. const $select = $(context).find('.book-title-select');
  18. const val = $select.val();
  19. if (val === '0') {
  20. return Drupal.t('Not in book');
  21. }
  22. else if (val === 'new') {
  23. return Drupal.t('New book');
  24. }
  25. return Drupal.checkPlain($select.find(':selected').text());
  26. });
  27. },
  28. };
  29. }(jQuery, Drupal));