OSDN Git Service

5027f4e377dd74f03e0554b5a807f0d755da7073
[pettanr/pettanr.git] / app / assets / javascripts / views / balloons / summary.js.coffee
1 class Pettanr.Views.Balloon.Summary extends Pettanr.Views.Common.Summary\r
2   \r
3   initialize: (options) ->\r
4     super(options)\r
5     @item = options.item\r
6     @load()\r
7   \r
8   load: () ->\r
9     @speech_balloon = @item.speech_balloon()\r
10     @speech_balloon.fetch({cache: true}).done =>\r
11       panel = @speech_balloon.panel()\r
12       panel.fetch({cache: true}).done =>\r
13         @panel_icon = new Pettanr.Views.Common.Icon({item: panel, half: true})\r
14         @listenTo(@panel_icon, 'click', @panel_click)\r
15         author = panel.author()\r
16         author.fetch({cache: true}).done =>\r
17           @author_icon_with_caption = author.icon_with_caption_view(true, 'name', 12)\r
18           @listenTo(@author_icon_with_caption, 'click', @author_click)\r
19           @trigger('ready')\r
20   \r
21   render: () ->\r
22     this.$el.html('')\r
23     this.$el.append(@panel_icon.render().el)\r
24     this.$el.append(@author_icon_with_caption.render().el)\r
25     this\r
26   \r
27   panel_click: () ->\r
28     @trigger('navigate', @panel_icon.url())\r
29   \r
30   author_click: () ->\r
31     @trigger('navigate', @author_icon_with_caption.url())\r
32   \r