OSDN Git Service

fix:view
[pettanr/pettanr.git] / app / assets / javascripts / view / show / header / authored_by.js.coffee
diff --git a/app/assets/javascripts/view/show/header/authored_by.js.coffee b/app/assets/javascripts/view/show/header/authored_by.js.coffee
new file mode 100644 (file)
index 0000000..61fbb0a
--- /dev/null
@@ -0,0 +1,22 @@
+class Pettanr.View.Show.AuthoredBy extends Pettanr.View\r
+  tagName: 'div'\r
+  \r
+  initialize: (options) ->\r
+    @item = options.item\r
+    @item.get_parent(@item.my_class().owner_type(), this, {\r
+      success: (author) =>  # author or artist\r
+        @linked_author =  new Pettanr.View.ShortableCaption(author, 'name', {\r
+          click: () ->\r
+            @trigger('click:author')\r
+        })\r
+        @listenTo(@linked_author, 'click', @click)\r
+        @render()\r
+    })\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id'))\r
+    this.$el.append(@linked_author.render().el)\r
+    this\r
+  \r
+  \r