OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / system_picture.js.coffee
1 class Pettanr.SystemPicture extends Peta.SystemResource\r
2   url: '/system_pictures/'\r
3   \r
4   @singular: () ->\r
5     'SystemPicture'\r
6   \r
7   @plural: () ->\r
8     'SystemPictures'\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   filename: () ->\r
18     @get('id') + '.' + @get('ext')\r
19   \r
20   mime_type: () ->\r
21     'image/' + @get('ext')\r
22   \r
23   r_url: () ->\r
24     '/system_pictures/' + @filename()\r
25   \r
26   opt_img_tag: () ->\r
27     {src: @r_url(), width: @get('width'), height: @get('height')}\r
28   \r
29   tmb_opt_img_tag: () ->\r
30     new Pettanr.Image.SymbolPicture({\r
31       attr: {\r
32         src: @r_url()\r
33       },\r
34       picture: this\r
35     })\r
36   \r
37   symbol_option: () ->\r
38     @fetch({cache: true}).done =>\r
39       @trigger('ready:symbol', @tmb_opt_img_tag())\r
40   \r
41   initialize: () ->\r
42     if @id\r
43       @url = @url + @id\r
44   \r