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
18 content: @icon.render().el
\r
20 @caption = new Tag.A({
\r
21 attr: {href: '/' + @caption_url},
\r
22 class_name: 'caption',
\r
23 content: _.escape(@title)
\r
25 @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true})
\r
26 @prof_button = new Tag.A({
\r
27 attr: {href: '/' + @prof_url},
\r
29 content: @prof.render().el
\r
31 @listenTo(@icon, 'click', @click_icon)
\r
32 @listenTo(@caption, 'click', @click_caption)
\r
33 @listenTo(@prof_button, 'click', @click_prof)
\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
43 @trigger('click:icon')
\r
45 click_caption: () ->
\r
46 @trigger('click:caption')
\r
49 @trigger('click:prof')
\r
51 class Pettanr.Views.Show.HeaderAuthor extends Backbone.View
\r
54 initialize: (options) ->
\r
55 @item = options.item
\r
56 @author = @item.author()
\r
57 @author.fetch({cache: true}).done =>
\r
58 name = @author.escape('name')
\r
59 author_url = @author.show_url()
\r
60 @linked_author = new Tag.A({
\r
61 attr: {href: '/' + author_url},
\r
64 @listenTo(@linked_author, 'click', @click)
\r
69 this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id'))
\r
70 this.$el.append(@linked_author.render().el) if @linked_author
\r
74 @trigger('click:author')
\r
76 class Pettanr.Views.Show.LinkedEditButton extends Tag.A
\r
78 initialize: (options) ->
\r
81 attr: {href: '/' + item.edit_url()},
\r
82 content: I18n.t('link.edit')
\r
88 class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A
\r
90 initialize: (options) ->
\r
93 attr: {href: '/' + item.destroy_url()},
\r
94 content: I18n.t('link.destroy')
\r
100 class Pettanr.Views.Show.OwnerFooter extends Backbone.View
\r
102 className: 'show-owner-footer'
\r
104 initialize: (options) ->
\r
106 @item = options.item
\r
107 @operators = options.operators
\r
108 @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})
\r
109 @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})
\r
110 @listenTo(@edit, 'click', @click_edit)
\r
111 @listenTo(@destroy, 'click', @click_destroy)
\r
115 this.$el.append(@edit.render().el)
\r
116 this.$el.append(@destroy.render().el)
\r
120 @trigger('click:edit')
\r
122 click_destroy: () ->
\r
123 @trigger('click:destroy')
\r
125 class Pettanr.Views.Show.Owner extends Backbone.View
\r
128 initialize: (options) ->
\r
130 @item = options.item
\r
131 @operators = options.operators
\r
132 @header = new Tag.H3({
\r
133 class_name: 'owner-header',
\r
134 content: I18n.t('editor')
\r
136 @footer = new Pettanr.Views.Show.OwnerFooter({item: @item, operators: @operators})
\r
137 @listenTo(@footer, 'click:edit', @click_edit)
\r
138 @listenTo(@footer, 'click:destroy', @click_destroy)
\r
142 this.$el.append(@header.render().el)
\r
143 this.$el.append(@footer.render().el)
\r
147 @trigger('click:footer:edit')
\r
148 @trigger('click:edit')
\r
150 click_destroy: () ->
\r
151 @trigger('click:footer:destroy')
\r
152 @trigger('click:destroy')
\r