Prechádzať zdrojové kódy

Fix error in chaining notifications

Javi Jimenez Villar 13 rokov pred
rodič
commit
7a2a2edadc

+ 3 - 4
example/static/javascripts/app.js

@@ -136,11 +136,10 @@ Lungo.Events.init({
     },
 
     'tap article#notification a[data-action=chaining]': function() {
-        Lungo.Notification.show('user', 'title', 2, function() {
+        Lungo.Notification.show('user', 'user', 2, function() {
             Lungo.Notification.error('Title 2', 'Description 2', 'remove',  2, function() {
-                Lungo.Notification.show('home', 'title 2', false, 2, function() {
-                    Lungo.Notification.html('<h1>Hello World</h1>', true);
-                    // Lungo.Notification.hide();
+                Lungo.Notification.show('cog', 'cog', 2, function() {
+                    Lungo.Notification.html('<h1>Hello World</h1>', "Close");
                 });
             });
         });

+ 6 - 7
src/modules/Lungo.Notification.coffee

@@ -12,9 +12,10 @@ Lungo.Notification = do(lng = Lungo) ->
   _el = null
   _window = null
   DELAY_TIME = 1
-  ANIMATION_MILISECONDS = 200
   ATTRIBUTE = lng.Constants.ATTRIBUTE
   BINDING = lng.Constants.BINDING
+  TRANSITION = lng.Constants.TRANSITION
+
   SELECTOR =
     BODY: "body"
     NOTIFICATION: ".notification"
@@ -30,7 +31,6 @@ Lungo.Notification = do(lng = Lungo) ->
     WORKING: "working"
     INPUT: "input"
 
-  CALLBACK_HIDE = "Lungo.Notification.hide()"
   MARKUP_NOTIFICATION = "<div class=\"notification\"><div class=\"window\"></div></div>"
 
   ###
@@ -52,7 +52,7 @@ Lungo.Notification = do(lng = Lungo) ->
     _window.removeClass("show")
     setTimeout (->
       _el.removeClass("show").removeClass("html").removeClass("confirm").removeClass("notify").removeClass "growl"
-    ), ANIMATION_MILISECONDS - 50
+    ), (TRANSITION.DURATION / 2)
 
 
   ###
@@ -108,18 +108,17 @@ Lungo.Notification = do(lng = Lungo) ->
     setTimeout (->
       _window.html html
       _window.attr "class", "window #{stylesheet} show"
-    ), 400
+    ), (TRANSITION.DURATION / 2)
 
   _hide = (seconds, callback) ->
     if seconds? and seconds > 0
       setTimeout (=>
-        do hide
-        if callback then callback.call @
+        if callback then callback.call undefined, callback
       ), seconds * 1000
 
   _notify = (title, description, icon, stylesheet, seconds, callback) ->
     _show _markup(title, description, icon), stylesheet
-    _hide seconds, callback if seconds
+    _hide seconds, callback
 
   _markup = (title, description, icon) ->
     description = (if not description then "&nbsp;" else description)