OSDN Git Service

fix event
[pettanr/pettanr.git] / app / assets / javascripts / locmare / filer / header.js.coffee
index 47804b9..6b4fbec 100644 (file)
@@ -6,13 +6,19 @@ class Locmare.FilerModule.Header extends Backbone.View
   \r
   render: () ->\r
     this.$el.html('')\r
-    icon = new Pettanr.Picture.Icon({item: @model()})\r
+    icon = new Pettanr.Image.Icon({item: @model(), half: true})\r
     caption = Pettanr.AppHelper.t_m(@model().singular())\r
-    url = Pettanr.url(@model().table_name(), 'index', {})\r
-    linked_icon = new Pettanr.Tag.A({href: url, content: icon.render().el})\r
-    linked_caption = new Pettanr.Tag.A({href: url, content: caption})\r
-    this.$el.append(linked_icon)\r
-    this.$el.append(linked_caption)\r
+    url = @model().index_url()\r
+    linked_icon = new Tag.A({\r
+      attr: {href: '/' + url}, content: icon.render().el\r
+    })\r
+    linked_caption = new Tag.A({\r
+      attr: {href: '/' + url}, content: caption\r
+    })\r
+    @listenTo(linked_icon, 'click', @click)\r
+    @listenTo(linked_caption, 'click', @click)\r
+    this.$el.append(linked_icon.render().el)\r
+    this.$el.append(linked_caption.render().el)\r
     this\r
   \r
   model: () ->\r
@@ -21,3 +27,6 @@ class Locmare.FilerModule.Header extends Backbone.View
   human_name: () ->\r
     @model.model_name.human\r
   \r
+  click: () ->\r
+    @trigger('click', @model().index_url())\r
+  \r