class Pettanr.Views.Common\r
+class Pettanr.Views.Common.LoadIcon extends Tag.Img\r
+ \r
+ initialize: () ->\r
+ @attr = {}\r
+ @width = Manifest.manifest().magic_numbers['thumbnail_width']\r
+ @height = Manifest.manifest().magic_numbers['thumbnail_height']\r
+ @width = Pettanr.to_i(@width/2)\r
+ @height = Pettanr.to_i(@height/2)\r
+ @attr['src'] = '/images/loading.gif'\r
+ @attr['width'] = @width\r
+ @attr['height'] = @height\r
+ @attr['alt'] = 'Loading'\r
+ @attr['title'] = 'Loading'\r
+ opt = {\r
+ attr: @attr,\r
+ }\r
+ super(opt)\r
+\r
class Pettanr.Views.Common.Icon extends Backbone.View\r
tagName: 'span'\r
\r
this.$el.append(@caption.render().el)\r
this\r
\r
+class Pettanr.Views.Common.Summary extends Backbone.View\r
+ \r
+ initialize: (options) ->\r
+ @clear()\r
+ @listenTo(this, 'ready', @render)\r
+ \r
+ clear: () ->\r
+ icon = new Pettanr.Views.Common.LoadIcon()\r
+ this.$el.html(icon.render().el)\r
+ this\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this\r
+ \r
class Pettanr.Views.Common.Binder\r
-class Pettanr.Views.Common.Binder.Summary extends Backbone.View\r
+class Pettanr.Views.Common.Binder.Summary extends Pettanr.Views.Common.Summary\r
\r
initialize: (options) ->\r
+ super(options)\r
@item = options.item\r
@visible_t = options.visible_t\r
@visible_column_name = options.visible_column_name\r
+ @load()\r
+ \r
+ load: () ->\r
@visible = new Tag.Div({\r
content: Pettanr.AppHelper.t_selected_item(@visible_t, @item.get(@visible_column_name))\r
})\r
- _this = this\r
@author = @item.author()\r
- @author.fetch({cache: true}).done ->\r
- _this.author_icon_with_caption = _this.author.icon_with_caption_view(true, 'name', 12)\r
- _this.render()\r
+ @author.fetch({cache: true}).done =>\r
+ @author_icon_with_caption = @author.icon_with_caption_view(true, 'name', 12)\r
+ @trigger('ready')\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(@visible.render().el)\r
- if @author_icon_with_caption\r
- this.$el.append(@author_icon_with_caption.render().el)\r
+ this.$el.append(@author_icon_with_caption.render().el)\r
this\r
\r
class Pettanr.Views.Common.Leaf\r
-class Pettanr.Views.Common.Leaf.Summary extends Backbone.View\r
+class Pettanr.Views.Common.Leaf.Summary extends Pettanr.Views.Common.Summary\r
\r
initialize: (options) ->\r
+ super(options)\r
@item = options.item\r
@binder_item_name = options.binder_item_name\r
@destination_item_name = options.destination_item_name\r
- _this = this\r
+ @load()\r
+ \r
+ load: () ->\r
@binder = @item[@binder_item_name]()\r
- @binder.fetch({cache: true}).done ->\r
- _this.binder_icon = _this.binder.icon_view(true)\r
- _this.binder_author = _this.binder.author()\r
- _this.binder_author.fetch({cache: true}).done ->\r
- _this.binder_author_icon_with_caption = _this.binder_author.icon_with_caption_view(true, 'name', 12)\r
- _this.render()\r
+ @binder.fetch({cache: true}).done =>\r
+ @binder_icon = @binder.icon_view(true)\r
+ @binder_author = @binder.author()\r
+ @binder_author.fetch({cache: true}).done =>\r
+ @binder_author_icon_with_caption = @binder_author.icon_with_caption_view(true, 'name', 12)\r
+ @trigger('ready')\r
@destination = @item[@destination_item_name]()\r
- @destination.fetch({cache: true}).done ->\r
- _this.destination_icon = _this.destination.icon_view(true)\r
- _this.destination_author = _this.destination.author()\r
- _this.destination_author.fetch({cache: true}).done ->\r
- _this.destination_author_icon_with_caption = _this.destination_author.icon_with_caption_view(true, 'name', 12)\r
- _this.render()\r
+ @destination.fetch({cache: true}).done =>\r
+ @destination_icon = @destination.icon_view(true)\r
+ @destination_author = @destination.author()\r
+ @destination_author.fetch({cache: true}).done =>\r
+ @destination_author_icon_with_caption = @destination_author.icon_with_caption_view(true, 'name', 12)\r
+ @trigger('ready')\r
\r
render: () ->\r
this.$el.html('')\r
- if @binder_author_icon_with_caption and @destination_author_icon_with_caption\r
+ if @binder_author_icon_with_caption\r
this.$el.append(@binder_icon.render().el)\r
this.$el.append(@binder_author_icon_with_caption.render().el)\r
+ if @destination_author_icon_with_caption\r
this.$el.append(@destination_icon.render().el)\r
this.$el.append(@destination_author_icon_with_caption.render().el)\r
this\r