OSDN Git Service

fix: js models
[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   @singular: () ->\r
4     'SystemPicture'\r
5   \r
6   @plural: () ->\r
7     'SystemPictures'\r
8   \r
9   defaults: {\r
10     id: null\r
11   } \r
12   \r
13   filename: () ->\r
14     @get('id') + '.' + @get('ext')\r
15   \r
16   mime_type: () ->\r
17     'image/' + @get('ext')\r
18   \r
19   r_url: () ->\r
20     '/system_pictures/' + @filename()\r
21   \r
22   opt_img_tag: () ->\r
23     {src: @r_url(), width: @get('width'), height: @get('height')}\r
24   \r
25   tmb_opt_img_tag: () ->\r
26     wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
27     {src: @r_url(), width: wh[0], height: wh[1]}\r
28   \r
29   symbol_option: () ->\r
30     @tmb_opt_img_tag()\r
31   \r
32   initialize: () ->\r
33     if @id\r
34       @url = @url + @id\r
35   \r
36 class Pettanr.SystemPicture.Collection extends Backbone.Collection\r
37   model: Pettanr.SystemPicture\r
38   url: '/system_pictures'\r