mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-15 03:35:01 +00:00
62216cab80
Display a single foreign bundle containing both alerts and messages on mobile. Bug: T131683 Change-Id: I9d3d160586c31457d3a1825e9cecadde42debf7c
71 lines
1.7 KiB
JavaScript
71 lines
1.7 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.dm.NotificationsModel} model Notifications view model
|
|
* @param {Object} [config] Configuration object
|
|
*/
|
|
mw.echo.ui.NotificationsWrapper = function MwEchoUiNotificationsWrapper( model, config ) {
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
mw.echo.ui.NotificationsWrapper.parent.call( this, config );
|
|
|
|
// Mixin constructor
|
|
OO.ui.mixin.PendingElement.call( this, config );
|
|
|
|
this.model = model;
|
|
|
|
this.notificationsWidget = new mw.echo.ui.NotificationsWidget(
|
|
this.model,
|
|
{
|
|
markReadWhenSeen: false,
|
|
$overlay: config.$overlay,
|
|
label: mw.msg( 'notifications' ),
|
|
icon: 'bell'
|
|
}
|
|
);
|
|
|
|
// Initialize
|
|
this.$element
|
|
.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.model.fetchNotifications( true )
|
|
.always( function () {
|
|
widget.popPending();
|
|
widget.emit( 'finishLoading' );
|
|
widget.promiseRunning = false;
|
|
} );
|
|
};
|
|
} )( mediaWiki );
|