mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
bf1a124475
Calling overlay.hide() doesn't invoke the onBeforeExit handler (anymore? not sure if it ever did), so we have to call this handler ourselves when manually closing the overlay. Bug: T258954 Change-Id: Ife5926241c0b8473607c14df0f89c794728566dd
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
var Overlay = mw.mobileFrontend.require( 'mobile.startup' ).Overlay;
|
|
|
|
/**
|
|
* Overlay for notifications filter
|
|
*
|
|
* @class NotificationsFilterOverlay
|
|
* @param {Object} options
|
|
* @param {Function} options.onBeforeExit executes before overlay closes
|
|
* @param {jQuery.Object} options.$notifReadState - notification read status widgets
|
|
* @param {jQuery.Object} options.$crossWikiUnreadFilter - notification unread filter
|
|
*
|
|
*/
|
|
function notificationsFilterOverlay( options ) {
|
|
var $content, overlay;
|
|
|
|
// Don't call overlay.hide(), because that doesn't invoke the onBeforeExit callback (T258954)
|
|
// Instead, change the hash, so that the OverlayManager hides the overlay for us
|
|
function hideOverlay() {
|
|
location.hash = '#';
|
|
}
|
|
|
|
// Close overlay when a selection is made
|
|
options.$crossWikiUnreadFilter.on( 'click', hideOverlay );
|
|
options.$notifReadState.find( '.oo-ui-buttonElement' ).on( 'click', hideOverlay );
|
|
|
|
$content = $( '<div>' ).append(
|
|
$( '<div>' )
|
|
.addClass( 'notifications-filter-overlay-read-state' )
|
|
.append( options.$notifReadState ),
|
|
options.$crossWikiUnreadFilter
|
|
);
|
|
|
|
overlay = Overlay.make( {
|
|
onBeforeExit: options.onBeforeExit,
|
|
heading: '<strong>' + mw.message( 'echo-mobile-notifications-filter-title' ).escaped() + '</strong>',
|
|
className: 'overlay notifications-filter-overlay notifications-overlay navigation-drawer'
|
|
}, { $el: $content } );
|
|
return overlay;
|
|
}
|
|
|
|
module.exports = notificationsFilterOverlay;
|