class Pettanr.Views.Top.Account extends Backbone.View tagName: 'div' initialize: (options) -> @operators = options.operators @author = @operators.author @artist = @operators.artist if @author @author_view = @author.icon_with_caption_view() @listenTo(@author_view, 'click', @author_click) if @artist @artist_view = @artist.icon_with_caption_view() @listenTo(@artist_view, 'click', @artist_click) render: () -> this.$el.html('') if @author_view this.$el.append(@author_view.render().el) if @artist_view this.$el.append(@artist_view.render().el) sign_out = new Tag.A({ attr: {href: '/'}, class_name: 'sign_out', content: 'sign out' }) this.$el.append(sign_out.render().el) @delegateEvents({'click .sign_out': 'sign_out'}) this author_click: () -> window.router.navigate(@author_view.url(), true) artist_click: () -> window.router.navigate(@artist_view.url(), true) sign_out: () -> user = new Backbone.Model({id: 0}) user.url = '/users/sign_out' user.destroy({success: () -> r = new Pettanr.Views.Top.Index({}) $("#header").html(r.render().el) $("#pettanr").html('') }) return false