OSDN Git Service

add scroll player
[pettanr/pettanr.git] / app / assets / javascripts / views / show.js.coffee
index d4eaeee..4a23494 100644 (file)
@@ -62,6 +62,28 @@ class Pettanr.Views.Show.HeaderAuthor extends Backbone.View
     this.$el.append(@linked_author.render().el) if @linked_author\r
     this\r
   \r
+class Pettanr.Views.Show.LinkedEditButton extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    edit_url = Pettanr.url(item.table_name(), 'edit', {id: item.get('id')})\r
+    super({\r
+      attr: {href: '/' + edit_url}, \r
+      handler_name: edit_url,\r
+      content: I18n.t('link.edit')\r
+    })\r
+  \r
+class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    edit_url = Pettanr.url(item.table_name(), 'destroy', {id: item.get('id')})\r
+    super({\r
+      attr: {href: '/' + edit_url}, \r
+      handler_name: edit_url,\r
+      content: I18n.t('link.destroy')\r
+    })\r
+  \r
 class Pettanr.Views.Show.OwnerFooter extends Backbone.View\r
   tagName: 'div'\r
   className: 'show-owner-footer'\r
@@ -70,18 +92,8 @@ class Pettanr.Views.Show.OwnerFooter extends Backbone.View
     super(options)\r
     @item = options.item\r
     @operators = options.operators\r
-    @edit_url = Pettanr.url(@item.table_name(), 'edit', {id: @item.get('id')})\r
-    @edit =  new Tag.A({\r
-      attr: {href: '/' + @edit_url}, \r
-      handler_name: @edit_url,\r
-      content: I18n.t('link.edit')\r
-    })\r
-    @destroy_url = Pettanr.url(@item.table_name(), 'destroy', {id: @item.get('id')})\r
-    @destroy =  new Tag.A({\r
-      attr: {href: '/' + @destroy_url}, \r
-      handler_name: @destroy_url,\r
-      content: I18n.t('link.destroy')\r
-    })\r
+    @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})\r
+    @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})\r
   \r
   render: () ->\r
     this.$el.html('')\r