OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / panel_picture.js.coffee
1 class Pettanr.PanelPicture extends Peta.Element\r
2   url: '/panel_pictures/'\r
3   \r
4   @singular: () ->\r
5     'PanelPicture'\r
6   \r
7   @plural: () ->\r
8     'PanelPictures'\r
9   \r
10   defaults: {\r
11     id: null\r
12   } \r
13   \r
14   picture: () ->\r
15     new Pettanr.Picture({id: @get('picture_id')})\r
16   \r
17   panel: (options = {}) ->\r
18     new Pettanr.Panel({id: @get('panel_id')}, options)\r
19   \r
20   @has_picture: () ->\r
21     true\r
22   \r
23   flip: () ->\r
24     v = if @get('height') > 0\r
25       ''\r
26     else\r
27       'v'\r
28     h = if @get('width') > 0\r
29       ''\r
30     else\r
31       'h'\r
32     res = v + h\r
33     res = res # format of /1.png?subdir=v\r
34     # res += '/' unless res.empty? # format of /v/1.png\r
35     res\r
36   \r
37   filename: (picture) ->\r
38     q = if _.isEmpty(@flip())\r
39       ''\r
40     else\r
41       '?subdir=' + @flip()\r
42     picture.filename() + q\r
43   \r
44   r_url: (picture) ->\r
45     '/pictures/' + @filename(picture)\r
46   \r
47   tmb_opt_img_tag: (picture) ->\r
48     new Pettanr.Image.SymbolPicture({\r
49       attr: {\r
50         src: picture.r_url(), \r
51         alt: @escape('caption')\r
52       },\r
53       picture: picture\r
54     })\r
55   \r
56   symbol_option: () ->\r
57     i = @picture()\r
58     i.fetch({cache: true}).done =>\r
59       @trigger('ready:symbol', i.tmb_opt_img_tag())\r
60   \r
61   element_face: () ->\r
62     new Pettanr.Views.PanelPicture.ElementFace({element: this})\r
63   \r
64   initialize: () ->\r
65     if @id\r
66       @url = @url + @id\r
67     @bind('change:width', () ->\r
68       console.log('cng')\r
69     )\r
70   \r