r = new Pettanr.Views.Top.Index({})\r
$("#header").html(r.render().el)\r
\r
- # try getting current user(copy paste from users/index)\r
- user = new Backbone.Model()\r
- user.url = '/users/sign_in'\r
- user.save({}, {\r
- success: (model, response, options) ->\r
- author = new Pettanr.Author(user.get('author')) if user.get('author')\r
- artist = new Pettanr.Artist(user.get('artist')) if user.get('artist')\r
- window.operators = new Pettanr.Operator({\r
- user: user, \r
- author: author, \r
- artist: artist\r
- })\r
- r = new Pettanr.Views.Top.Account({operators: window.operators})\r
- $('#account').html(r.render().el)\r
- window.router.navigate('', true)\r
- error: (model, response, options) ->\r
- response.status\r
- })\r
- \r
window.onbeforeunload = (e)->\r
return('leave?')\r
window.router = new Pettanr.Router()\r
- Backbone.history.start({pushState: true})\r
- window.router.navigate('', true)\r
+ Backbone.history.start({silent: true, pushState: true})\r
+ \r
+ # try getting current user(copy paste from users/index)\r
+ user = new Pettanr.User.Current()\r
+ user.save({}, (current_user) ->\r
+ r = new Pettanr.Views.Top.Account({operators: window.operators})\r
+ $('#account').html(r.render().el)\r
+ window.router.home()\r
+ )\r
\r
t: () ->\r
#i = new Pettanr.Balloon({id: 49})\r
if @id\r
@url = @url + @id\r
\r
+class Pettanr.User.Current extends Pettanr.User\r
+ \r
+ save: (model_attr, after_save = null) ->\r
+ _this = this\r
+ super(model_attr, {\r
+ success: (model, response, options) ->\r
+ author = new Pettanr.Author(_this.get('author')) if _this.get('author')\r
+ artist = new Pettanr.Artist(_this.get('artist')) if _this.get('artist')\r
+ window.operators = new Pettanr.Operator({\r
+ user: _this, \r
+ author: author, \r
+ artist: artist\r
+ })\r
+ if after_save\r
+ after_save(_this)\r
+ error: (model, response, options) ->\r
+ r = new Pettanr.Views.User.Index({})\r
+ $("#pettanr").html(r.render().el)\r
+ })\r
+ \r
+ initialize: () ->\r
+ @url = '/users/sign_in'\r
+ \r
sign_in: () ->\r
m = $('#user_email').val()\r
p = $('#user_password').val()\r
- user = new Backbone.Model()\r
- user.url = '/users/sign_in'\r
- user.save({user: {email: m, password: p}}, {\r
- success: (model, response, options) ->\r
- author = new Pettanr.Author(user.get('author')) if user.get('author')\r
- artist = new Pettanr.Artist(user.get('artist')) if user.get('artist')\r
- window.operators = new Pettanr.Operator({\r
- user: user, \r
- author: author, \r
- artist: artist\r
- })\r
- r = new Pettanr.Views.Top.Account({operators: window.operators})\r
- $('#account').html(r.render().el)\r
- window.router.navigate('', true)\r
- error: (model, response, options) ->\r
- response.status\r
- })\r
+ user = new Pettanr.User.Current()\r
+ user.save({user: {email: m, password: p}}, (current_user) ->\r
+ r = new Pettanr.Views.Top.Account({operators: window.operators})\r
+ $('#account').html(r.render().el)\r
+ window.router.home()\r
+ )\r
return false\r
\r