w/resources/src/mediawiki/mediawiki.notification.js
/**
	 * Initialisation.
	 * Must only be called once, and not before the document is ready.
	 *
	 * @ignore
	 */
Initialisation.
Must only be called once, and not before the document is ready.

@ignore
Initialisation . Must only be called once and not before the document is ready . @ignore
function init() {
		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 );
		}
		$area = $( '<div id="mw-notification-area" class="mw-notification-area mw-notification-area-layout"></div>' )
			.on( {
				mouseenter: notification.pause,
				mouseleave: notification.resume
			} )
			.on( 'click', '.mw-notification', function () {
				var notif = $( this ).data( 'mw.notification' );
				if ( notif ) {
					notif.close();
				}
			} )
			.on( 'click', 'a', function ( e ) {
				e.stopPropagation();
			} );
		mw.util.$content.prepend( $area );
		rAF( function () {
			offset = $area.offset();
			updateAreaMode();
			$area.css( 'display', 'none' );
			$( window ).on( 'scroll', updateAreaMode );
			isPageReady = true;
			while ( preReadyNotifQueue.length ) {
				notif = preReadyNotifQueue.shift();
				notif.start();
			}
		} );
	}
function init ( ) { 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 ) ; } $area = $ ( '<div id="mw-notification-area" class="mw-notification-area mw-notification-area-layout"></div>' ) . on ( { mouseenter : notification . pause , mouseleave : notification . resume } ) . on ( 'click' , '.mw-notification' , function ( ) { var notif = $ ( this ) . data ( 'mw.notification' ) ; if ( notif ) { notif . close ( ) ; } } ) . on ( 'click' , 'a' , function ( e ) { e . stopPropagation ( ) ; } ) ; mw . util . $content . prepend ( $area ) ; rAF ( function ( ) { offset = $area . offset ( ) ; updateAreaMode ( ) ; $area . css ( 'display' , 'none' ) ; $ ( window ) . on ( 'scroll' , updateAreaMode ) ; isPageReady = true ; while ( preReadyNotifQueue . length ) { notif = preReadyNotifQueue . shift ( ) ; notif . start ( ) ; } } ) ; }
Initialisation.
Initialisation .
// Write to the DOM: // Prepend the notification area to the content area and save its object. // Pause auto-hide timers when the mouse is in the notification area. // When clicking on a notification close it. // Stop click events from <a> tags from propogating to prevent clicking. // on links from hiding a notification. // Read from the DOM: // Must be in the next frame to avoid synchronous layout // computation from offset()/getBoundingClientRect(). // Initial mode (reads, and then maybe writes) // Once we have the offset for where it would normally render, set the // initial state of the (currently empty) notification area to be hidden. // Handle pre-ready queue.