OSDN Git Service

fix: view system2
[pettanr/pettanr.git] / app / assets / javascripts / view / summary / leaf.js.coffee
1 class Pettanr.View.Summary.Leaf extends Pettanr.View\r
2   \r
3   initialize: (options) ->\r
4     super(options)\r
5     @item = options.item\r
6     @binder_item_name = options.binder_item_name\r
7     @destination_item_name = options.destination_item_name\r
8     @binder_view = new Tag.Span({})\r
9     @destination_view = new Tag.Span({})\r
10     @load()\r
11   \r
12   load: () ->\r
13     @listenTo(this, 'load_binder', @load_destination)\r
14     @listenTo(this, 'load_destination', @ready)\r
15     @load_binder()\r
16   \r
17   ready: () ->\r
18     @trigger('ready')\r
19   \r
20   load_binder: () ->\r
21     @item.get_parent(@binder_item_name, this, {\r
22       success: (@binder) =>\r
23         @binder_icon = @binder.icon_view(true)\r
24         @listenTo(@binder_icon, 'click', @binder_click)\r
25         @binder.get_parent('author', this, {\r
26           success: (@binder_author) =>\r
27             @binder_author_icon_with_caption = @binder_author.icon_with_caption_view(true, 'name', 12)\r
28             @listenTo(@binder_author_icon_with_caption, 'click', @binder_author_click)\r
29             @binder_view.$el.append(@binder_icon.render().el)\r
30             @binder_view.$el.append(@binder_author_icon_with_caption.render().el)\r
31             @trigger('load_binder')\r
32         })\r
33     })\r
34   \r
35   load_destination: () ->\r
36     @item.get_parent(@destination_item_name, this, {\r
37       success: (@destination) =>\r
38         @destination_icon = @destination.icon_view(true)\r
39         @listenTo(@destination_icon, 'click', @destination_click)\r
40         @destination.get_parent('author', this, {\r
41           success: (@destination_author) =>\r
42             @destination_author_icon_with_caption = @destination_author.icon_with_caption_view(true, 'name', 12)\r
43             @listenTo(@destination_author_icon_with_caption, 'click', @destination_author_click)\r
44             @destination_view.$el.append(@destination_icon.render().el)\r
45             @destination_view.$el.append(@destination_author_icon_with_caption.render().el)\r
46             @trigger('load_destination')\r
47         })\r
48     })\r
49   \r
50   render: () ->\r
51     this.$el.html('')\r
52     this.$el.append(@binder_view.render().el)\r
53     this.$el.append(@destination_view.render().el)\r
54     this\r
55   \r
56   binder_click: () ->\r
57     @trigger('http_get', @binder_icon.url())\r
58   \r
59   destination_click: () ->\r
60     @trigger('http_get', @destination_icon.url())\r
61   \r
62   binder_author_click: () ->\r
63     @trigger('http_get', @binder_author_icon_with_caption.url())\r
64   \r
65   destination_author_click: () ->\r
66     @trigger('http_get', @destination_author_icon_with_caption.url())\r
67   \r