OSDN Git Service

fix:element remove func failed
[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('original_picture', this, {\r
16       success: (@original_picture) =>\r
17         @owner = new Pettanr.View.Show.Footer(null, this, {\r
18           actions: {\r
19             replace: {\r
20               item: @original_picture,\r
21               url: @original_picture.edit_url(),\r
22               dic_name: 'original_pictures.show.replace',\r
23               click: () =>\r
24                 @trigger('http_get', @original_picture.edit_url())\r
25             }, \r
26             source: {\r
27               item: @original_picture,\r
28               url: @original_picture.show_url(),\r
29               dic_name: 'original_pictures.show.title',\r
30               click: () =>\r
31                 @trigger('http_get', @original_picture.show_url())\r
32             }, \r
33             stop: {\r
34               item: @item,\r
35               url: @item.destroy_url(),\r
36               dic_name: 'original_pictures.index.stop',\r
37               click: () =>\r
38                 redirect = (url) =>\r
39                   @trigger('http_get', url)\r
40                 Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
41             }, \r
42           }, \r
43         })\r
44         @item.get_parent('picture', this, {\r
45           success: (picture) =>\r
46             @add_credit(picture)\r
47             this.$el.append(@owner.render().el)\r
48         })\r
49     })\r
50     this\r
51   \r
52   click_pick: () ->\r
53     @trigger('pick', @item)\r
54   \r
55   is_pickable: () ->\r
56     true\r
57   \r
58   add_pick: (target_model) ->\r
59     @header.add_pick(target_model)\r
60   \r