From 247f5d615539784c46b5c7c5b35b6ee348e04151 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 4 May 2012 09:48:27 -0700 Subject: initial commit --- view.coffee | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 view.coffee (limited to 'view.coffee') diff --git a/view.coffee b/view.coffee new file mode 100644 index 0000000..8987630 --- /dev/null +++ b/view.coffee @@ -0,0 +1,54 @@ +$ = jQuery + +toReplace = 0 +replaced = 0 + +class imageReplacer + constructor: (@orig, @src) -> + @replacement = new Image() + @replacement.onload = @replace + @replacement.src = @src + toReplace++ + @updateText() + replace: => + $(@orig).replaceWith(@replacement) + replaced++ + @updateText() + updateText: => + if ((toReplace-replaced)>0) + $('.loading').text('Please be patient, loading high-quality images ('+replaced+'/'+toReplace+')') + else + $('.loading').text('') + +loadHighRes = -> + images = $('img') + for image in images + new imageReplacer(image, image.src.replace('.small.', '.')) + +zoomIn = -> + width = $('.paper').width() + $('.paper').width(width*1.1) + +zoomOut = -> + width = $('.paper').width() + $('.paper').width(width*(1/1.1)) + +fitPageHeight = -> + page_height = $('.paper img').height() + page_width = $('.paper img').width() + window_height = $(window).height() - $('.menu').height() + # We now want to set page_height=window_height, but through page_width + $('.paper').width(window_height*(2*page_width/page_height)) + +updatePageNumber = -> + + +$ -> + menu = $('.menu').text('') + $('