OSDN Git Service

f578b07a58d66431ae1dd35519c5d97aa669055f
[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_faced_label_button = @author.mini_faced_label_button({\r
40                 shorten: true\r
41               }, {\r
42               context: @context,\r
43               click: () =>\r
44                 @trigger('http_get', @author.show_url())\r
45             })\r
46             this.$el.html('')\r
47             this.$el.append(@face_button.render().el)\r
48             this.$el.append(@author_faced_label_button.render().el)\r
49         })\r
50     })\r
51     this\r
52   \r
53 class Pettanr.View.Summary.Leaf.Destination extends Pettanr.View\r
54   tagName: 'span'\r
55   \r
56   constructor: (@item, @context, options) ->\r
57     @destination_model = @item.my_class().destination_model()\r
58     super(options)\r
59   \r
60   initialize: (options) ->\r
61     super(options)\r
62   \r
63   render: () ->\r
64     super()\r
65     @item.get_parent(@destination_model.item_name(), this, {\r
66       success: (@destination) =>\r
67         @face_button = @destination.mini_face_button({\r
68           context: @context,\r
69           click: () =>\r
70             @trigger('http_get', @binder.show_url())\r
71         })\r
72         @destination.get_parent('author', this, {\r
73           success: (@author) =>\r
74             @author_faced_label_button = @author.mini_faced_label_button({\r
75                 shorten: true\r
76               }, {\r
77               context: @context,\r
78               click: () =>\r
79                 @trigger('http_get', @author.show_url())\r
80             })\r
81             this.$el.html('')\r
82             this.$el.append(@face_button.render().el)\r
83             this.$el.append(@author_faced_label_button.render().el)\r
84         })\r
85     })\r
86     this\r
87   \r