From a7ac3b834372825ac38f368d0dbbf792708c98c5 Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Tue, 30 Aug 2016 16:02:18 -0700 Subject: [PATCH] Allow skins to place notification container for mw.notify Give skins the ability to place the mw.notification notifications in a div of their choosing rather than force the container to be in the content area. This is particularly useful for skins that deal with multiple overlays that are created and displayed outside the content div, which then in turn hides the notification area. A good example of this behavior is in MobileFrontend's overlays that are created as siblings to the content div, and so all mw.notify() notifications are then hidden behind them. Bug: T143837 Bug: T202466 Change-Id: I5a78949efef88083bdafc4207a6872c76b463970 --- .../src/mediawiki.notification/notification.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/resources/src/mediawiki.notification/notification.js b/resources/src/mediawiki.notification/notification.js index a163a3d328..d4bc7ad648 100644 --- a/resources/src/mediawiki.notification/notification.js +++ b/resources/src/mediawiki.notification/notification.js @@ -290,10 +290,18 @@ .toggleClass( 'mw-notification-area-layout', !isFloating ); } - // Write to the DOM: - // Prepend the notification area to the content area and save its object. - // The ID attribute here is deprecated. - $area = $( '
' ) + // Look for a preset notification area in the skin. + // 'data-mw*' attributes are banned from user content in Sanitizer. + $area = $( '.mw-notification-area[data-mw="interface"]' ).first(); + if ( !$area.length ) { + $area = $( '
' ).addClass( 'mw-notification-area' ); + // Prepend the notification area to the content area + mw.util.$content.prepend( $area ); + } + $area + .addClass( 'mw-notification-area-layout' ) + // The ID attribute here is deprecated. + .attr( 'id', 'mw-notification-area' ) // Pause auto-hide timers when the mouse is in the notification area. .on( { mouseenter: notification.pause, @@ -312,8 +320,6 @@ e.stopPropagation(); } ); - mw.util.$content.prepend( $area ); - // Read from the DOM: // Must be in the next frame to avoid synchronous layout // computation from offset()/getBoundingClientRect(). -- 2.20.1