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 @author = @item.author()
\r
69 @author.fetch({cache: true}).done =>
\r
70 name = @author.escape('name')
\r
71 author_url = @author.show_url()
\r
72 @linked_author = new Tag.A({
\r
73 attr: {href: '/' + author_url},
\r
76 @listenTo(@linked_author, 'click', @click)
\r
81 this.$el.append(Pettanr.AppHelper.t_a(@item.item_name(), 'author_id'))
\r
82 this.$el.append(@linked_author.render().el) if @linked_author
\r
86 @trigger('click:author')
\r
88 class Pettanr.Views.Show.LinkedEditButton extends Tag.A
\r
90 initialize: (options) ->
\r
93 attr: {href: '/' + item.edit_url()},
\r
94 content: I18n.t('link.edit')
\r
100 class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A
\r
102 initialize: (options) ->
\r
103 item = options.item
\r
105 attr: {href: '/' + item.destroy_url()},
\r
106 content: I18n.t('link.destroy')
\r
112 class Pettanr.Views.Show.OwnerFooter extends Backbone.View
\r
114 className: 'show-owner-footer'
\r
116 initialize: (options) ->
\r
118 @item = options.item
\r
119 @operators = options.operators
\r
120 @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})
\r
121 @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})
\r
122 @listenTo(@edit, 'click', @click_edit)
\r
123 @listenTo(@destroy, 'click', @click_destroy)
\r
127 this.$el.append(@edit.render().el)
\r
128 this.$el.append(@destroy.render().el)
\r
132 @trigger('click:edit')
\r
134 click_destroy: () ->
\r
135 @trigger('click:destroy')
\r
137 class Pettanr.Views.Show.Owner extends Backbone.View
\r
140 initialize: (options) ->
\r
142 @item = options.item
\r
143 @operators = options.operators
\r
144 @header = new Tag.H3({
\r
145 class_name: 'owner-header',
\r
146 content: I18n.t('editor')
\r
148 @footer = new Pettanr.Views.Show.OwnerFooter({item: @item, operators: @operators})
\r
149 @listenTo(@footer, 'click:edit', @click_edit)
\r
150 @listenTo(@footer, 'click:destroy', @click_destroy)
\r
154 this.$el.append(@header.render().el)
\r
155 this.$el.append(@footer.render().el)
\r
159 @trigger('click:footer:edit')
\r
160 @trigger('click:edit')
\r
162 click_destroy: () ->
\r
163 @trigger('click:footer:destroy')
\r
164 @trigger('click:destroy')
\r