Skip to content

Instantly share code, notes, and snippets.

@virginia
Created February 10, 2012 03:41
Show Gist options
  • Save virginia/1786252 to your computer and use it in GitHub Desktop.
Save virginia/1786252 to your computer and use it in GitHub Desktop.
Google Preview
$(document).ready(function() {
google.load("books", "0");
var viewerHeight;
var headerHeight;
function viewerInit() {
// var header = $(document.body).down('.header');
headerHeight = 40;
viewerHeight = 700;
var vDiv = $('#viewerCanvas');
vDiv.css({
height: viewerHeight + "px"
});
var viewer = new google.books.DefaultViewer(
vDiv.get(0),
{ 'showLinkChrome': false }
);
viewer.load('ISBN:' + window.bookISBN, null, showButton);
}
function showButton() {
var btn = $('#viewerButton');
btn.click(showViewer);
btn.html("» Preview this book");
btn.show('medium');
}
function showViewer() {
var viewer = $('#viewerContainer');
var btn = $('#viewerButton');
if (!window.noBookSlide) {
viewer.animate({
height: viewerHeight + "px"
},
400,
function() {
console.log("showing!");
});
} else {
viewer.css({ height: viewerHeight + "px" });
}
viewer.css({ visibility: "visible" });
btn.html('« Hide the preview');
btn.click(hideViewer);
}
function hideViewer() {
var viewer = $('#viewerContainer');
var btn = $('#viewerButton');
if (!window.noBookSlide) {
viewer.animate({
height: 0
},
400
);
console.log("hiding!");
} else {
viewer.css({ visibility: "hidden", height: "0" });
}
btn.html('» Preview this book!');
btn.click(showViewer);
}
google.setOnLoadCallback(viewerInit);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment