book.js 853 B

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