2012-10-11 17:01:49 +00:00
|
|
|
/**
|
2022-09-09 06:26:42 +00:00
|
|
|
* @file
|
|
|
|
* JavaScript behaviors for the Book module.
|
|
|
|
*/
|
2012-10-11 17:01:49 +00:00
|
|
|
|
2016-02-29 03:25:57 +00:00
|
|
|
(function ($, Drupal) {
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Adds summaries to the book outline form.
|
|
|
|
*
|
|
|
|
* @type {Drupal~behavior}
|
|
|
|
*
|
|
|
|
* @prop {Drupal~behaviorAttach} attach
|
|
|
|
* Attaches summary behavior to book outline forms.
|
|
|
|
*/
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.bookDetailsSummaries = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context) {
|
2022-09-09 06:26:42 +00:00
|
|
|
$(context)
|
|
|
|
.find('.book-outline-form')
|
|
|
|
.drupalSetSummary((context) => {
|
|
|
|
const $select = $(context).find('.book-title-select');
|
|
|
|
const val = $select[0].value;
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
if (val === '0') {
|
|
|
|
return Drupal.t('Not in book');
|
|
|
|
}
|
|
|
|
if (val === 'new') {
|
|
|
|
return Drupal.t('New book');
|
|
|
|
}
|
|
|
|
return Drupal.checkPlain($select.find(':selected')[0].textContent);
|
|
|
|
});
|
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2022-09-09 06:26:42 +00:00
|
|
|
})(jQuery, Drupal);
|