mediawiki-extensions-Echo/modules/special/ext.echo.special.js
Ed Sanders 7ed027ddcf build: Update eslint-config-wikimedia to 0.10.1
Change-Id: I776585adab962c2b1d353d18d3a02b6662941b13
2019-02-06 01:42:53 +00:00

54 lines
1.6 KiB
JavaScript

( function () {
'use strict';
/*!
* Echo Special:Notifications page initialization
*/
$( function () {
var specialPageContainer,
limitNotifications = 50,
links = mw.config.get( 'wgNotificationsSpecialPageLinks' ),
// FIXME: Use CSS transition
// eslint-disable-next-line 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;
specialPageContainer = new mw.echo.ui.NotificationsInboxWidget(
controller,
modelManager,
{
limit: limitNotifications,
$overlay: mw.echo.ui.$overlay,
prefLink: links.preferences,
helpLink: links.help
}
);
// Overlay
$( document.body ).append( mw.echo.ui.$overlay );
// Notifications
$content.empty().append( specialPageContainer.$element );
} );
}() );