OSDN Git Service

fix js
[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   filename: () ->\r
15     @get('id') + '.' + @get('ext')\r
16   \r
17   mime_type: () ->\r
18     'image/' + @get('ext')\r
19   \r
20   r_url: () ->\r
21     '/system_pictures/' + @filename()\r
22   \r
23   opt_img_tag: () ->\r
24     {src: @r_url(), width: @get('width'), height: @get('height')}\r
25   \r
26   tmb_opt_img_tag: () ->\r
27     new Pettanr.Image.SymbolPicture({\r
28       attr: {\r
29         src: @r_url()\r
30       },\r
31       picture: this\r
32     })\r
33   \r
34   symbol_option: (cb) ->\r
35     _this = this\r
36     this.fetch().done ->\r
37       cb(_this.tmb_opt_img_tag())\r
38   \r
39   initialize: () ->\r
40     if @id\r
41       @url = @url + @id\r
42   \r
43 class Pettanr.SystemPicture.Collection extends Backbone.Collection\r
44   model: Pettanr.SystemPicture\r
45   url: '/system_pictures'\r