OSDN Git Service

9b704e2f5a3617c24573cb382040be4b35274ae4
[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     this.$el.html('')\r
31     @item.get_parent(@binder_model.item_name(), this, {\r
32       success: (@binder) =>\r
33         @face_button = @binder.mini_face_button({\r
34           context: @context,\r
35           click: () =>\r
36             @trigger('http_get', @binder.show_url())\r
37         })\r
38         this.$el.append(@face_button.render().el)\r
39         @binder.get_parent('author', this, {\r
40           success: (@author) =>\r
41             @author_faced_label_button = @author.mini_faced_label_button({\r
42                 shorten: true\r
43               }, {\r
44               context: @context,\r
45               click: () =>\r
46                 @trigger('http_get', @author.show_url())\r
47             })\r
48             this.$el.append(@author_faced_label_button.render().el)\r
49           fail: (response, opt) =>\r
50             author_faced_label_error = new Pettanr.View.MiniFacedLabelButton.Error({\r
51             })\r
52             this.$el.append(author_faced_label_error.render().el)\r
53         })\r
54       fail: (response, opt) =>\r
55         this.$el.append(I18n.t('yasapp.unresolved'))\r
56     })\r
57     this\r
58   \r
59 class Pettanr.View.Summary.Leaf.Destination extends Pettanr.View\r
60   tagName: 'span'\r
61   \r
62   constructor: (@item, @context, options) ->\r
63     @destination_model = @item.my_class().destination_model()\r
64     super(options)\r
65   \r
66   initialize: (options) ->\r
67     super(options)\r
68   \r
69   render: () ->\r
70     super()\r
71     this.$el.html('')\r
72     @item.get_parent(@destination_model.item_name(), this, {\r
73       success: (@destination) =>\r
74         @face_button = @destination.mini_face_button({\r
75           context: @context,\r
76           click: () =>\r
77             @trigger('http_get', @binder.show_url())\r
78         })\r
79         this.$el.append(@face_button.render().el)\r
80         @destination.get_parent('author', this, {\r
81           success: (@author) =>\r
82             @author_faced_label_button = @author.mini_faced_label_button({\r
83                 shorten: true\r
84               }, {\r
85               context: @context,\r
86               click: () =>\r
87                 @trigger('http_get', @author.show_url())\r
88             })\r
89             this.$el.append(@author_faced_label_button.render().el)\r
90           fail: (response, opt) =>\r
91             author_faced_label_error = new Pettanr.View.MiniFacedLabelButton.Error({\r
92             })\r
93             this.$el.append(author_faced_label_error.render().el)\r
94         })\r
95       fail: (response, opt) =>\r
96         this.$el.append(I18n.t('yasapp.unresolved'))\r
97     })\r
98     this\r
99   \r