OSDN Git Service

change editor
[pettanr/pettanr.git] / app / assets / javascripts / views / common.js.coffee
index 88ac3a1..c34e908 100644 (file)
@@ -169,11 +169,17 @@ class Pettanr.Views.Common.Binder.Summary extends Pettanr.Views.Common.Summary
     @visible = new Tag.Div({\r
       content: Pettanr.AppHelper.t_selected_item(@visible_t, @item.get(@visible_column_name))\r
     })\r
-    @author = @item.author()\r
-    @author.fetch({cache: true}).done =>\r
-      @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12)\r
-      @listenTo(@author_icon_with_caption, 'click', @author_click)\r
-      @trigger('ready')\r
+    @empty_author = @item.author()\r
+    @author = Pettanr.cache.restore(@empty_author)\r
+    if @author\r
+      # got cached author\r
+      @render_author()\r
+    else\r
+      # built empty author\r
+      @author = @empty_author\r
+      @author.fetch({cache: true}).done =>\r
+        Pettanr.cache.store(@author)\r
+        @render_author()\r
   \r
   render: () ->\r
     this.$el.html('')\r
@@ -181,6 +187,11 @@ class Pettanr.Views.Common.Binder.Summary extends Pettanr.Views.Common.Summary
     this.$el.append(@author_icon_with_caption.render().el)\r
     this\r
   \r
+  render_author: () ->\r
+    @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12)\r
+    @listenTo(@author_icon_with_caption, 'click', @author_click)\r
+    @trigger('ready')\r
+  \r
   author_click: () ->\r
     @trigger('http_get', @author_icon_with_caption.url())\r
   \r