OSDN Git Service

fix:replace row break
[pettanr/pettanr.git] / app / assets / javascripts / views / speech_balloons / show.js.coffee
1 class Pettanr.Views.SpeechBalloon.ShowModule\r
2 class Pettanr.Views.SpeechBalloon.ShowModule.Header extends Pettanr.Views.Show.Header\r
3   \r
4   initialize: (options) ->\r
5     super(options)\r
6   \r
7 class Pettanr.Views.SpeechBalloon.Show extends Pettanr.View\r
8   tagName: 'div'\r
9   className: 'show'\r
10   \r
11   initialize: (options) ->\r
12     @item = options.item\r
13     icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
14     caption_url = icon_url\r
15     prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'})\r
16     @header = new Pettanr.Views.SpeechBalloon.ShowModule.Header({\r
17       item: @item, \r
18       caption: @item.get('caption'), \r
19       icon_url: icon_url,\r
20       caption_url: caption_url,\r
21       prof_url: prof_url\r
22     })\r
23     @listenTo(this, 'ready', @ready)\r
24     retriever = @item.panel()\r
25     @listenTo(retriever, 'retrieve', @retrieve_panel)\r
26     retriever.retrieve()\r
27   \r
28   retrieve_panel: (item) ->\r
29     @panel = item.with_elements()\r
30     @panel.fetch().done =>\r
31       @panel.attributes = @panel.replaced_attributes()\r
32       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
33       @body = new Pettanr.Views.Panel.Body({\r
34         panel: @panel,\r
35         spot: @item\r
36       })\r
37       @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
38         pictures: @panel.licensed_pictures()\r
39       })\r
40       @listenTo(@header, 'click:pick', @click_pick)\r
41       @listenTo(@header, 'click:icon', @click_show)\r
42       @listenTo(@header, 'click:caption', @click_show)\r
43       @listenTo(@header, 'click:prof', @click_prof)\r
44       @listenTo(@author, 'click:author', @click_author)\r
45       @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
46       @trigger('ready')\r
47   \r
48   render: () ->\r
49     this.$el.html('')\r
50     this\r
51   \r
52   ready: () ->\r
53     this.$el.html('')\r
54     this.$el.append(@header.render().el)\r
55     this.$el.append(@author.render().el)\r
56     this.$el.append(@body.render().el)\r
57     this.$el.append(@credits.render().el)\r
58     @rb()\r
59   \r
60   click_show: () ->\r
61     @trigger('http_get', @item.show_url())\r
62   \r
63   click_author: () ->\r
64     @trigger('http_get', @panel.author().show_url())\r
65   \r
66   click_prof: () ->\r
67     @trigger('http_get', @item.prof_url())\r
68   \r
69   click_credit_icon: (item) ->\r
70     @trigger('http_get', item.show_url())\r
71   \r
72   click_pick: () ->\r
73     @trigger('pick', @item)\r
74   \r
75   is_pickable: () ->\r
76     true\r
77   \r
78   add_pick: (target_model) ->\r
79     @header.add_pick(target_model)\r
80   \r