mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
299adfe6b1
We have to make sure that any notifications wrapper has the css term overflow-y: auto; so that the popup menus behave properly. Change-Id: I14a1a9f1c3610ef27fe04aa4b1e7197c08d1dfd4
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
( function ( mw ) {
|
|
/**
|
|
* Wrapper for the notifications widget, for view outside the popup.
|
|
*
|
|
* @class
|
|
* @extends OO.ui.Widget
|
|
* @mixins OO.ui.mixin.PendingElement
|
|
*
|
|
* @constructor
|
|
* @param {mw.echo.Controller} controller Echo controller
|
|
* @param {mw.echo.dm.ModelManager} model Notifications model manager
|
|
* @param {Object} [config] Configuration object
|
|
*/
|
|
mw.echo.ui.NotificationsWrapper = function MwEchoUiNotificationsWrapper( controller, model, config ) {
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
mw.echo.ui.NotificationsWrapper.parent.call( this, config );
|
|
|
|
// Mixin constructor
|
|
OO.ui.mixin.PendingElement.call( this, config );
|
|
|
|
this.controller = controller;
|
|
this.model = model;
|
|
|
|
this.notificationsWidget = new mw.echo.ui.NotificationsListWidget(
|
|
this.controller,
|
|
this.model,
|
|
{
|
|
markReadWhenSeen: false,
|
|
$overlay: config.$overlay,
|
|
types: this.controller.getTypes(),
|
|
label: mw.msg( 'notifications' ),
|
|
icon: 'bell'
|
|
}
|
|
);
|
|
|
|
// Initialize
|
|
this.$element
|
|
.addClass( 'mw-echo-notificationsWrapper' )
|
|
.append( this.notificationsWidget.$element );
|
|
};
|
|
|
|
/* Initialization */
|
|
|
|
OO.inheritClass( mw.echo.ui.NotificationsWrapper, OO.ui.Widget );
|
|
OO.mixinClass( mw.echo.ui.NotificationsWrapper, OO.ui.mixin.PendingElement );
|
|
|
|
/* Events */
|
|
|
|
/**
|
|
* @event finishLoading
|
|
* Notifications have successfully finished being processed and are fully loaded
|
|
*/
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Populate the notifications panel
|
|
*
|
|
* @return {jQuery.Promise} A promise that is resolved when all notifications
|
|
* were fetched from the API and added to the model and UI.
|
|
*/
|
|
mw.echo.ui.NotificationsWrapper.prototype.populate = function () {
|
|
var widget = this;
|
|
|
|
this.pushPending();
|
|
return this.controller.fetchLocalNotifications( true )
|
|
.always( function () {
|
|
widget.popPending();
|
|
widget.emit( 'finishLoading' );
|
|
widget.promiseRunning = false;
|
|
} );
|
|
};
|
|
} )( mediaWiki );
|