mw.notification: fix error on notif. close with $.fx.off=true
authorMatmaRex <matma.rex@gmail.com>
Wed, 3 Oct 2012 17:33:05 +0000 (19:33 +0200)
committerMarius Hoch <hoo@online.de>
Wed, 3 Oct 2012 17:51:11 +0000 (19:51 +0200)
I didn't investigate why, but apparently $placeholder being defined
lexically after it is first used causes it to be null when it shouldn't
be, causing at least Opera to blow up. This only appears when $.fx.off is
set to true (to disable all jQuery animations; there's a gadget that does
this on pl.wikipedia).

Change-Id: If0aa6279515694ef20337ef02a05562c5543b2e2

resources/mediawiki/mediawiki.notification.js

index 5bcbfcc..58a3ab6 100644 (file)
                        } )
                        // Fix the top/left position to the current computed position from which we
                        // can animate upwards.
-                       .css( this.$notification.position() )
-                       // Animate opacity and top to create fade upwards animation for notification closing
+                       .css( this.$notification.position() );
+
+               // This needs to be done *after* notification's position has been made absolute.
+               if ( options.placeholder ) {
+                       // Insert a placeholder with a height equal to the height of the
+                       // notification plus it's vertical margins in place of the notification
+                       var $placeholder = $( '<div>' )
+                               .css( 'height', this.$notification.outerHeight( true ) )
+                               .insertBefore( this.$notification );
+               }
+
+               // Animate opacity and top to create fade upwards animation for notification closing
+               this.$notification
                        .animate( {
                                opacity: 0,
                                top: '-=35'
                                        }
                                }
                        } );
-
-               if ( options.placeholder ) {
-                       // Insert a placeholder with a height equal to the height of the
-                       // notification plus it's vertical margins in place of the notification
-                       var $placeholder = $( '<div>' )
-                               .css( 'height', this.$notification.outerHeight( true ) )
-                               .insertBefore( this.$notification );
-               }
        };
 
        /**