OSDN Git Service

fix: view
[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 = new Pettanr.View.Summary.Leaf.Binder(@item, {})\r
7     @destination = new Pettanr.View.Summary.Leaf.Binder(@item, options.destination_item_name, {})\r
8     @load()\r
9   \r
10   load: () ->\r
11     @listenTo(this, 'load_binder', @load_destination)\r
12     @listenTo(this, 'load_destination', @ready)\r
13     @load_binder()\r
14   \r
15   ready: () ->\r
16     @trigger('ready')\r
17   \r
18   load_binder: () ->\r
19   \r
20   load_destination: () ->\r
21     @item.get_parent(@destination_item_name, this, {\r
22       success: (@destination) =>\r
23         @destination_icon = @destination.icon_view(true)\r
24         @listenTo(@destination_icon, 'click', @destination_click)\r
25         @destination.get_parent('author', this, {\r
26           success: (@destination_author) =>\r
27             @destination_author_mini_faced_label = @destination_author.mini_faced_label({\r
28               context: this,\r
29               click: () =>\r
30                 @trigger('http_get', @destination_author.show_url())\r
31             })\r
32             this.$el.append(@destination_author_mini_faced_label.render().el)\r
33             @trigger('load_destination')\r
34         })\r
35     })\r
36   \r
37   render: () ->\r
38     this.$el.html('')\r
39     this.$el.append(@binder_author_mini_faced_label.render().el)\r
40     this.$el.append(@destination_author_mini_faced_label.render().el)\r
41     this\r
42   \r
43   binder_click: () ->\r
44     @trigger('http_get', @binder_icon.url())\r
45   \r
46   destination_click: () ->\r
47     @trigger('http_get', @destination_icon.url())\r
48   \r
49   binder_author_click: () ->\r
50     @trigger('http_get', @binder_author_icon_with_caption.url())\r
51   \r
52   destination_author_click: () ->\r
53     @trigger('http_get', @destination_author_icon_with_caption.url())\r
54   \r
55 class Pettanr.View.Summary.Leaf.Binder extends Tag.Span\r
56   \r
57   constructor: (@item, @binder_item_name, options) ->\r
58     super(options)\r
59     @binder_model = @item.my_class().binder_model()\r
60   \r
61   initialize: (options) ->\r
62     @item.get_parent(@binder_model.item_name(), this, {\r
63       success: (@binder) =>\r
64         @face_button = @binder.mini_face_button(true)\r
65         @binder.get_parent('author', this, {\r
66           success: (@author) =>\r
67             @author_mini_faced_label = @author.mini_faced_label({\r
68               context: this,\r
69               click: () =>\r
70                 @trigger('http_get', @author.show_url())\r
71             })\r
72             this.$el.append(@author_mini_faced_label.render().el)\r
73             @trigger('load_binder')\r
74         })\r
75     })\r
76   \r