OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / views / panel_pictures / show.js.coffee
index 89ca570..e2e2b66 100644 (file)
@@ -1,10 +1,68 @@
+class Pettanr.Views.PanelPicture.ShowModule\r
+class Pettanr.Views.PanelPicture.ShowModule.Header extends Pettanr.Views.Show.Header\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+  \r
 class Pettanr.Views.PanelPicture.Show extends Backbone.View\r
   tagName: 'div'\r
+  className: 'show'\r
   \r
   initialize: (options) ->\r
+    @item = options.item\r
     @operators = options.operators\r
+    icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
+    caption_url = icon_url\r
+    prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'})\r
+    @header = new Pettanr.Views.PanelPicture.ShowModule.Header({\r
+      item: @item, \r
+      operators: @operators,\r
+      caption: @item.get('caption'), \r
+      icon_url: icon_url,\r
+      caption_url: caption_url,\r
+      prof_url: prof_url\r
+    })\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.$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('navigate', @item.show_url())\r
+  \r
+  click_author: () ->\r
+    @trigger('navigate', @panel.author().show_url())\r
+  \r
+  click_prof: () ->\r
+    @trigger('navigate', @item.prof_url())\r
+  \r
+  click_credit_icon: (item) ->\r
+    @trigger('navigate', item.show_url())\r
+  \r