OSDN Git Service

fix layout default
[pettanr/pettanr.git] / app / assets / javascripts / views / users / account.js.coffee
1 class Pettanr.Views.User.Account extends Backbone.View\r
2   tagName: 'div'\r
3   \r
4   initialize: (options) ->\r
5     @operators = options.operators\r
6     @author = @operators.author\r
7     @artist = @operators.artist\r
8     if @author\r
9       @author_view = @author.icon_with_caption_view()\r
10       @listenTo(@author_view, 'click', @author_click)\r
11     if @artist\r
12       @artist_view = @artist.icon_with_caption_view()\r
13       @listenTo(@artist_view, 'click', @artist_click)\r
14   \r
15   render: () ->\r
16     this.$el.html('')\r
17     if @author_view\r
18       this.$el.append(@author_view.render().el)\r
19     if @artist_view\r
20       this.$el.append(@artist_view.render().el)\r
21     sign_out = new Tag.A({\r
22       attr: {href: '/users/sign_out'}, \r
23       class_name: 'sign_out', \r
24       content: 'sign out'\r
25     })\r
26     this.$el.append(sign_out.render().el)\r
27     @delegateEvents({'click .sign_out': 'sign_out'})\r
28     this\r
29   \r
30   author_click: () ->\r
31     @trigger('navigate', @author_view.url())\r
32   \r
33   artist_click: () ->\r
34     @trigger('navigate', @artist_view.url())\r
35   \r
36   sign_out: () ->\r
37     user = new Backbone.Model({id: 0})\r
38     user.url = '/users/sign_out'\r
39     user.destroy({success: () ->\r
40       r = new Pettanr.Views.Top.Index({})\r
41       $("#header").html(r.render().el)\r
42       $("#pettanr").html('')\r
43     })\r
44     return false\r
45   \r