OSDN Git Service

4f6f21ed14e001d1661bf546450008d3e42343c3
[pettanr/pettanr.git] / app / assets / javascripts / views / pictures / credit.js.coffee
1 class Pettanr.Views.Picture.Credit extends Backbone.View\r
2   tagName: 'div'\r
3   className: 'credit'\r
4   \r
5   initialize: (options) ->\r
6     @item = options.item\r
7     @with_icon = options.with_icon\r
8     @url = @item.url + '/credit'\r
9   \r
10   render: () ->\r
11     this.$el.html('')\r
12     if @with_icon\r
13       p = @item.credit_icon_view()\r
14       this.$el.append(p.render().el)\r
15     if Pettanr.credits[@url]\r
16       this.$el.append(Pettanr.credits[@url])\r
17       this.$el.append((new Tag.RowBreak()).render().el)\r
18     else\r
19       f = (data, status) =>\r
20         Pettanr.credits[@url] = data\r
21         this.$el.append(data)\r
22         rb = new Tag.RowBreak()\r
23         this.$el.append(rb.render().el)\r
24       $.get(@url, null, f, 'html')\r
25     this\r
26   \r