class Pettanr.Views.Common class Pettanr.Views.Common.Icon extends Backbone.View tagName: 'span' initialize: (options) -> @item = options.item @half = options.half @icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')}) @icon = new Pettanr.Image.Icon({item: @item, half: @half}) @icon_button = new Tag.A({ attr: {href: '/' + @icon_url}, handler_name: @icon_url, class_name: 'icon', content: @icon.render().el }) render: () -> this.$el.html(@icon_button.render().el) this class Pettanr.Views.Common.Caption extends Backbone.View tagName: 'span' initialize: (options) -> @item = options.item @length = options.length @name = Pettanr.truncate(@item.get('name'), @length) @url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')}) @linked_name = new Tag.A({ attr: {href: '/' + @url}, handler_name: @url, content: @name }) render: () -> this.$el.html(@linked_name.render().el) this class Pettanr.Views.Common.IconWithCaption extends Backbone.View tagName: 'span' initialize: (options) -> @item = options.item @column = options.column @icon = new Pettanr.Views.Common.Icon({item: @item, half: @half}) @caption = new Pettanr.Views.Common.Caption({item: @item, column: @column, length: @length}) render: () -> this.$el.html('') this.$el.append(@icon.render().el) this.$el.append(@caption.render().el) this