OSDN Git Service

5ff3fbb0b92621d9d69786b7b8449717b27e05f5
[pettanr/pettanr.git] / app / assets / javascripts / views / ground_colors / show.js.coffee
1 class Pettanr.Views.GroundColor.ShowModule\r
2 class Pettanr.Views.GroundColor.ShowModule.Header extends Pettanr.Views.Show.Header\r
3   \r
4   initialize: (options) ->\r
5     super(options)\r
6   \r
7 class Pettanr.Views.GroundColor.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.GroundColor.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       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
29       @body = new Pettanr.Views.Panel.Body({\r
30         panel: @panel,\r
31         operators: @operators,\r
32         spot: @item\r
33       })\r
34       @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
35         pictures: @panel.licensed_pictures()\r
36       })\r
37       @listenTo(@header, 'click:icon', @click_show)\r
38       @listenTo(@header, 'click:caption', @click_show)\r
39       @listenTo(@header, 'click:prof', @click_prof)\r
40       @listenTo(@author, 'click:author', @click_author)\r
41       @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
42       @trigger('ready')\r
43   \r
44   render: () ->\r
45     this.$el.html('')\r
46     this\r
47   \r
48   ready: () ->\r
49     this.$el.html('')\r
50     this.$el.append(@header.render().el)\r
51     this.$el.append(@author.render().el)\r
52     this.$el.append(@body.render().el)\r
53     this.$el.append(@credits.render().el)\r
54     rb = new Tag.RowBreak()\r
55     this.$el.append(rb.render().el)\r
56   \r
57   click_show: () ->\r
58     @trigger('http_get', @item.show_url())\r
59   \r
60   click_author: () ->\r
61     @trigger('http_get', @panel.author().show_url())\r
62   \r
63   click_prof: () ->\r
64     @trigger('http_get', @item.prof_url())\r
65   \r
66   click_credit_icon: (item) ->\r
67     @trigger('http_get', item.show_url())\r
68   \r