OSDN Git Service

add credit
[pettanr/pettanr.git] / app / assets / javascripts / models / balloon.js.coffee
index 918997c..e6986f4 100644 (file)
@@ -1,2 +1,44 @@
 class Pettanr.Balloon extends Peta.Element\r
+  url: '/balloons/'\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
+  speech_balloon: () ->\r
+    new Pettanr.SpeechBalloon({id: @get('speech_balloon_id')})\r
+  \r
+  system_picture: () ->\r
+    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
+  \r
+  r_url: () ->\r
+    '/system_pictures/' + @system_picture().filename()\r
+  \r
+  symbol_option: (cb) ->\r
+    sb = @speech_balloon()\r
+    sb.fetch().done ->\r
+      sbt = sb.speech_balloon_template()\r
+      sbt.fetch().done ->\r
+        sp = sbt.system_picture()\r
+        sp.fetch().done ->\r
+          cb(sp.tmb_opt_img_tag())\r
+  \r
+  initialize: () ->\r
+    if @id\r
+      @url = @url + @id\r
+  \r
+class Pettanr.Balloon.Collection extends Backbone.Collection\r
+  model: Pettanr.Balloon\r
+  url: '/balloons'\r
 \r