OSDN Git Service

fix filer
[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     wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height'))\r
28     new Pettanr.AppHelperImg({src: @r_url(), size: wh[0]})\r
29   \r
30   symbol_option: (cb) ->\r
31     _this = this\r
32     this.fetch().done ->\r
33       cb(_this.tmb_opt_img_tag())\r
34   \r
35   initialize: () ->\r
36     if @id\r
37       @url = @url + @id\r
38   \r
39 class Pettanr.SystemPicture.Collection extends Backbone.Collection\r
40   model: Pettanr.SystemPicture\r
41   url: '/system_pictures'\r