OSDN Git Service

fix: js models
[pettanr/pettanr.git] / app / assets / javascripts / models / speech_balloon_template.js.coffee
1 class Pettanr.SpeechBalloonTemplate extends Peta.Template\r
2   relations: [{\r
3     type: Backbone.HasMany,\r
4     key: 'speech_balloons',\r
5     relatedModel: 'SpeechBalloon',\r
6     collectionType: 'SpeechBalloonCollection',\r
7     reverseRelation: {\r
8       key: 'livesIn',\r
9       includeInJSON: 'id'\r
10     }\r
11   }]\r
12   \r
13   @singular: () ->\r
14     'SpeechBalloonTemplate'\r
15   \r
16   @plural: () ->\r
17     'SpeechBalloonTemplates'\r
18   \r
19   defaults: {\r
20     id: null\r
21   } \r
22   \r
23   get_system_picture: () ->\r
24     new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
25   \r
26   symbol_option: () ->\r
27     _this = this\r
28     r = @get_system_picture()\r
29     r.fetch({}).done () ->\r
30       _this.system_picture = r\r
31       _this.system_picture.tmb_opt_img_tag()\r
32   \r
33   initialize: () ->\r
34     if @id\r
35       @url = @url + @id\r
36     @system_picture = null\r
37   \r
38 class Pettanr.SpeechBalloonTemplate.Collection extends Backbone.Collection\r
39   model: Pettanr.SpeechBalloonTemplate\r
40   url: '/speech_balloon_templates'\r