OSDN Git Service

fix:balloon r
[pettanr/pettanr.git] / app / assets / javascripts / models / balloon.js.coffee
1 class Pettanr.Balloon extends Peta.Element\r
2   url: '/balloons/'\r
3   \r
4   @singular: () ->\r
5     'Balloon'\r
6   \r
7   @plural: () ->\r
8     'Balloons'\r
9   \r
10   defaults: {\r
11     id: null,\r
12     x: 0,\r
13     y: 0,\r
14     width: 100,\r
15     height: 100,\r
16     r: 0\r
17   } \r
18   \r
19   pick: () ->\r
20     # \r
21     speech_balloon_template = @templates.speech_balloon_template\r
22     {\r
23       speech_balloon_template_id: speech_balloon_template.get('id'),\r
24       speech_balloon_template_module_name: speech_balloon_template.get('module_name'),\r
25     }\r
26   \r
27   speech_balloon: () ->\r
28     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
29   \r
30   system_picture: () ->\r
31     new Pettanr.Cache.Retriever(Pettanr.SystemPicture, @get('system_picture_id'))\r
32   \r
33   r_url: () ->\r
34     '/system_pictures/' + @system_picture().filename()\r
35   \r
36   symbol_option: () ->\r
37     retriever = @speech_balloon()\r
38     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon)\r
39     retriever.retrieve()\r
40   \r
41   retrieve_speech_balloon: (speech_balloon) -> \r
42     retriever = speech_balloon.speech_balloon_template()\r
43     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
44     retriever.retrieve()\r
45   \r
46   retrieve_speech_balloon_template: (speech_balloon_template) -> \r
47     retriever = speech_balloon_template.system_picture()\r
48     @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
49     retriever.retrieve()\r
50   \r
51   retrieve_system_picture: (system_picture) -> \r
52     @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
53   \r
54   initialize: (attr, options) ->\r
55     super(attr, options)\r
56     if @id\r
57       @url = @url + @id\r
58     @bind('change:width', () ->\r
59       console.log('cng')\r
60     )\r
61   \r