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
15 @icon = new Pettanr.Image.Icon({item: @item, half: true})
\r
16 @icon_button = new Tag.A({
\r
17 attr: {href: '/' + @icon_url},
\r
19 content: @icon.render().el
\r
21 @caption = new Tag.A({
\r
22 attr: {href: '/' + @caption_url},
\r
23 class_name: 'caption',
\r
24 content: _.escape(@title)
\r
26 @prof = new Pettanr.Image.SymbolImg({attr: {src: '/images/prof.gif'}, half: true})
\r
27 @prof_button = new Tag.A({
\r
28 attr: {href: '/' + @prof_url},
\r
30 content: @prof.render().el
\r
32 @listenTo(@icon, 'click', @click_icon)
\r
33 @listenTo(@caption, 'click', @click_caption)
\r
34 @listenTo(@prof_button, 'click', @click_prof)
\r
38 this.$el.append(@pick.render().el) if @pick
\r
39 this.$el.append(@icon_button.render().el)
\r
40 this.$el.append(@caption.render().el)
\r
41 this.$el.append(@prof_button.render().el)
\r
45 @trigger('click:pick')
\r
48 @trigger('click:icon')
\r
50 click_caption: () ->
\r
51 @trigger('click:caption')
\r
54 @trigger('click:prof')
\r
56 add_pick: (target_model) ->
\r
57 @pick = new Pettanr.Views.Common.PickIcon({
\r
58 name: target_model.pick_type(@item.item_name()), half: true
\r
60 @listenTo(@pick, 'click', @click_pick)
\r
63 class Pettanr.Views.Show.HeaderAuthor extends Backbone.View
\r
66 initialize: (options) ->
\r
67 @item = options.item
\r
68 retriever = @item.author()
\r
69 @listenTo(retriever, 'retrieve', @retrieve_author)
\r
70 retriever.retrieve()
\r
72 retrieve_author: (@author) ->
\r
73 name = @author.escape('name')
\r
74 author_url = @author.show_url()
\r
75 @linked_author = new Tag.A({
\r
76 attr: {href: '/' + author_url},
\r
79 @listenTo(@linked_author, 'click', @click)
\r
84 this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id'))
\r
85 this.$el.append(@linked_author.render().el) if @linked_author
\r
89 @trigger('click:author')
\r
91 class Pettanr.Views.Show.LinkedEditButton extends Tag.A
\r
93 initialize: (options) ->
\r
96 attr: {href: '/' + item.edit_url()},
\r
97 content: I18n.t('link.edit')
\r
103 class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A
\r
105 initialize: (options) ->
\r
106 item = options.item
\r
108 attr: {href: '/' + item.destroy_url()},
\r
109 content: I18n.t('link.destroy')
\r
115 class Pettanr.Views.Show.OwnerFooter extends Backbone.View
\r
117 className: 'show-owner-footer'
\r
119 initialize: (options) ->
\r
121 @item = options.item
\r
122 @operators = options.operators
\r
123 @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})
\r
124 @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})
\r
125 @listenTo(@edit, 'click', @click_edit)
\r
126 @listenTo(@destroy, 'click', @click_destroy)
\r
130 this.$el.append(@edit.render().el)
\r
131 this.$el.append(@destroy.render().el)
\r
135 @trigger('click:edit')
\r
137 click_destroy: () ->
\r
138 @trigger('click:destroy')
\r
140 class Pettanr.Views.Show.Owner extends Backbone.View
\r
143 initialize: (options) ->
\r
145 @item = options.item
\r
146 @operators = options.operators
\r
147 @header = new Tag.H3({
\r
148 class_name: 'owner-header',
\r
149 content: I18n.t('editor')
\r
151 @footer = new Pettanr.Views.Show.OwnerFooter({item: @item, operators: @operators})
\r
152 @listenTo(@footer, 'click:edit', @click_edit)
\r
153 @listenTo(@footer, 'click:destroy', @click_destroy)
\r
157 this.$el.append(@header.render().el)
\r
158 this.$el.append(@footer.render().el)
\r
162 @trigger('click:footer:edit')
\r
163 @trigger('click:edit')
\r
165 click_destroy: () ->
\r
166 @trigger('click:footer:destroy')
\r
167 @trigger('click:destroy')
\r