OSDN Git Service

mrg
[pettanr/pettanr.git] / app / assets / javascripts / models / ground_picture.js.coffee
1 class Pettanr.GroundPicture extends Peta.Element\r
2   url: '/ground_pictures/'\r
3   \r
4   @singular: () ->\r
5     'GroundPicture'\r
6   \r
7   @plural: () ->\r
8     'GroundPictures'\r
9   \r
10   defaults: {\r
11     id: null,\r
12     x: 0,\r
13     y: 0,\r
14     repeat: 0\r
15   } \r
16   \r
17   @repeat_texts: () -> \r
18     ['repeat', 'repeat-x', 'repeat-y', 'no-repeat']\r
19   \r
20   picture: () ->\r
21     new Pettanr.Picture({id: @get('picture_id')})\r
22   \r
23   has_picture: () ->\r
24     true\r
25   \r
26   tmb_opt_img_tag: (picture) ->\r
27     new Pettanr.Image.SymbolPicture({\r
28       attr: {\r
29         src: picture.r_url(), \r
30         alt: @get('caption')\r
31       },\r
32       picture: picture\r
33     })\r
34   \r
35   symbol_option: (cb) ->\r
36     i = @picture()\r
37     _this = this\r
38     i.fetch().done ->\r
39       cb(_this.tmb_opt_img_tag(i))\r
40   \r
41   repeat_text: () ->\r
42     Pettanr.GroundPicture.repeat_texts()[@get('repeat')]\r
43   \r
44   initialize: () ->\r
45     if @id\r
46       @url = @url + @id\r
47   \r
48 class Pettanr.GroundPicture.Collection extends Backbone.Collection\r
49   model: Pettanr.GroundPicture\r
50   url: '/ground_pictures/'\r
51   \r