mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
2dd3780966
Change-Id: I01da3714b1f5d9b1926ee4394c15f594efb01245
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
( function () {
|
|
'use strict';
|
|
|
|
/*!
|
|
* Echo Special:Notifications page initialization
|
|
*/
|
|
$( () => {
|
|
const limitNotifications = 50,
|
|
links = mw.config.get( 'wgNotificationsSpecialPageLinks' ),
|
|
// FIXME: Use CSS transition
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
$content = $( '#mw-content-text' ),
|
|
echoApi = new mw.echo.api.EchoApi( { limit: limitNotifications } ),
|
|
unreadCounter = new mw.echo.dm.UnreadNotificationCounter( echoApi, [ 'message', 'alert' ], limitNotifications ),
|
|
modelManager = new mw.echo.dm.ModelManager( unreadCounter, {
|
|
type: [ 'message', 'alert' ],
|
|
itemsPerPage: limitNotifications,
|
|
readState: mw.config.get( 'wgEchoReadState' ),
|
|
localCounter: new mw.echo.dm.UnreadNotificationCounter(
|
|
echoApi,
|
|
[ 'message', 'alert' ],
|
|
limitNotifications,
|
|
{
|
|
localOnly: true,
|
|
source: 'local'
|
|
}
|
|
)
|
|
} ),
|
|
controller = new mw.echo.Controller( echoApi, modelManager );
|
|
|
|
// Set default max prioritized action links per item.
|
|
// For general purpose we have 2, for mobile only 1
|
|
mw.echo.config.maxPrioritizedActions = mw.config.get( 'skin' ) === 'minerva' ? 1 : 2;
|
|
|
|
const specialPageContainer = new mw.echo.ui.NotificationsInboxWidget(
|
|
controller,
|
|
modelManager,
|
|
{
|
|
limit: limitNotifications,
|
|
$overlay: mw.echo.ui.$overlay,
|
|
prefLink: links.preferences
|
|
}
|
|
);
|
|
|
|
// Overlay
|
|
$( document.body ).append( mw.echo.ui.$overlay );
|
|
|
|
// Notifications
|
|
$content.empty().append( specialPageContainer.$element );
|
|
} );
|
|
}() );
|