mediawiki-extensions-Echo/modules/mobile/notificationsFilterOverlay.js
Ed Sanders 1d3be2c605 ESLint: Autofix no-var errors
Keep the rule and prefer-const disabled as they will
require manual fixing.

Change-Id: Idd31eb7d7a456b10c07b905b4b837dd4c890eb71
2024-06-03 13:22:48 +01:00

43 lines
1.4 KiB
JavaScript

const Overlay = require( 'mobile.startup' ).Overlay;
/**
* @module module:ext.echo.mobile
*/
/**
* Overlay for notifications filter
*
* @class NotificationsFilterOverlay
* @param {Object} options
* @param {Function} options.onBeforeExit executes before overlay closes
* @param {jQuery} options.$notifReadState - notification read status widgets
* @param {jQuery} options.$crossWikiUnreadFilter - notification unread filter
*/
function notificationsFilterOverlay( options ) {
// 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 );
const $content = $( '<div>' ).append(
$( '<div>' )
.addClass( 'notifications-filter-overlay-read-state' )
.append( options.$notifReadState ),
options.$crossWikiUnreadFilter
);
const 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;