OSDN Git Service

fix:
[pettanr/pettanr.git] / app / assets / javascripts / views / speeches / show.js.coffee
1 class Pettanr.Views.Speech.ShowModule\r
2 class Pettanr.Views.Speech.ShowModule.Header extends Pettanr.Views.Show.Header\r
3   \r
4   initialize: (options) ->\r
5     super(options)\r
6   \r
7 class Pettanr.Views.Speech.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.Speech.ShowModule.Header({\r
18       item: @item, \r
19       operators: @operators,\r
20       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     @speech_balloon = @item.speech_balloon()\r
27     @speech_balloon.fetch({cache: true}).done =>\r
28       @panel = @speech_balloon.panel().with_elements()\r
29       @panel.fetch({cache: false}).done =>  # with elements\r
30         @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
31         @body = new Pettanr.Views.Panel.Body({\r
32           panel: @panel,\r
33           operators: @operators,\r
34           spot: @item\r
35         })\r
36         @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
37           pictures: @panel.licensed_pictures()\r
38         })\r
39         @listenTo(@header, 'click:pick', @click_pick)\r
40         @listenTo(@header, 'click:icon', @click_show)\r
41         @listenTo(@header, 'click:caption', @click_show)\r
42         @listenTo(@header, 'click:prof', @click_prof)\r
43         @listenTo(@author, 'click:author', @click_author)\r
44         @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
45         @trigger('ready')\r
46   \r
47   render: () ->\r
48     this.$el.html('')\r
49     this\r
50   \r
51   ready: () ->\r
52     this.$el.html('')\r
53     this.$el.append(@header.render().el)\r
54     this.$el.append(@author.render().el)\r
55     this.$el.append(@body.render().el)\r
56     this.$el.append(@credits.render().el)\r
57     rb = new Tag.RowBreak()\r
58     this.$el.append(rb.render().el)\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