OSDN Git Service

fix: view
[pettanr/pettanr.git] / app / assets / javascripts / view / show / header / authored_by.js.coffee
1 # options: {\r
2 #   label: {  label_options ... }\r
3 #   button: {  button_options ... }\r
4 # }\r
5 class Pettanr.View.Show.AuthoredBy extends Pettanr.View\r
6   tagName: 'div'\r
7   \r
8   constructor: (@content, options) ->\r
9     super(options)\r
10   \r
11   initialize: (options = {}) ->\r
12     @label_options = options.label || {shorten: false}\r
13   \r
14   render: () ->\r
15     this.$el.html('')\r
16     author_item_name = @content.my_class().owner_type()\r
17     @content.get_parent(author_item_name, this, {\r
18       success: (author) =>  # author or artist\r
19         label_button = author.label_button(@label_options, {\r
20           context: this,\r
21           click: () =>\r
22             @trigger('click', author)\r
23         })\r
24         this.$el.append(Pettanr.AppHelper.t_a(@content.item_name(), @content.my_class().owner_column()))\r
25         this.$el.append(label_button.render().el)\r
26     })\r
27     this\r
28   \r