Improved code layout.

This commit is contained in:
Martin Edenhofer 2012-11-11 23:57:50 +01:00
parent eff2818a71
commit e0b1d2c5a9

View file

@ -4,9 +4,9 @@ class Index extends App.Controller
className: 'container' className: 'container'
events: events:
'submit form': 'submit', 'submit form': 'submit'
'click .submit': 'submit', 'click .submit': 'submit'
'click .retry': 'rerender', 'click .retry': 'rerender'
constructor: -> constructor: ->
super super
@ -25,9 +25,9 @@ class Index extends App.Controller
@html App.view('reset_password')() @html App.view('reset_password')()
new App.ControllerForm( new App.ControllerForm(
el: @el.find('#form-password'), el: @el.find('#form-password')
model: { configure_attributes: configure_attributes }, model: { configure_attributes: configure_attributes }
autofocus: true, autofocus: true
) )
rerender: (e) -> rerender: (e) ->
@ -40,26 +40,26 @@ class Index extends App.Controller
# get data # get data
App.Com.ajax( App.Com.ajax(
id: 'password_reset', id: 'password_reset'
type: 'POST', type: 'POST'
url: '/api/users/password_reset', url: '/api/users/password_reset'
data: JSON.stringify(params), data: JSON.stringify(params)
processData: true, processData: true
success: @success, success: @success
error: @error, error: @error
) )
success: (data, status, xhr) => success: (data, status, xhr) =>
@html App.view('generic/hero_message')( @html App.view('generic/hero_message')(
head: 'We\'ve sent password reset instructions to your email address', head: 'We\'ve sent password reset instructions to your email address'
message: 'If you don\'t receive instructions within a minute or two, check your email\'s spam and junk filters, or try <a href="#" class="retry">resending your request</a>.' message: 'If you don\'t receive instructions within a minute or two, check your email\'s spam and junk filters, or try <a href="#" class="retry">resending your request</a>.'
); )
error: (data, status, xhr) => error: (data, status, xhr) =>
@html App.view('generic/hero_message')( @html App.view('generic/hero_message')(
head: 'Problem', head: 'Problem'
message: 'Username or email address invalid, please go back and try <a href="#" class="retry">again</a>.' message: 'Username or email address invalid, please go back and try <a href="#" class="retry">again</a>.'
); )
App.Config.set( 'reset_password', Index, 'Routes' ) App.Config.set( 'reset_password', Index, 'Routes' )
@ -67,8 +67,8 @@ class Verify extends App.Controller
className: 'container' className: 'container'
events: events:
'submit form': 'submit', 'submit form': 'submit'
'click .submit': 'submit', 'click .submit': 'submit'
constructor: -> constructor: ->
super super
@ -81,11 +81,11 @@ class Verify extends App.Controller
params = {} params = {}
params['token'] = @token params['token'] = @token
App.Com.ajax( App.Com.ajax(
id: 'password_reset_verify', id: 'password_reset_verify'
type: 'POST', type: 'POST'
url: '/api/users/password_reset_verify', url: '/api/users/password_reset_verify'
data: JSON.stringify(params), data: JSON.stringify(params)
processData: true, processData: true
success: @render_success success: @render_success
error: @render_failed error: @render_failed
) )
@ -98,16 +98,16 @@ class Verify extends App.Controller
@html App.view('reset_password_change')() @html App.view('reset_password_change')()
new App.ControllerForm( new App.ControllerForm(
el: @el.find('#form-password-change'), el: @el.find('#form-password-change')
model: { configure_attributes: configure_attributes }, model: { configure_attributes: configure_attributes }
autofocus: true, autofocus: true
) )
render_failed: -> render_failed: ->
@html App.view('generic/hero_message')( @html App.view('generic/hero_message')(
head: 'Failed!', head: 'Failed!'
message: 'Token is not valid!' message: 'Token is not valid!'
); )
submit: (e) -> submit: (e) ->
e.preventDefault() e.preventDefault()
@ -116,25 +116,25 @@ class Verify extends App.Controller
# get data # get data
App.Com.ajax( App.Com.ajax(
id: 'password_reset_verify', id: 'password_reset_verify'
type: 'POST', type: 'POST'
url: '/api/users/password_reset_verify', url: '/api/users/password_reset_verify'
data: JSON.stringify(params), data: JSON.stringify(params)
processData: true, processData: true
success: @render_changed_success success: @render_changed_success
error: @render_changed_failed error: @render_changed_failed
) )
render_changed_success: (data, status, xhr) => render_changed_success: (data, status, xhr) =>
@html App.view('generic/hero_message')( @html App.view('generic/hero_message')(
head: 'Woo hoo! Your password has been changed!', head: 'Woo hoo! Your password has been changed!'
message: 'Please try to login!', message: 'Please try to login!'
); )
render_changed_failed: -> render_changed_failed: =>
@html App.view('generic/hero_message')( @html App.view('generic/hero_message')(
head: 'Failed!', head: 'Failed!'
message: 'Ask your admin!', message: 'Ask your admin!'
); )
App.Config.set( 'password_reset_verify/:token', Verify, 'Routes' ) App.Config.set( 'password_reset_verify/:token', Verify, 'Routes' )