OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / views / top / account.js.coffee
1 class Pettanr.Views.Top.Account extends Backbone.View\r
2   tagName: 'div'\r
3   \r
4   initialize: (options) ->\r
5     @operators = options.operators\r
6   \r
7   render: () ->\r
8     this.$el.html('')\r
9     if au = @operators.author\r
10       author = au.icon_with_caption_view()\r
11       this.$el.append(author.render().el)\r
12     if ar = @operators.artist\r
13       artist = ar.icon_with_caption_view()\r
14       this.$el.append(artist.render().el)\r
15     sign_out = new Tag.A({attr: {href: '/'}, class_name: 'sign_out', content: 'sign out'})\r
16     this.$el.append(sign_out.render().el)\r
17     @delegateEvents({'click .sign_out': 'sign_out'})\r
18     this\r
19   \r
20   sign_out: () ->\r
21     user = new Backbone.Model({id: 0})\r
22     user.url = '/users/sign_out'\r
23     user.destroy({success: () ->\r
24       r = new Pettanr.Views.Top.Index({})\r
25       $("#header").html(r.render().el)\r
26       $("#pettanr").html('')\r
27     })\r
28     return false\r
29   \r