OSDN Git Service

fix:balloon edit
[pettanr/pettanr.git] / app / assets / javascripts / pettanr / pettan_imager.js.coffee
1 class Pettanr.Imager
2   @thumbnail_size: (w, h) ->
3     lw = Manifest.manifest().magic_numbers['thumbnail_width']
4     lh = Manifest.manifest().magic_numbers['thumbnail_height']
5     Pettanr.Imager.fix_size_both lw, lh, w, h
6   
7   @fix_size_both: (limw, limh, w, h)->
8     wr = if w > limw
9       limw*100/w
10     else
11       100
12     hr = if h > limh
13       limh*100/h
14     else
15       100
16     r = if wr < hr
17       [Math.floor(w*wr/100), Math.floor(h*wr/100)]
18     else
19       [Math.floor(w*hr/100), Math.floor(h*hr/100)]
20     r
21