OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / models / speech_balloon.js.coffee
index c10b7b5..4cb0e9c 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SpeechBalloon extends Peta.Element\r
-  url: '/speech_balloons/'\r
   \r
   @singular: () ->\r
     'SpeechBalloon'\r
@@ -13,30 +12,48 @@ class Pettanr.SpeechBalloon extends Peta.Element
     t: null\r
   } \r
   \r
-  panel: () ->\r
-    new Pettanr.Panel({id: @get('panel_id')})\r
+  @pick_item_name: () ->\r
+    'speech_balloon_template'\r
   \r
-  speech_balloon_template: () ->\r
-    new Pettanr.SpeechBalloonTemplate({id: @get('speech_balloon_template_id')})\r
+  @traceable_item_names: () ->\r
+    ['speech', 'balloon']\r
+  \r
+  pick: () ->\r
+    # \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
+    }\r
+  \r
+  @trace_routes: () ->\r
+    {\r
+      symbol: ['speech_balloon_template', 'system_picture'],\r
+    }\r
   \r
   @has_picture: () ->\r
     false\r
   \r
-  symbol_option: (cb) ->\r
-    sbt = @speech_balloon_template()\r
-    sbt.fetch({cache: true}).done ->\r
-      sp = sbt.system_picture()\r
-      sp.fetch({cache: true}).done ->\r
-        cb(sp.tmb_opt_img_tag())\r
+  filer_caption: (context, options) ->\r
+    @get_child('balloon', this, {\r
+      success: (balloon) => \r
+        @get_child('speech', this, {\r
+          success: (speech) => \r
+            plain_scenario = @plain_scenario() + balloon.plain_scenario() + speech.plain_scenario()\r
+            options.success.call(context, plain_scenario)\r
+          fail: (response, opt) =>\r
+            options.fail.call(context, response, opt)\r
+        })\r
+      fail: (response, opt) =>\r
+        options.fail.call(context, response, opt)\r
+    })\r
   \r
   plain_scenario: () ->\r
-    @get('caption')\r
+    @escape('caption')\r
   \r
-  initialize: () ->\r
-    if @id\r
-      @url = @url + @id\r
+  element_face: () ->\r
+    new Pettanr.Views.SpeechBalloon.ElementFace({element: this})\r
   \r
-class Pettanr.SpeechBalloon.Collection extends Backbone.Collection\r
-  model: Pettanr.SpeechBalloon\r
-  url: '/speech_balloons/'\r
+  initialize: (attr, options) ->\r
+    super(attr, options)\r
   \r