OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / view / image.js.coffee
1 class Pettanr.View.Image\r
2   \r
3   @thumbnail_size: () ->\r
4     [Manifest.manifest().magic_numbers['thumbnail_width'], Manifest.manifest().magic_numbers['thumbnail_height']]\r
5   \r
6   @to_thumbnail_size: (w, h) ->\r
7     s = @thumbnail_size()\r
8     @fix_size_both(s[0], s[1], w, h)\r
9   \r
10   @minicon_size: () ->\r
11     [Math.floor(Manifest.manifest().magic_numbers['thumbnail_width'] / 2), Math.floor(Manifest.manifest().magic_numbers['thumbnail_height'] / 2)]\r
12   \r
13   @to_minicon_size: (w, h) ->\r
14     s = @minicon_size()\r
15     @fix_size_both(s[0], s[1], w, h)\r
16   \r
17   @fix_size_both: (limw, limh, w, h)->\r
18     wr = if w > limw\r
19       limw*100/w\r
20     else\r
21       100\r
22     hr = if h > limh\r
23       limh*100/h\r
24     else\r
25       100\r
26     r = if wr < hr\r
27       [Math.floor(w*wr/100), Math.floor(h*wr/100)]\r
28     else\r
29       [Math.floor(w*hr/100), Math.floor(h*hr/100)]\r
30     r\r
31   \r
32   @image_dir: () ->\r
33     '/images/'\r
34   \r
35   @icon_prof_file: () ->\r
36     new Pettanr.ImageFile(@image_dir() + 'prof.gif')\r
37   \r
38   @icon_edit_file: () ->\r
39     new Pettanr.ImageFile(@image_dir() + 'edit.png')\r
40   \r
41   @icon_destroy_file: () ->\r
42     new Pettanr.ImageFile(@image_dir() + 'remove.png')\r
43   \r
44   @icon_inspire_file: () ->\r
45     new Pettanr.ImageFile(@image_dir() + 'inspire.gif')\r
46   \r
47   @icon_loading_file: () ->\r
48     new Pettanr.ImageFile(@image_dir() + 'loading.gif')\r
49   \r
50   @icon_root_file: () ->\r
51     new Pettanr.ImageFile(@image_dir() + 'root.png')\r
52   \r
53   @icon_pick_file: (type) ->\r
54     new Pettanr.ImageFile(@image_dir() + type + '.gif')\r
55   \r