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   @pick: () ->\r
15   \r
16   @pick_item_name: () ->\r
17     'resource_picture'\r
18   \r
19   @pick_model: () ->\r
20     Manifest.item_name_to_model(@pick_item_name())\r
21   \r
22   @traceable_item_names: () ->\r
23     ['ground_picture', 'picture']\r
24   \r
25   @is_traceable: (item_name) ->\r
26     _.contains(@traceable_item_names(), item_name)\r
27   \r
28   trace_from_ground_picture: () ->\r
29   \r
30   trace_from_picture: () ->\r
31   \r
32   picture: () ->\r
33     new Pettanr.Picture({id: @get('picture_id')})\r
34   \r
35   panel: (options = {}) ->\r
36     new Pettanr.Panel({id: @get('panel_id')}, options)\r
37   \r
38   @has_picture: () ->\r
39     true\r
40   \r
41   flip: () ->\r
42     v = if @get('height') > 0\r
43       ''\r
44     else\r
45       'v'\r
46     h = if @get('width') > 0\r
47       ''\r
48     else\r
49       'h'\r
50     res = v + h\r
51     res = res # format of /1.png?subdir=v\r
52     # res += '/' unless res.empty? # format of /v/1.png\r
53     res\r
54   \r
55   filename: (picture) ->\r
56     q = if _.isEmpty(@flip())\r
57       ''\r
58     else\r
59       '?subdir=' + @flip()\r
60     picture.filename() + q\r
61   \r
62   r_url: (picture) ->\r
63     '/pictures/' + @filename(picture)\r
64   \r
65   tmb_opt_img_tag: (picture) ->\r
66     new Pettanr.Image.SymbolPicture({\r
67       attr: {\r
68         src: picture.r_url(), \r
69         alt: @escape('caption')\r
70       },\r
71       picture: picture\r
72     })\r
73   \r
74   symbol_option: () ->\r
75     i = @picture()\r
76     i.fetch({cache: true}).done =>\r
77       @trigger('ready:symbol', i.tmb_opt_img_tag())\r
78   \r
79   element_face: () ->\r
80     new Pettanr.Views.PanelPicture.ElementFace({element: this})\r
81   \r
82   initialize: () ->\r
83     if @id\r
84       @url = @url + @id\r
85     @bind('change:width', () ->\r
86       console.log('cng')\r
87     )\r
88   \r