class Pettanr.Views.Show class Pettanr.Views.Show.Header extends Backbone.View tagName: 'h1' className: 'show-header' initialize: (options) -> @item = options.item @operators = options.operators @title = options.caption @icon_url = options.icon_url @caption_url = options.caption_url @prof_url = options.prof_url @icon = new Pettanr.Image.Icon({item: @item, half: true}) @icon_button = new Tag.A({ attr: {href: '/' + @icon_url}, class_name: 'icon', content: @icon.render().el }) @caption = new Tag.A({ attr: {href: '/' + @caption_url}, class_name: 'caption', content: _.escape(@title) }) @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true}) @prof_button = new Tag.A({ attr: {href: '/' + @prof_url}, class_name: 'prof', content: @prof.render().el }) @listenTo(@icon, 'click', @click_icon) @listenTo(@caption, 'click', @click_caption) @listenTo(@prof_button, 'click', @click_prof) render: () -> this.$el.html('') this.$el.append(@icon_button.render().el) this.$el.append(@caption.render().el) this.$el.append(@prof_button.render().el) this click_icon: () -> @trigger('click:icon') click_caption: () -> @trigger('click:caption') click_prof: () -> @trigger('click:prof') class Pettanr.Views.Show.HeaderAuthor extends Backbone.View tagName: 'div' initialize: (options) -> @item = options.item @author = @item.author() @author.fetch({cache: true}).done => name = @author.escape('name') author_url = @author.show_url() @linked_author = new Tag.A({ attr: {href: '/' + author_url}, content: name }) @listenTo(@linked_author, 'click', @click) @render() render: () -> this.$el.html('') this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id')) this.$el.append(@linked_author.render().el) if @linked_author this click: () -> @trigger('click:author') class Pettanr.Views.Show.LinkedEditButton extends Tag.A initialize: (options) -> item = options.item super({ attr: {href: '/' + item.edit_url()}, content: I18n.t('link.edit') }) url: () -> @url class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A initialize: (options) -> item = options.item super({ attr: {href: '/' + item.destroy_url()}, content: I18n.t('link.destroy') }) url: () -> @destroy_url class Pettanr.Views.Show.OwnerFooter extends Backbone.View tagName: 'div' className: 'show-owner-footer' initialize: (options) -> super(options) @item = options.item @operators = options.operators @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item}) @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item}) @listenTo(@edit, 'click', @click_edit) @listenTo(@destroy, 'click', @click_destroy) render: () -> this.$el.html('') this.$el.append(@edit.render().el) this.$el.append(@destroy.render().el) this click_edit: () -> @trigger('click:edit') click_destroy: () -> @trigger('click:destroy') class Pettanr.Views.Show.Owner extends Backbone.View tagName: 'div' initialize: (options) -> super(options) @item = options.item @operators = options.operators @header = new Tag.H3({ class_name: 'owner-header', content: I18n.t('editor') }) @footer = new Pettanr.Views.Show.OwnerFooter({item: @item, operators: @operators}) @listenTo(@footer, 'click:edit', @click_edit) @listenTo(@footer, 'click:destroy', @click_destroy) render: () -> this.$el.html('') this.$el.append(@header.render().el) this.$el.append(@footer.render().el) this click_edit: () -> @trigger('click:footer:edit') @trigger('click:edit') click_destroy: () -> @trigger('click:footer:destroy') @trigger('click:destroy')