X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fcore%2Fmodules%2Fbook%2Fbook.js;fp=web%2Fcore%2Fmodules%2Fbook%2Fbook.js;h=2cc788126479f4baf475416aa477bbb5fe88f478;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/book/book.js b/web/core/modules/book/book.js new file mode 100644 index 000000000..2cc788126 --- /dev/null +++ b/web/core/modules/book/book.js @@ -0,0 +1,37 @@ +/** + * @file + * Javascript behaviors for the Book module. + */ + +(function ($, Drupal) { + + 'use strict'; + + /** + * Adds summaries to the book outline form. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Attaches summary behavior to book outline forms. + */ + Drupal.behaviors.bookDetailsSummaries = { + attach: function (context) { + $(context).find('.book-outline-form').drupalSetSummary(function (context) { + var $select = $(context).find('.book-title-select'); + var val = $select.val(); + + if (val === '0') { + return Drupal.t('Not in book'); + } + else if (val === 'new') { + return Drupal.t('New book'); + } + else { + return Drupal.checkPlain($select.find(':selected').text()); + } + }); + } + }; + +})(jQuery, Drupal);