OSDN Git Service

c5488ad64bd57cae9325c239e65bda4dffe043a5
[pettanr/pettanr.git] / app / assets / javascripts / view / summary / leaf.js.coffee
1 class Pettanr.View.Summary.Leaf extends Pettanr.View.Summary\r
2   \r
3   initialize: (options) ->\r
4     super(options)\r
5     @binder = new Pettanr.View.Summary.Leaf.Binder(@item, @context)\r
6     @destination = new Pettanr.View.Summary.Leaf.Destination(@item, @context)\r
7   \r
8   render: () ->\r
9     super()\r
10     this.$el.html('')\r
11     this.$el.append(@binder.render().el)\r
12     this.$el.append(@destination.render().el)\r
13     this\r
14   \r
15   http_get: (url) ->\r
16     @trigger('http_get', url)\r
17   \r
18 class Pettanr.View.Summary.Leaf.Binder extends Pettanr.View\r
19   tagName: 'span'\r
20   \r
21   constructor: (@item, @context, options) ->\r
22     @binder_model = @item.my_class().binder_model()\r
23     super(options)\r
24   \r
25   initialize: (options) ->\r
26     super(options)\r
27   \r
28   render: () ->\r
29     super()\r
30     @item.get_parent(@binder_model.item_name(), this, {\r
31       success: (@binder) =>\r
32         @face_button = @binder.mini_face_button({\r
33           context: @context,\r
34           click: () =>\r
35             @trigger('http_get', @binder.show_url())\r
36         })\r
37         @binder.get_parent('author', this, {\r
38           success: (@author) =>\r
39             @author_mini_faced_label = @author.mini_faced_label({\r
40               context: @context,\r
41               click: () =>\r
42                 @trigger('http_get', @author.show_url())\r
43             })\r
44             this.$el.html('')\r
45             this.$el.append(@face_button.render().el)\r
46             this.$el.append(@author_mini_faced_label.render().el)\r
47         })\r
48     })\r
49     this\r
50   \r
51 class Pettanr.View.Summary.Leaf.Destination extends Pettanr.View\r
52   tagName: 'span'\r
53   \r
54   constructor: (@item, @context, options) ->\r
55     @destination_model = @item.my_class().destination_model()\r
56     super(options)\r
57   \r
58   initialize: (options) ->\r
59     super(options)\r
60   \r
61   render: () ->\r
62     super()\r
63     @item.get_parent(@destination_model.item_name(), this, {\r
64       success: (@destination) =>\r
65         @face_button = @destination.mini_face_button({\r
66           context: @context,\r
67           click: () =>\r
68             @trigger('http_get', @binder.show_url())\r
69         })\r
70         @destination.get_parent('author', this, {\r
71           success: (@author) =>\r
72             @author_mini_faced_label = @author.mini_faced_label({\r
73               context: @context,\r
74               click: () =>\r
75                 @trigger('http_get', @author.show_url())\r
76             })\r
77             this.$el.html('')\r
78             this.$el.append(@face_button.render().el)\r
79             this.$el.append(@author_mini_faced_label.render().el)\r
80         })\r
81     })\r
82     this\r
83   \r