1 // resize the iframe based on internal contents on page load
2 function autoResize(id){
6 if(document.getElementById){
7 newheight = document.getElementById(id).contentWindow.document .body.scrollHeight;
8 newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth;
11 document.getElementById(id).height = (newheight + 10) + "px";
12 document.getElementById(id).width= (newwidth + 5) + "px";
15 function rescalePdf(viewer, frameWidth) {
17 var outlineWidth = 250;
18 var pdfWidth = frameWidth;
20 if ($(viewer.sidebar).hasClass('opened')){
21 pdfWidth = pdfWidth - 250;
24 var newPdfScale = pdfWidth / scaleBase;
25 viewer.rescale(newPdfScale);
28 function setupPdfViewer() {
29 var noteFrame = document.getElementById("noteframe")
30 var pdfViewer = noteFrame.contentWindow.pdf2htmlEX.defaultViewer;
32 $('#plus-btn').click(function (){
33 pdfViewer.rescale(1.20, true, [0,0]);
36 $('#minus-btn').click(function (){
37 pdfViewer.rescale(0.80, true, [0,0]);
40 // detect if the PDF viewer wants to show an outline
42 if ($(pdfViewer.sidebar).hasClass('opened')) {
44 // if the screen is less than 64em wide, hide the outline
45 if (parseInt($(body.width()).toEm({scope: body})) < 64) {
46 $(pdfViewer.sidebar).removeClass('opened');
50 $('#outline-btn').click(function() {
51 $(pdfViewer.sidebar).toggleClass('opened');
52 // rescale the PDF to fit the available space
53 rescalePdf(pdfViewer, parseInt(noteFrame.width));
56 $('#scroll-to').change(function() {
57 page = parseInt($(this).val());
58 pdfViewer.scroll_to(page, [0,0]);
61 // rescale the PDF to fit the available space
62 rescalePdf(pdfViewer, parseInt(noteFrame.width));
66 $("#thank-button").click(function() {
67 event.preventDefault();
69 // increment number in page right away
70 var thankNumber = $("#thank-number");
71 thankNumber.text(parseInt(thankNumber.text()) + 1);
73 // disable thank button so it can't
76 $('#thank-button-disabled').show();
77 $(this).unbind('click');
79 // tell server that somebody thanked