blob: 8987630e5ce4f356453df1c23bad28b8fd7ef82f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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('')
$('<button>').text("Zoom Out").click(zoomOut).appendTo(menu)
$('<button>').text("Zoom In").click(zoomIn).appendTo(menu)
$('<button>').text("Fit Page Height").click(fitPageHeight).appendTo(menu)
$('<div>').addClass('loading').appendTo(menu)
$('.spacer').height(menu.height())
$('.paper').scroll(updatePageNumber)
loadHighRes()
|