OSDN Git Service

fix:
[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 Backbone.View\r
8   tagName: 'div'\r
9   className: 'show'\r
10   \r
11   initialize: (options) ->\r
12     @item = options.item\r
13     @operators = options.operators\r
14     icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
15     caption_url = icon_url\r
16     prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'})\r
17     @header = new Pettanr.Views.SpeechBalloon.ShowModule.Header({\r
18       item: @item, \r
19       operators: @operators,\r
20       caption: @item.get('caption'), \r
21       icon_url: icon_url,\r
22       caption_url: caption_url,\r
23       prof_url: prof_url\r
24     })\r
25     @listenTo(this, 'ready', @ready)\r
26     @panel = @item.panel().with_elements()\r
27     @panel.fetch({cache: false}).done =>  # with elements\r
28       @panel.attributes = @panel.replaced_attributes()\r
29       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
30       @body = new Pettanr.Views.Panel.Body({\r
31         panel: @panel,\r
32         operators: @operators,\r
33         spot: @item\r
34       })\r
35       @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
36         pictures: @panel.licensed_pictures()\r
37       })\r
38       @listenTo(@header, 'click:pick', @click_pick)\r
39       @listenTo(@header, 'click:icon', @click_show)\r
40       @listenTo(@header, 'click:caption', @click_show)\r
41       @listenTo(@header, 'click:prof', @click_prof)\r
42       @listenTo(@author, 'click:author', @click_author)\r
43       @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
44       @trigger('ready')\r
45   \r
46   render: () ->\r
47     this.$el.html('')\r
48     this\r
49   \r
50   ready: () ->\r
51     this.$el.html('')\r
52     this.$el.append(@header.render().el)\r
53     this.$el.append(@author.render().el)\r
54     this.$el.append(@body.render().el)\r
55     this.$el.append(@credits.render().el)\r
56     rb = new Tag.RowBreak()\r
57     this.$el.append(rb.render().el)\r
58   \r
59   click_show: () ->\r
60     @trigger('http_get', @item.show_url())\r
61   \r
62   click_author: () ->\r
63     @trigger('http_get', @panel.author().show_url())\r
64   \r
65   click_prof: () ->\r
66     @trigger('http_get', @item.prof_url())\r
67   \r
68   click_credit_icon: (item) ->\r
69     @trigger('http_get', item.show_url())\r
70   \r
71   click_pick: () ->\r
72     @trigger('pick', @item)\r
73   \r
74   is_pickable: () ->\r
75     true\r
76   \r
77   add_pick: (target_model) ->\r
78     @header.add_pick(target_model)\r
79   \r