1 class Pettanr.Views.Common
\r
2 class Pettanr.Views.Common.Icon extends Backbone.View
\r
5 initialize: (options) ->
\r
8 @icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})
\r
9 @icon = new Pettanr.Image.Icon({item: @item, half: @half})
\r
10 @icon_button = new Tag.A({
\r
11 attr: {href: '/' + @icon_url},
\r
12 handler_name: @icon_url,
\r
14 content: @icon.render().el
\r
18 this.$el.html(@icon_button.render().el)
\r
21 class Pettanr.Views.Common.Caption extends Backbone.View
\r
24 initialize: (options) ->
\r
25 @item = options.item
\r
26 @length = options.length
\r
27 @name = Pettanr.truncate(@item.get('name'), @length)
\r
28 @url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})
\r
29 @linked_name = new Tag.A({
\r
30 attr: {href: '/' + @url},
\r
36 this.$el.html(@linked_name.render().el)
\r
39 class Pettanr.Views.Common.IconWithCaption extends Backbone.View
\r
42 initialize: (options) ->
\r
43 @item = options.item
\r
44 @column = options.column
\r
45 @icon = new Pettanr.Views.Common.Icon({item: @item, half: @half})
\r
46 @caption = new Pettanr.Views.Common.Caption({item: @item, column: @column, length: @length})
\r
50 this.$el.append(@icon.render().el)
\r
51 this.$el.append(@caption.render().el)
\r