OSDN Git Service

fix: show's destroy button
[pettanr/pettanr.git] / app / assets / javascripts / models / balloon.js.coffee
index 918997c..d4a5040 100644 (file)
@@ -1,2 +1,55 @@
 class Pettanr.Balloon extends Peta.Element\r
-\r
+  \r
+  @singular: () ->\r
+    'Balloon'\r
+  \r
+  @plural: () ->\r
+    'Balloons'\r
+  \r
+  defaults: {\r
+    id: null,\r
+    x: 0,\r
+    y: 0,\r
+    width: 100,\r
+    height: 100,\r
+    r: 0\r
+  } \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
+  speech_balloon: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.SpeechBalloon, @get('speech_balloon_id'))\r
+  \r
+  system_picture: () ->\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
+    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
+  \r