-
-
Save makenosound/1786285 to your computer and use it in GitHub Desktop.
Google Preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
google.load("books", "0"); | |
var viewerHeight; | |
var headerHeight; | |
var btn = $('#viewerButton'); // Single ref. | |
var viewer = $('#viewerContainer'); | |
function viewerInit() { | |
// var header = $(document.body).down('.header'); | |
headerHeight = 40; | |
viewerHeight = 700; | |
var vDiv = $('#viewerCanvas'); | |
vDiv.css({ | |
height: viewerHeight + "px" | |
}); | |
var gViewer = new google.books.DefaultViewer( | |
vDiv.get(0), { | |
'showLinkChrome': false | |
}); | |
gViewer.load('ISBN:' + window.bookISBN, null, showButton); | |
} | |
function showButton() { | |
btn.on("click", showViewer); | |
btn.html("» Preview this book"); | |
btn.show('medium'); | |
} | |
function showViewer() { | |
// Unbind | |
btn.off("click", showViewer); | |
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.on("click", hideViewer); | |
} | |
function hideViewer() { | |
btn.off("click", hideViewer); | |
if (!window.noBookSlide) { | |
viewer.animate({ | |
height: 0 | |
}, 400); | |
console.log("hiding!"); | |
} else { | |
viewer.css({ | |
visibility: "hidden", | |
height: "0" | |
}); | |
} | |
btn.html('» Preview this book!'); | |
btn.on("click", showViewer); | |
} | |
google.setOnLoadCallback(viewerInit); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment