Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/382229 )
Change subject: mediawiki.notification: Refactor $.ready handler and init()
......................................................................
mediawiki.notification: Refactor $.ready handler and init()
* Merge code from $.ready handler into init().
This makes it more obvious in which order the code runs, and
makes it easier to make perf fixes in the next commit.
* Move updateAreaMode() to the start of the init() function.
Change-Id: I088446e17c2dc8ed88742bfeae80352444126e88
---
M resources/src/mediawiki/mediawiki.notification.js
1 file changed, 21 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/29/382229/1
diff --git a/resources/src/mediawiki/mediawiki.notification.js
b/resources/src/mediawiki/mediawiki.notification.js
index c213cd2..291d996 100644
--- a/resources/src/mediawiki/mediawiki.notification.js
+++ b/resources/src/mediawiki/mediawiki.notification.js
@@ -266,9 +266,21 @@
* @ignore
*/
function init() {
- var offset,
+ var offset, notif,
isFloating = false;
+ function updateAreaMode() {
+ var shouldFloat = window.pageYOffset > offset.top;
+ if ( isFloating === shouldFloat ) {
+ return;
+ }
+ isFloating = shouldFloat;
+ $area
+ .toggleClass( 'mw-notification-area-floating',
isFloating )
+ .toggleClass( 'mw-notification-area-layout',
!isFloating );
+ }
+
+ // Prepend the notification area to the content area and save
it's object.
$area = $( '<div id="mw-notification-area"
class="mw-notification-area mw-notification-area-layout"></div>' )
// Pause auto-hide timers when the mouse is in the
notification area.
.on( {
@@ -288,26 +300,22 @@
e.stopPropagation();
} );
- // Prepend the notification area to the content area and save
it's object.
mw.util.$content.prepend( $area );
offset = $area.offset();
$area.css( 'display', 'none' );
- function updateAreaMode() {
- var shouldFloat = window.pageYOffset > offset.top;
- if ( isFloating === shouldFloat ) {
- return;
- }
- isFloating = shouldFloat;
- $area
- .toggleClass( 'mw-notification-area-floating',
isFloating )
- .toggleClass( 'mw-notification-area-layout',
!isFloating );
- }
$( window ).on( 'scroll', updateAreaMode );
// Initial mode
updateAreaMode();
+
+ // Handle pre-ready queue.
+ isPageReady = true;
+ while ( preReadyNotifQueue.length ) {
+ notif = preReadyNotifQueue.shift();
+ notif.start();
+ }
}
/**
@@ -423,18 +431,7 @@
autoHideLimit: 3
};
- $( function () {
- var notif;
-
- init();
-
- // Handle pre-ready queue.
- isPageReady = true;
- while ( preReadyNotifQueue.length ) {
- notif = preReadyNotifQueue.shift();
- notif.start();
- }
- } );
+ $( init );
mw.notification = notification;
--
To view, visit https://gerrit.wikimedia.org/r/382229
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I088446e17c2dc8ed88742bfeae80352444126e88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits