OSDN Git Service

conflict
[pettanr/pettanr.git] / app / assets / javascripts / views / resource_pictures / show.js.coffee
index 39afdbb..d50ad42 100644 (file)
@@ -1,9 +1,61 @@
-class Pettanr.Views.ResourcePicture.Show extends Backbone.View\r
-  tagName: 'div'\r
+class Pettanr.Views.ResourcePicture.Show extends Pettanr.View.Show\r
   \r
   initialize: (options) ->\r
+    @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
+    @authored_by = @item.authored_by()\r
+    @img = @item.real_picture('full')\r
+    @listenTo(@header, 'click:pick', @click_pick)\r
+    @listenTo(@authored_by, 'click', @click_authored_by)\r
   \r
   render: () ->\r
     this.$el.html('')\r
+    this.$el.append(@header.render().el)\r
+    this.$el.append(@authored_by.render().el)\r
+    this.$el.append(@img.render().el)\r
+    @item.get_parent('picture', this, {\r
+      success: (picture) =>\r
+        @add_credit(picture)\r
+    })\r
+    if @item.is_own()\r
+      @item.get_parent('original_picture', this, {\r
+        success: (@original_picture) =>\r
+          @owner = new Pettanr.View.Show.Footer(null, this, {\r
+            actions: {\r
+              replace: {\r
+                item: @original_picture,\r
+                url: @original_picture.edit_url(),\r
+                dic_name: 'original_pictures.show.replace',\r
+                click: () =>\r
+                  @trigger('http_get', @original_picture.edit_url())\r
+              }, \r
+              source: {\r
+                item: @original_picture,\r
+                url: @original_picture.show_url(),\r
+                dic_name: 'original_pictures.show.title',\r
+                click: () =>\r
+                  @trigger('http_get', @original_picture.show_url())\r
+              }, \r
+              stop: {\r
+                item: @item,\r
+                url: @item.destroy_url(),\r
+                dic_name: 'original_pictures.index.stop',\r
+                click: () =>\r
+                  redirect = (url) =>\r
+                    @trigger('http_get', url)\r
+                  Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
+              }, \r
+            }, \r
+          })\r
+          this.$el.append(@owner.render().el)\r
+      })\r
     this\r
   \r
+  click_pick: () ->\r
+    @trigger('pick', @item)\r
+  \r
+  is_pickable: () ->\r
+    true\r
+  \r
+  add_pick: (target_model) ->\r
+    @header.add_pick(target_model)\r
+  \r