Commit 5362c163 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#181125 follow up by beginner: book.js should have been removed earlier in...

#181125 follow up by beginner: book.js should have been removed earlier in #181125, was a commit mistake
parent f96a1c76
// $Id$
Drupal.behaviors.bookSelect = function(context) {
// This behavior attaches by ID, so is only valid once on a page.
if ($('#edit-book-bid.book-select-processed').size()) {
return;
}
// Hide the button in the node form, since it's not needed when JS is enabled.
$('#edit-book-pick-book').css('display', 'none');
// Binds a function to the keyup and change actions of the book select to
// retrieve parent options. Mark as processed so this binding is only done once.
$('#edit-book-bid')
.keyup(Drupal.bookFillSelect)
.change(Drupal.bookFillSelect)
.addClass('book-select-processed');
};
// This function passes the form information and the book ID to a Drupal callback
// and retrieves a parent select with changed options to replace the one in the form.
Drupal.bookFillSelect = function() {
// Create a progress bar and substitute it for the parent select.
pb = new Drupal.progressBar('book_progress');
pb.setProgress(-1, Drupal.t('Updating parents...'));
$('#edit-book-plid-wrapper').html(pb.element);
$.ajax({
url: Drupal.settings.book.formCallback +'/'+ $('#'+ Drupal.settings.book.formId +' input[name=form_build_id]').val() +'/'+ $('#edit-book-bid').val(),
dataType: 'json',
success: function(data) {
// Insert the new select, and remove the progress bar.
$('#edit-book-plid-wrapper').after(data['book']).remove();
}
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment