class Pettanr.Views.Scroll.PlayModule class Pettanr.Views.Scroll.PlayModule.Header extends Pettanr.Views.Show.Header initialize: (options) -> super(options) class Pettanr.Views.Scroll.PlayModule.Owner extends Pettanr.Views.Show.Owner initialize: (options) -> super(options) class Pettanr.Views.Scroll.PlayModule.Footer extends Backbone.View tagName: 'table' className: 'no-border' initialize: (options) -> @panel = options.panel @scroll_panel = options.scroll_panel @operators = options.operators render: () -> this.$el.html('') this.$el.append( (new Pettanr.Views.Panel.Icon({item: @panel, half: true})).render().el ) this.$el.append( (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el ) this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at'))) # this.$el.append( (new Pettanr.Views.Panel.Icon({item: @scroll_panel, half: true})).render().el ) this.$el.append( (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el ) this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@scroll_panel.get('updated_at'))) # if @panel.is_own(@operators) this.$el.append('') this class Pettanr.Views.Scroll.PlayModule.Credits extends Backbone.View tagName: 'div' className: 'credits' initialize: (options) -> @parent = options.parent @licensed_pictures = {} render: () -> this.$el.html('') this push: (append_pictures) -> _.each append_pictures, (picture, pid) => return if @licensed_pictures[pid] @licensed_pictures[pid] = picture picture.fetch({cache: true}).done => credit = picture.credit_view() this.$el.append(credit.render().el) class Pettanr.Views.Scroll.PlayModule.Panels extends Backbone.View tagName: 'div' initialize: (options) -> @parent = options.parent @items = options.items @credits = options.credits @operators = options.operators render: () -> this.$el.html('') _.each @items, (scroll_panel) => return if not scroll_panel.has_panel() panel = scroll_panel.panel() panel.fetch({cache: true}).done => panel.attributes = panel.replaced_attributes() body = new Pettanr.Views.Panel.Body({ panel: panel, operators: @operators, spot: null }) this.$el.append(body.render().el) footer = new Pettanr.Views.Panel.Footer({ scroll_panel: scroll_panel, panel: panel, operators: @operators }) this.$el.append(footer.render().el) this.credits.push(panel.licensed_pictures()) this class Pettanr.Views.Scroll.PlayModule.Body extends Backbone.View tagName: 'div' initialize: (options) -> @parent = options.parent @list = options.list @operators = options.operators @items = @list.items() if @items.length < 1 @render_empty() else @render() render_empty: () -> this.$el.html('') this.$el.append((new Tag.H2({content: I18n.t('scrolls.play.empty')})).render().el) this render: () -> this.$el.html('') # paginate(@pager) credits = new Pettanr.Views.Scroll.PlayModule.Credits({parent: this}) panels = new Pettanr.Views.Scroll.PlayModule.Panels({ parent: this, items: @items, credits: credits, operators: @operators }) this.$el.append(panels.render().el) this.$el.append(credits.render().el) rb = new Tag.RowBreak() this.$el.append(rb.render().el) # paginate(@pager) this class Pettanr.Views.Scroll.Play extends Backbone.View tagName: 'div' className: 'show' initialize: (options) -> @item = options.item @list = options.list @operators = options.operators icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')}) caption_url = Pettanr.url(@item.table_name(), 'play', {id: @item.get('id')}) prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'}) @header = new Pettanr.Views.Scroll.PlayModule.Header({ item: @item, operators: @operators, caption: @item.get('title'), icon_url: icon_url, caption_url: caption_url, prof_url: prof_url }) @author = new Pettanr.Views.Show.HeaderAuthor({item: @item}) @body = new Pettanr.Views.Scroll.PlayModule.Body({ parent: this, list: @list, operators: @operators }) @owner = new Pettanr.Views.Scroll.PlayModule.Owner({item: @item, operators: @operators}) render: () -> this.$el.html('') this.$el.append(@header.render().el) this.$el.append(@author.render().el) this.$el.append(@body.render().el) this.$el.append(@owner.render().el) if @item.is_own(@operators) this