1 class Pettanr.Views.Sheet.PlayModule
\r
2 class Pettanr.Views.Sheet.PlayModule.Header extends Pettanr.Views.Show.Header
\r
4 initialize: (options) ->
\r
7 class Pettanr.Views.Sheet.PlayModule.Owner extends Pettanr.Views.Show.Owner
\r
9 initialize: (options) ->
\r
12 class Pettanr.Views.Sheet.PlayModule.Footer extends Pettanr.View
\r
14 className: 'no-border'
\r
16 initialize: (options) ->
\r
17 @panel = options.panel
\r
18 @sheet_panel = options.sheet_panel
\r
23 (new Pettanr.Views.Panel.Icon({item: @panel, half: true})).render().el
\r
26 (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el
\r
28 this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')))
\r
31 (new Pettanr.Views.Panel.Icon({item: @sheet_panel, half: true})).render().el
\r
34 (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el
\r
36 this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@sheet_panel.get('updated_at')))
\r
42 class Pettanr.Views.Sheet.PlayModule.Credits extends Pettanr.View
\r
44 className: 'credits'
\r
46 initialize: (options) ->
\r
47 @parent = options.parent
\r
48 @licensed_pictures = {}
\r
54 push: (append_pictures) ->
\r
55 _.each append_pictures, (retriever, pid) =>
\r
56 return if @licensed_pictures[pid]
\r
57 @listenTo(retriever, 'retrieve', @retrieve_picture)
\r
58 retriever.retrieve()
\r
60 retrieve_picture: (picture) ->
\r
61 @licensed_pictures[pid] = picture
\r
62 credit = picture.credit_view()
\r
63 this.$el.append(credit.render().el)
\r
65 class Pettanr.Views.Sheet.PlayModule.Panel extends Pettanr.View
\r
68 initialize: (options) ->
\r
69 @sheet_panel = options.sheet_panel
\r
73 retriever = @sheet_panel.panel()
\r
74 @listenTo(retriever, 'retrieve', @retrieve_panel)
\r
75 retriever.retrieve()
\r
78 retrieve_panel: (@panel) ->
\r
83 body = new Pettanr.Views.Panel.Body({
\r
87 this.$el.append(body.render().el)
\r
88 footer = new Pettanr.Views.Panel.Footer({
\r
89 sheet_panel: sheet_panel,
\r
92 this.$el.append(footer.render().el)
\r
93 this.credits.push(@panel.licensed_pictures())
\r
96 class Pettanr.Views.Sheet.PlayModule.Panels extends Pettanr.View
\r
99 initialize: (options) ->
\r
100 @parent = options.parent
\r
101 @items = options.items
\r
102 @credits = options.credits
\r
106 _.each @items, (sheet_panel) =>
\r
107 return if not sheet_panel.has_panel()
\r
108 panel_view = new Pettanr.Views.Sheet.PlayModule.Panel({
\r
109 sheet_panel: sheet_panel,
\r
111 this.$el.append(panel_view.render().el)
\r
114 class Pettanr.Views.Sheet.PlayModule.Body extends Pettanr.View
\r
117 initialize: (options) ->
\r
118 @parent = options.parent
\r
119 @list = options.list
\r
120 @items = @list.items()
\r
121 if @items.length < 1
\r
126 render_empty: () ->
\r
128 this.$el.append((new Tag.H2({content: I18n.t('sheets.play.empty')})).render().el)
\r
134 credits = new Pettanr.Views.Sheet.PlayModule.Credits({parent: this})
\r
135 panels = new Pettanr.Views.Sheet.PlayModule.Panels({
\r
140 this.$el.append(panels.render().el)
\r
141 this.$el.append(credits.render().el)
\r
146 class Pettanr.Views.Sheet.Play extends Pettanr.View
\r
150 initialize: (options) ->
\r
151 @item = options.item
\r
152 @list = options.list
\r
153 icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})
\r
154 caption_url = Pettanr.url(@item.table_name(), 'play', {id: @item.get('id')})
\r
155 prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'})
\r
156 @header = new Pettanr.Views.Sheet.PlayModule.Header({
\r
158 caption: @item.get('caption'),
\r
159 icon_url: icon_url,
\r
160 caption_url: caption_url,
\r
163 @author = new Pettanr.Views.Show.HeaderAuthor({item: @item})
\r
164 @body = new Pettanr.Views.Sheet.PlayModule.Body({
\r
168 @owner = new Pettanr.Views.Sheet.PlayModule.Owner({item: @item})
\r
172 this.$el.append(@header.render().el)
\r
173 this.$el.append(@author.render().el)
\r
174 this.$el.append(@body.render().el)
\r
175 this.$el.append(@owner.render().el) if @item.is_own()
\r