OSDN Git Service

fix event names
[pettanr/pettanr.git] / app / assets / javascripts / views / speech_balloons / show.js.coffee
index ee2ebb4..a2fe35e 100644 (file)
@@ -22,15 +22,47 @@ class Pettanr.Views.SpeechBalloon.Show extends Backbone.View
       caption_url: caption_url,\r
       prof_url: prof_url\r
     })\r
-    _this = this\r
-    @panel = @item.panel()\r
-    @panel.fetch().done ->\r
-      _this.author = new Pettanr.Views.Show.HeaderAuthor({item: _this.panel})\r
-      _this.render()\r
+    @listenTo(this, 'ready', @ready)\r
+    @panel = @item.panel().with_elements()\r
+    @panel.fetch({cache: false}).done =>  # with elements\r
+      @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
+      @body = new Pettanr.Views.Panel.Body({\r
+        panel: @panel,\r
+        operators: @operators,\r
+        spot: @item\r
+      })\r
+      @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
+        pictures: @panel.licensed_pictures()\r
+      })\r
+      @listenTo(@header, 'click:icon', @click_show)\r
+      @listenTo(@header, 'click:caption', @click_show)\r
+      @listenTo(@header, 'click:prof', @click_prof)\r
+      @listenTo(@author, 'click:author', @click_author)\r
+      @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
+      @trigger('ready')\r
   \r
   render: () ->\r
     this.$el.html('')\r
+    this\r
+  \r
+  ready: () ->\r
+    this.$el.html('')\r
     this.$el.append(@header.render().el)\r
     this.$el.append(@author.render().el)\r
-    this\r
+    this.$el.append(@body.render().el)\r
+    this.$el.append(@credits.render().el)\r
+    rb = new Tag.RowBreak()\r
+    this.$el.append(rb.render().el)\r
+  \r
+  click_show: () ->\r
+    @trigger('http_get', @item.show_url())\r
+  \r
+  click_author: () ->\r
+    @trigger('http_get', @panel.author().show_url())\r
+  \r
+  click_prof: () ->\r
+    @trigger('http_get', @item.prof_url())\r
+  \r
+  click_credit_icon: (item) ->\r
+    @trigger('http_get', item.show_url())\r
   \r