file_name: () ->\r
'/images/loading.gif'\r
\r
-class Pettanr.Views.Common.BackIcon extends Pettanr.Views.Common.EmptyIcon\r
+class Pettanr.Views.Common.RootIcon extends Pettanr.Views.Common.EmptyIcon\r
\r
file_name: () ->\r
- '/images/back.png'\r
+ '/images/root.png'\r
\r
-class Pettanr.Views.Common.ForwardIcon extends Pettanr.Views.Common.EmptyIcon\r
+class Pettanr.Views.Common.PickIcon extends Backbone.View\r
\r
- file_name: () ->\r
- '/images/forward.png'\r
+ initialize: (options) ->\r
+ @class_name = options.class_name\r
+ @name = options.name\r
+ @half = options.half\r
+ @button = if @is_button()\r
+ @linked_icon()\r
+ else\r
+ @icon()\r
\r
-class Pettanr.Views.Common.RootIcon extends Pettanr.Views.Common.EmptyIcon\r
+ render: () ->\r
+ this.$el.html('')\r
+ @el.className = @class_name if @class_name\r
+ if @is_button()\r
+ @listenTo(@button, 'click', @click)\r
+ this.$el.append(@button.render().el)\r
+ this\r
\r
- file_name: () ->\r
- '/images/root.png'\r
+ is_button: () ->\r
+ @name != 'none'\r
+ \r
+ icon: () ->\r
+ new Pettanr.Image.SymbolImg({attr: {src: '/images/' + @name + '.gif'}, half: @half})\r
+ \r
+ linked_icon: () ->\r
+ new Tag.A({\r
+ attr: {href: '#'},\r
+ content: @icon().render().el\r
+ })\r
+ \r
+ click: () ->\r
+ @trigger('click', this)\r
\r
class Pettanr.Views.Common.EmptyCaption extends Backbone.View\r
tagName: 'div'\r
@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
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