OSDN Git Service

conflict
[pettanr/pettanr.git] / app / assets / javascripts / views / resource_pictures / show.js.coffee
1 class Pettanr.Views.ResourcePicture.Show extends Pettanr.View.Show\r
2   \r
3   initialize: (options) ->\r
4     @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
5     @authored_by = @item.authored_by()\r
6     @img = @item.real_picture('full')\r
7     @listenTo(@header, 'click:pick', @click_pick)\r
8     @listenTo(@authored_by, 'click', @click_authored_by)\r
9   \r
10   render: () ->\r
11     this.$el.html('')\r
12     this.$el.append(@header.render().el)\r
13     this.$el.append(@authored_by.render().el)\r
14     this.$el.append(@img.render().el)\r
15     @item.get_parent('picture', this, {\r
16       success: (picture) =>\r
17         @add_credit(picture)\r
18     })\r
19     if @item.is_own()\r
20       @item.get_parent('original_picture', this, {\r
21         success: (@original_picture) =>\r
22           @owner = new Pettanr.View.Show.Footer(null, this, {\r
23             actions: {\r
24               replace: {\r
25                 item: @original_picture,\r
26                 url: @original_picture.edit_url(),\r
27                 dic_name: 'original_pictures.show.replace',\r
28                 click: () =>\r
29                   @trigger('http_get', @original_picture.edit_url())\r
30               }, \r
31               source: {\r
32                 item: @original_picture,\r
33                 url: @original_picture.show_url(),\r
34                 dic_name: 'original_pictures.show.title',\r
35                 click: () =>\r
36                   @trigger('http_get', @original_picture.show_url())\r
37               }, \r
38               stop: {\r
39                 item: @item,\r
40                 url: @item.destroy_url(),\r
41                 dic_name: 'original_pictures.index.stop',\r
42                 click: () =>\r
43                   redirect = (url) =>\r
44                     @trigger('http_get', url)\r
45                   Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
46               }, \r
47             }, \r
48           })\r
49           this.$el.append(@owner.render().el)\r
50       })\r
51     this\r
52   \r
53   click_pick: () ->\r
54     @trigger('pick', @item)\r
55   \r
56   is_pickable: () ->\r
57     true\r
58   \r
59   add_pick: (target_model) ->\r
60     @header.add_pick(target_model)\r
61   \r