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}, handler_name: @icon_url, class_name: 'icon', content: @icon.render().el }) @caption = new Tag.A({ attr: {href: '/' + @caption_url}, handler_name: @caption_url, class_name: 'caption', content: @title }) @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true}) @prof_button = new Tag.A({ attr: {href: '/' + @prof_url}, handler_name: @prof_url, class_name: 'prof', content: @prof.render().el }) 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 class Pettanr.Views.Show.HeaderAuthor extends Backbone.View tagName: 'div' initialize: (options) -> @item = options.item _this = this @author = @item.author() @author.fetch().done -> name = _this.author.get('name') author_url = Pettanr.url(_this.author.table_name(), 'show', {id: _this.author.get('id')}) _this.linked_author = new Tag.A({ attr: {href: '/' + author_url}, handler_name: author_url, content: name }) _this.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 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_url = Pettanr.url(@item.table_name(), 'edit', {id: @item.get('id')}) @edit = new Tag.A({ attr: {href: '/' + @edit_url}, handler_name: @edit_url, content: I18n.t('link.edit') }) @destroy_url = Pettanr.url(@item.table_name(), 'destroy', {id: @item.get('id')}) @destroy = new Tag.A({ attr: {href: '/' + @destroy_url}, handler_name: @destroy_url, content: I18n.t('link.destroy') }) render: () -> this.$el.html('') this.$el.append(@edit.render().el) this.$el.append(@destroy.render().el) this 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}) render: () -> this.$el.html('') this.$el.append(@header.render().el) this.$el.append(@footer.render().el) this