From c9a7108af24a24b697ad2fa28d539c842e8e6a2f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 24 Apr 2012 08:38:47 +0200 Subject: [PATCH] Improved notifications. --- .../controllers/agent_ticket_create.js.coffee | 13 +++---- .../app/controllers/notify.js.coffee | 38 +++++++++---------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index fd2f5c0b1..a7123766b 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -59,10 +59,6 @@ class Index extends App.Controller form: @formGen( model: { configure_attributes: configure_attributes, className: 'create' } ), ) -# @modalShow( -# navigateBack: true -# ) - user_new: (e) => e.preventDefault() new UserNew() @@ -123,14 +119,15 @@ class Index extends App.Controller # notify UI @notify - type: 'success', - msg: 'Ticket ' + r.number + ' created!' - + type: 'success', + msg: "Ticket #{r.number} created!", + timeout: 12000, + # create new create screen @render() # scroll to top - window.scrollTo(0,0) + @scrollTo() error: => @log 'save failed!' diff --git a/app/assets/javascripts/app/controllers/notify.js.coffee b/app/assets/javascripts/app/controllers/notify.js.coffee index 95fb236c9..ed0d60a86 100644 --- a/app/assets/javascripts/app/controllers/notify.js.coffee +++ b/app/assets/javascripts/app/controllers/notify.js.coffee @@ -10,38 +10,36 @@ class App.Notify extends Spine.Controller super Spine.bind 'notify', (data) => - @[data.type] data.msg + @render(data) Spine.bind 'notify:removeall', => @log 'notify:removeall', @ @destroyAll() - info: (data) -> - @render( text: arguments[0], type: 'information' ) - - warning: (data) -> - @render( text: arguments[0], type: 'alert' ) - - error: (data) -> - @render( text: arguments[0], type: 'error' ) - - success: (data) -> - @render( text: arguments[0], type: 'success' ) - render: (data) -> # notify = App.view('notify')(data: data) # @append( notify ) + + # match noty naming + if data['type'] is 'info' + data['type'] = 'information' + $.noty.closeAll() $('#notify').noty( { - text: data.text, - layout: 'top', - type: data.type, - theme: 'noty_theme_twitter', - animateOpen: { height: 'toggle' }, - animateClose: { height: 'toggle' }, + text: data.msg, + layout: 'top', + type: data.type, + theme: 'noty_theme_twitter', + animateOpen: { + height: 'toggle' + opacity: 0.85, + }, + animateClose: { + opacity: 0.25, + }, speed: 450, - timeout: 3600, + timeout: data.timeout || 3800, closeButton: false, closeOnSelfClick: true, closeOnSelfOver: false,