OSDN Git Service

fix:balloon r
[pettanr/pettanr.git] / app / assets / javascripts / models / balloon.js.coffee
index c1ca348..f50e03b 100644 (file)
@@ -16,32 +16,40 @@ class Pettanr.Balloon extends Peta.Element
     r: 0\r
   } \r
   \r
-  pick: (templates) ->\r
+  pick: () ->\r
     # \r
-    speech_balloon_template = templates.speech_balloon_template\r
+    speech_balloon_template = @templates.speech_balloon_template\r
     {\r
       speech_balloon_template_id: speech_balloon_template.get('id'),\r
       speech_balloon_template_module_name: speech_balloon_template.get('module_name'),\r
-      speech_balloon_template_settings: speech_balloon_template.get('settings')\r
     }\r
   \r
   speech_balloon: () ->\r
-    new Pettanr.SpeechBalloon({id: @get('speech_balloon_id')})\r
+    new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
   \r
   system_picture: () ->\r
-    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
+    new Pettanr.Cache.Retriever(Pettanr.SystemPicture, @get('system_picture_id'))\r
   \r
   r_url: () ->\r
     '/system_pictures/' + @system_picture().filename()\r
   \r
   symbol_option: () ->\r
-    sb = @speech_balloon()\r
-    sb.fetch({cache: true}).done =>\r
-      sbt = sb.speech_balloon_template()\r
-      sbt.fetch({cache: true}).done =>\r
-        sp = sbt.system_picture()\r
-        sp.fetch({cache: true}).done =>\r
-          @trigger('ready:symbol', sp.tmb_opt_img_tag())\r
+    retriever = @speech_balloon()\r
+    @listenTo(retriever, 'retrieve', @retrieve_speech_balloon)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_speech_balloon: (speech_balloon) -> \r
+    retriever = speech_balloon.speech_balloon_template()\r
+    @listenTo(retriever, 'retrieve', @retrieve_speech_balloon_template)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_speech_balloon_template: (speech_balloon_template) -> \r
+    retriever = speech_balloon_template.system_picture()\r
+    @listenTo(retriever, 'retrieve', @retrieve_system_picture)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_system_picture: (system_picture) -> \r
+    @trigger('ready:symbol', system_picture.tmb_opt_img_tag())\r
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r