OSDN Git Service

fix summary
[pettanr/pettanr.git] / app / assets / javascripts / views / common.js.coffee
diff --git a/app/assets/javascripts/views/common.js.coffee b/app/assets/javascripts/views/common.js.coffee
new file mode 100644 (file)
index 0000000..b2e384c
--- /dev/null
@@ -0,0 +1,20 @@
+class Pettanr.Views.Common\r
+class Pettanr.Views.Common.Icon extends Backbone.View\r
+  tagName: 'span'\r
+  \r
+  initialize: (options) ->\r
+    @item = options.item\r
+    @half = options.half\r
+    @icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
+    @icon = new Pettanr.Image.Icon({item: @item, half: @half})\r
+    @icon_button = new Tag.A({\r
+      attr: {href: '/' + @icon_url}, \r
+      handler_name: @icon_url,\r
+      class_name: 'icon',\r
+      content: @icon.render().el\r
+    })\r
+  \r
+  render: () ->\r
+    this.$el.html(@icon_button.render().el)\r
+    this\r
+  \r