Notify code cleanup.

This commit is contained in:
Martin Edenhofer 2013-05-09 18:05:07 +02:00
parent 6f8d3ee1b6
commit 09531e7a4d
4 changed files with 44 additions and 51 deletions

View file

@ -1,6 +1,6 @@
class Index extends App.ControllerContent
events:
'submit #login': 'login',
'submit #login': 'login'
constructor: ->
super
@ -47,7 +47,7 @@ class Index extends App.ControllerContent
auth_providers: auth_providers
)
# set focus
# set focus to username or password
if !$(@el).find('[name="username"]').val()
$(@el).find('[name="username"]').focus()
else
@ -68,9 +68,9 @@ class Index extends App.ControllerContent
# session create with login/password
App.Auth.login(
data: params,
data: params
success: @success
error: @error,
error: @error
)
success: (data, status, xhr) =>
@ -80,15 +80,14 @@ class Index extends App.ControllerContent
App.WebSocket.send( event: 'navupdate_ticket_overview' )
# add notify
App.Event.trigger 'notify:removeall'
App.Event.trigger 'notify', {
type: 'success',
msg: App.i18n.translateContent('Login successfully! Have a nice day!'),
}
@notify
type: 'success'
msg: App.i18n.translateContent('Login successfully! Have a nice day!')
removeAll: true
# redirect to #
requested_url = @Config.get( 'requested_url' )
if requested_url isnt ''
if requested_url && requested_url isnt '#login'
console.log("REDIRECT to '#{requested_url}'")
@navigate requested_url
@ -101,11 +100,10 @@ class Index extends App.ControllerContent
error: (xhr, statusText, error) =>
# add notify
App.Event.trigger 'notify:removeall'
App.Event.trigger 'notify', {
type: 'error',
msg: App.i18n.translateContent('Wrong Username and Password combination.'),
}
@notify
type: 'error'
msg: App.i18n.translateContent('Wrong Username and Password combination.')
removeAll: true
# rerender login page
@render(
@ -115,7 +113,7 @@ class Index extends App.ControllerContent
# login shake
@delay(
=> @shake( @el.find('#login') ),
700
600
)
App.Config.set( 'login', Index, 'Routes' )

View file

@ -24,27 +24,29 @@ class App.Notify extends Spine.Controller
if data['type'] is 'warning'
data['type'] = 'alert'
$.noty.closeAll()
if data['removeAll']
$.noty.closeAll()
if data.link
data.msg = '<a href="' + data.link + '">' + data.msg + '</a>'
$('#notify').noty(
{
text: data.msg,
layout: 'top',
type: data.type,
theme: 'noty_theme_twitter',
dismissQueue: true
text: data.msg
layout: 'top'
type: data.type
theme: 'noty_theme_twitter'
animateOpen: {
height: 'toggle'
opacity: 0.85,
},
animateClose: {
opacity: 0.25,
opacity: 0.25
},
speed: 450,
timeout: data.timeout || 3800,
closeButton: false,
closeOnSelfClick: true,
closeOnSelfOver: false,
speed: 450
timeout: data.timeout || 3800
closeButton: false
closeOnSelfClick: true
closeOnSelfOver: false
}
)

View file

@ -140,10 +140,10 @@ class Verify extends App.ControllerContent
App.Auth.loginCheck()
# add notify
App.Event.trigger 'notify:removeall'
@notify
type: 'success',
msg: 'Woo hoo! Your password has been changed!'
type: 'success'
msg: 'Woo hoo! Your password has been changed!'
removeAll: true
# redirect to #
@navigate '#'
@ -151,10 +151,10 @@ class Verify extends App.ControllerContent
error: =>
# add notify
App.Event.trigger 'notify:removeall'
@notify
type: 'error',
msg: 'Something went wrong. Please contact your administrator.'
type: 'error'
msg: 'Something went wrong. Please contact your administrator.'
removeAll: true
)
render_changed_failed: =>

View file

@ -2,9 +2,9 @@ class Index extends App.ControllerContent
className: 'container signup'
events:
'submit form': 'submit',
'click .submit': 'submit',
'click .cancel': 'cancel',
'submit form': 'submit'
'click .submit': 'submit'
'click .cancel': 'cancel'
constructor: ->
super
@ -37,7 +37,7 @@ class Index extends App.ControllerContent
)
cancel: ->
@navigate 'login'
@navigate '#login'
submit: (e) ->
e.preventDefault()
@ -80,10 +80,10 @@ class Index extends App.ControllerContent
App.Auth.loginCheck()
# add notify
App.Event.trigger 'notify:removeall'
@notify
type: 'success',
msg: 'Thanks for joining. Email sent to "' + @params.email + '". Please verify your email address.'
type: 'success'
msg: 'Thanks for joining. Email sent to "' + @params.email + '". Please verify your email address.'
removeAll: true
# redirect to #
@navigate '#'
@ -91,16 +91,9 @@ class Index extends App.ControllerContent
error: (xhr, statusText, error) =>
# add notify
App.Event.trigger 'notify:removeall'
App.Event.trigger 'notify', {
type: 'warning'
msg: 'Wrong Username and Password combination.'
}
# rerender login page
@render(
msg: 'Wrong Username and Password combination.'
username: @username
)
@notify
type: 'warning'
msg: 'Wrong Username and Password combination.'
removeAll: true
App.Config.set( 'signup', Index, 'Routes' )