OSDN Git Service

change: cache system
[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: (templates) ->\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       speech_balloon_template_settings: speech_balloon_template.get('settings')\r
26     }\r
27   \r
28   speech_balloon: () ->\r
29     new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
30   \r
31   system_picture: () ->\r
32     new Pettanr.Cache.Retriever(Pettanr.SystemPicture, @get('system_picture_id'))\r
33   \r
34   r_url: () ->\r
35     '/system_pictures/' + @system_picture().filename()\r
36   \r
37   symbol_option: () ->\r
38     retriever = @speech_balloon()\r
39     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon)\r
40     retriever.retrieve()\r
41   \r
42   retrieve_speech_balloon: (speech_balloon) -> \r
43     retriever = speech_balloon.speech_balloon_template()\r
44     @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
45     retriever.retrieve()\r
46   \r
47   retrieve_speech_balloon_template: (speech_balloon_template) -> \r
48     retriever = speech_balloon_template.system_picture()\r
49     @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
50     retriever.retrieve()\r
51   \r
52   retrieve_system_picture: (system_picture) -> \r
53     @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
54   \r
55   initialize: (attr, options) ->\r
56     super(attr, options)\r
57     if @id\r
58       @url = @url + @id\r
59     @bind('change:width', () ->\r
60       console.log('cng')\r
61     )\r
62   \r