1 class Pettanr.Views.Show
\r
2 class Pettanr.Views.Show.Header extends Backbone.View
\r
4 className: 'show-header'
\r
6 initialize: (options) ->
\r
8 @operators = options.operators
\r
9 @title = options.caption
\r
10 @icon_url = options.icon_url
\r
11 @caption_url = options.caption_url
\r
12 @prof_url = options.prof_url
\r
14 @icon = new Pettanr.Image.Icon({item: @item, half: true})
\r
15 @icon_button = new Tag.A({
\r
16 attr: {href: '/' + @icon_url},
\r
17 handler_name: @icon_url,
\r
19 content: @icon.render().el
\r
21 @caption = new Tag.A({
\r
22 attr: {href: '/' + @caption_url},
\r
23 handler_name: @caption_url,
\r
24 class_name: 'caption',
\r
27 @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true})
\r
28 @prof_button = new Tag.A({
\r
29 attr: {href: '/' + @prof_url},
\r
30 handler_name: @prof_url,
\r
32 content: @prof.render().el
\r
37 this.$el.append(@icon_button.render().el)
\r
38 this.$el.append(@caption.render().el)
\r
39 this.$el.append(@prof_button.render().el)
\r
42 class Pettanr.Views.Show.HeaderAuthor extends Backbone.View
\r
45 initialize: (options) ->
\r
46 @item = options.item
\r
48 @author = @item.author()
\r
49 @author.fetch({cache: true}).done ->
\r
50 name = _this.author.get('name')
\r
51 author_url = Pettanr.url(_this.author.table_name(), 'show', {id: _this.author.get('id')})
\r
52 _this.linked_author = new Tag.A({
\r
53 attr: {href: '/' + author_url},
\r
54 handler_name: author_url,
\r
61 this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id'))
\r
62 this.$el.append(@linked_author.render().el) if @linked_author
\r
65 class Pettanr.Views.Show.LinkedEditButton extends Tag.A
\r
67 initialize: (options) ->
\r
69 edit_url = Pettanr.url(item.table_name(), 'edit', {id: item.get('id')})
\r
71 attr: {href: '/' + edit_url},
\r
72 handler_name: edit_url,
\r
73 content: I18n.t('link.edit')
\r
76 class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A
\r
78 initialize: (options) ->
\r
80 edit_url = Pettanr.url(item.table_name(), 'destroy', {id: item.get('id')})
\r
82 attr: {href: '/' + edit_url},
\r
83 handler_name: edit_url,
\r
84 content: I18n.t('link.destroy')
\r
87 class Pettanr.Views.Show.OwnerFooter extends Backbone.View
\r
89 className: 'show-owner-footer'
\r
91 initialize: (options) ->
\r
93 @item = options.item
\r
94 @operators = options.operators
\r
95 @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})
\r
96 @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})
\r
100 this.$el.append(@edit.render().el)
\r
101 this.$el.append(@destroy.render().el)
\r
104 class Pettanr.Views.Show.Owner extends Backbone.View
\r
107 initialize: (options) ->
\r
109 @item = options.item
\r
110 @operators = options.operators
\r
111 @header = new Tag.H3({
\r
112 class_name: 'owner-header',
\r
113 content: I18n.t('editor')
\r
115 @footer = new Pettanr.Views.Show.OwnerFooter({item: @item, operators: @operators})
\r
119 this.$el.append(@header.render().el)
\r
120 this.$el.append(@footer.render().el)
\r