2015-08-13 00:54:16 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
/**
|
|
|
|
* Notification badge button widget for echo popup.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.ButtonWidget
|
|
|
|
*
|
|
|
|
* @constructor
|
2016-04-10 13:31:02 +00:00
|
|
|
* @param {mw.echo.Controller} controller Echo notifications controller
|
|
|
|
* @param {mw.echo.dm.ModelManager} manager Model manager
|
|
|
|
* @param {Object} [config] Configuration object
|
|
|
|
* @cfg {string|string[]} [type='message'] The type or array of types of
|
|
|
|
* notifications that are in this model. They can be 'alert', 'message' or
|
|
|
|
* an array of both. Defaults to 'message'
|
2015-08-13 00:54:16 +00:00
|
|
|
* @cfg {number} [numItems=0] How many items are in the button display
|
2015-09-03 21:24:03 +00:00
|
|
|
* @cfg {boolean} [hasUnseen=false] Whether there are unseen items
|
2015-09-09 20:18:52 +00:00
|
|
|
* @cfg {number} [popupWidth=450] The width of the popup
|
2015-08-13 00:54:16 +00:00
|
|
|
* @cfg {string|Object} [badgeIcon] The icons to use for this button.
|
|
|
|
* If this is a string, it will be used as the icon regardless of the state.
|
|
|
|
* If it is an object, it must include
|
2015-09-03 21:24:03 +00:00
|
|
|
* the properties 'unseen' and 'seen' with icons attached to both. For example:
|
2015-08-13 00:54:16 +00:00
|
|
|
* { badgeIcon: {
|
2015-09-03 21:24:03 +00:00
|
|
|
* unseen: 'bellOn',
|
|
|
|
* seen: 'bell'
|
2015-08-13 00:54:16 +00:00
|
|
|
* } }
|
2015-09-24 01:13:37 +00:00
|
|
|
* @cfg {string} [href] URL the badge links to
|
2015-11-21 01:54:12 +00:00
|
|
|
* @cfg {jQuery} [$overlay] A jQuery element functioning as an overlay
|
|
|
|
* for popups.
|
2015-08-13 00:54:16 +00:00
|
|
|
*/
|
2016-04-10 13:31:02 +00:00
|
|
|
mw.echo.ui.NotificationBadgeWidget = function MwEchoUiNotificationBadgeButtonPopupWidget( controller, manager, config ) {
|
2016-03-18 00:00:05 +00:00
|
|
|
var buttonFlags, allNotificationsButton, preferencesButton, footerButtonGroupWidget, $footer,
|
|
|
|
initialNotifCount, notice;
|
2015-08-13 00:54:16 +00:00
|
|
|
|
|
|
|
config = config || {};
|
|
|
|
config.links = config.links || {};
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
// Parent constructor
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.parent.call( this, config );
|
|
|
|
|
2015-08-13 00:54:16 +00:00
|
|
|
// Mixin constructors
|
|
|
|
OO.ui.mixin.PendingElement.call( this, config );
|
|
|
|
|
2015-11-21 01:54:12 +00:00
|
|
|
this.$overlay = config.$overlay || this.$element;
|
2015-10-16 23:18:25 +00:00
|
|
|
// Create a menu overlay
|
|
|
|
this.$menuOverlay = $( '<div>' )
|
|
|
|
.addClass( 'mw-echo-ui-NotificationBadgeWidget-overlay-menu' );
|
|
|
|
this.$overlay.append( this.$menuOverlay );
|
2015-11-21 01:54:12 +00:00
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
// Controller
|
|
|
|
this.controller = controller;
|
|
|
|
this.manager = manager;
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.types = this.manager.getTypes();
|
2015-10-26 22:23:22 +00:00
|
|
|
|
2016-03-09 04:50:31 +00:00
|
|
|
this.maxNotificationCount = mw.config.get( 'wgEchoMaxNotificationCount' );
|
2015-08-13 00:54:16 +00:00
|
|
|
this.numItems = config.numItems || 0;
|
2015-09-17 00:05:52 +00:00
|
|
|
this.badgeIcon = config.badgeIcon || {};
|
2015-08-13 00:54:16 +00:00
|
|
|
this.hasRunFirstTime = false;
|
|
|
|
|
|
|
|
buttonFlags = [ 'primary' ];
|
2015-09-03 21:24:03 +00:00
|
|
|
if ( !!config.hasUnseen ) {
|
2015-08-13 00:54:16 +00:00
|
|
|
buttonFlags.push( 'unseen' );
|
|
|
|
}
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
this.badgeButton = new mw.echo.ui.BadgeLinkWidget( {
|
|
|
|
label: this.numItems,
|
|
|
|
flags: buttonFlags,
|
|
|
|
badgeIcon: config.badgeIcon,
|
|
|
|
// The following messages can be used here:
|
|
|
|
// tooltip-pt-notifications-alert
|
2016-07-07 22:05:56 +00:00
|
|
|
// tooltip-pt-notifications-notice
|
|
|
|
title: mw.msg( 'tooltip-pt-notifications-' +
|
2016-07-08 00:05:52 +00:00
|
|
|
(
|
|
|
|
this.controller.getTypeString() === 'message' ? 'notice' : this.controller.getTypeString()
|
|
|
|
)
|
2016-07-07 22:05:56 +00:00
|
|
|
),
|
2015-09-24 01:13:37 +00:00
|
|
|
href: config.href
|
2015-09-17 00:05:52 +00:00
|
|
|
} );
|
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
// Notifications list widget
|
|
|
|
this.notificationsWidget = new mw.echo.ui.NotificationsListWidget(
|
|
|
|
this.controller,
|
|
|
|
this.manager,
|
2015-08-13 00:54:16 +00:00
|
|
|
{
|
2016-04-10 13:31:02 +00:00
|
|
|
type: this.types,
|
2016-06-10 13:06:04 +00:00
|
|
|
$overlay: this.$menuOverlay
|
2015-08-13 00:54:16 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Footer
|
|
|
|
allNotificationsButton = new OO.ui.ButtonWidget( {
|
|
|
|
icon: 'next',
|
|
|
|
label: mw.msg( 'echo-overlay-link' ),
|
|
|
|
href: config.links.notifications,
|
|
|
|
classes: [ 'mw-echo-ui-notificationBadgeButtonPopupWidget-footer-allnotifs' ]
|
|
|
|
} );
|
|
|
|
|
|
|
|
preferencesButton = new OO.ui.ButtonWidget( {
|
|
|
|
icon: 'advanced',
|
|
|
|
label: mw.msg( 'mypreferences' ),
|
|
|
|
href: config.links.preferences,
|
|
|
|
classes: [ 'mw-echo-ui-notificationBadgeButtonPopupWidget-footer-preferences' ]
|
|
|
|
} );
|
|
|
|
|
2015-09-09 20:18:52 +00:00
|
|
|
footerButtonGroupWidget = new OO.ui.ButtonGroupWidget( {
|
2016-03-18 00:00:05 +00:00
|
|
|
items: [ allNotificationsButton, preferencesButton ],
|
|
|
|
classes: [ 'mw-echo-ui-notificationBadgeButtonPopupWidget-footer-buttons' ]
|
2015-09-09 20:18:52 +00:00
|
|
|
} );
|
2015-08-13 00:54:16 +00:00
|
|
|
$footer = $( '<div>' )
|
|
|
|
.addClass( 'mw-echo-ui-notificationBadgeButtonPopupWidget-footer' )
|
2015-09-09 20:18:52 +00:00
|
|
|
.append( footerButtonGroupWidget.$element );
|
2015-09-17 00:05:52 +00:00
|
|
|
|
2016-03-18 00:00:05 +00:00
|
|
|
// Footer notice
|
|
|
|
initialNotifCount = mw.config.get( 'wgEchoInitialNotifCount' );
|
2016-04-10 13:31:02 +00:00
|
|
|
initialNotifCount = this.types === 'all' ?
|
|
|
|
( initialNotifCount.alert + initialNotifCount.message ) :
|
|
|
|
initialNotifCount[ this.type ];
|
|
|
|
|
2016-03-18 00:00:05 +00:00
|
|
|
if (
|
2016-04-26 01:33:01 +00:00
|
|
|
mw.config.get( 'wgEchoShowBetaInvitation' ) &&
|
|
|
|
!mw.user.options.get( 'echo-dismiss-beta-invitation' )
|
2016-03-18 00:00:05 +00:00
|
|
|
) {
|
|
|
|
notice = new mw.echo.ui.FooterNoticeWidget( {
|
|
|
|
// This is probably not the right way of doing this
|
|
|
|
iconUrl: mw.config.get( 'wgExtensionAssetsPath' ) + '/Echo/modules/icons/feedback.svg',
|
2016-04-10 13:31:02 +00:00
|
|
|
url: mw.util.getUrl( 'Special:Preferences' ) + '#mw-prefsection-beta-features'
|
2016-03-18 00:00:05 +00:00
|
|
|
} );
|
|
|
|
// Event
|
|
|
|
notice.connect( this, { dismiss: 'onFooterNoticeDismiss' } );
|
|
|
|
// Prepend to the footer
|
|
|
|
$footer.prepend( notice.$element );
|
|
|
|
}
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
this.popup = new OO.ui.PopupWidget( {
|
|
|
|
$content: this.notificationsWidget.$element,
|
|
|
|
$footer: $footer,
|
2016-01-13 03:36:47 +00:00
|
|
|
width: config.popupWidth || 500,
|
2015-09-17 00:05:52 +00:00
|
|
|
autoClose: true,
|
2015-10-16 23:18:25 +00:00
|
|
|
// Also ignore clicks from the nested action menu items, that
|
|
|
|
// actually exist in the overlay
|
|
|
|
$autoCloseIgnore: this.$element.add( this.$menuOverlay ),
|
2015-09-17 00:05:52 +00:00
|
|
|
head: true,
|
2015-09-10 22:17:11 +00:00
|
|
|
// The following messages can be used here:
|
2015-09-17 00:05:52 +00:00
|
|
|
// echo-notification-alert-text-only
|
2016-07-14 12:45:23 +00:00
|
|
|
// echo-notification-notice-text-only
|
2016-07-07 22:05:56 +00:00
|
|
|
label: mw.msg(
|
|
|
|
'echo-notification-' +
|
|
|
|
(
|
|
|
|
this.controller.getTypeString() === 'message' ?
|
|
|
|
'notice' :
|
|
|
|
this.controller.getTypeString()
|
|
|
|
) +
|
|
|
|
'-text-only'
|
|
|
|
),
|
2015-09-25 21:17:54 +00:00
|
|
|
classes: [ 'mw-echo-ui-notificationBadgeButtonPopupWidget-popup' ]
|
2015-09-17 00:05:52 +00:00
|
|
|
} );
|
2015-08-13 00:54:16 +00:00
|
|
|
// HACK: Add an icon to the popup head label
|
2015-09-03 21:24:03 +00:00
|
|
|
this.popupHeadIcon = new OO.ui.IconWidget();
|
|
|
|
this.popup.$head.prepend( this.popupHeadIcon.$element );
|
|
|
|
|
2015-09-10 22:24:21 +00:00
|
|
|
this.setPendingElement( this.popup.$head );
|
2015-09-17 00:05:52 +00:00
|
|
|
this.updateIcon( !!config.hasUnseen );
|
2015-09-10 22:24:21 +00:00
|
|
|
|
2015-08-13 00:54:16 +00:00
|
|
|
// Mark all as read button
|
|
|
|
this.markAllReadButton = new OO.ui.ButtonWidget( {
|
|
|
|
framed: false,
|
|
|
|
label: mw.msg( 'echo-mark-all-as-read' ),
|
|
|
|
classes: [ 'mw-echo-ui-notificationsWidget-markAllReadButton' ]
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Hide the close button
|
|
|
|
this.popup.closeButton.toggle( false );
|
|
|
|
// Add the 'mark all as read' button to the header
|
|
|
|
this.popup.$head.append( this.markAllReadButton.$element );
|
2015-09-28 20:21:37 +00:00
|
|
|
this.markAllReadButton.toggle( false );
|
2015-08-13 00:54:16 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.markAllReadButton.connect( this, { click: 'onMarkAllReadButtonClick' } );
|
2016-04-10 13:31:02 +00:00
|
|
|
this.manager.connect( this, {
|
2016-07-08 22:56:01 +00:00
|
|
|
update: 'updateBadge'
|
2015-08-13 00:54:16 +00:00
|
|
|
} );
|
2016-07-08 22:56:01 +00:00
|
|
|
this.manager.getSeenTimeModel().connect( this, { update: 'onSeenTimeModelUpdate' } );
|
2016-04-10 13:31:02 +00:00
|
|
|
this.manager.getUnreadCounter().connect( this, { countChange: 'updateBadge' } );
|
2015-09-08 00:11:31 +00:00
|
|
|
this.popup.connect( this, { toggle: 'onPopupToggle' } );
|
2015-09-17 00:05:52 +00:00
|
|
|
this.badgeButton.connect( this, {
|
|
|
|
click: 'onBadgeButtonClick'
|
|
|
|
} );
|
2015-08-13 00:54:16 +00:00
|
|
|
|
|
|
|
this.$element
|
2016-07-21 18:19:17 +00:00
|
|
|
.prop( 'id', 'pt-notifications-' + (
|
|
|
|
this.controller.getTypeString() === 'message' ? 'notice' : 'alert'
|
|
|
|
) )
|
2015-09-17 00:05:52 +00:00
|
|
|
// The following classes can be used here:
|
|
|
|
// mw-echo-ui-notificationBadgeButtonPopupWidget-alert
|
|
|
|
// mw-echo-ui-notificationBadgeButtonPopupWidget-message
|
2015-08-13 00:54:16 +00:00
|
|
|
.addClass(
|
|
|
|
'mw-echo-ui-notificationBadgeButtonPopupWidget ' +
|
2016-07-21 18:19:17 +00:00
|
|
|
'mw-echo-ui-notificationBadgeButtonPopupWidget-' + (
|
|
|
|
this.controller.getTypeString() === 'message' ? 'notice' : 'alert'
|
|
|
|
)
|
2015-09-17 00:05:52 +00:00
|
|
|
)
|
|
|
|
.append(
|
|
|
|
this.badgeButton.$element,
|
|
|
|
this.popup.$element
|
2015-08-13 00:54:16 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
OO.inheritClass( mw.echo.ui.NotificationBadgeWidget, OO.ui.Widget );
|
2015-08-13 00:54:16 +00:00
|
|
|
OO.mixinClass( mw.echo.ui.NotificationBadgeWidget, OO.ui.mixin.PendingElement );
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
/* Static properties */
|
|
|
|
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.static.tagName = 'li';
|
|
|
|
|
2015-09-17 20:47:23 +00:00
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @event allRead
|
|
|
|
* All notifications were marked as read
|
|
|
|
*/
|
|
|
|
|
2016-01-15 22:11:33 +00:00
|
|
|
/**
|
|
|
|
* @event finishLoading
|
|
|
|
* Notifications have successfully finished being processed and are fully loaded
|
|
|
|
*/
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
/* Methods */
|
|
|
|
|
2016-03-18 00:00:05 +00:00
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.onFooterNoticeDismiss = function () {
|
|
|
|
// Clip again to recalculate height
|
|
|
|
this.popup.clip();
|
|
|
|
|
|
|
|
// Save the preference in general
|
2016-04-26 01:33:01 +00:00
|
|
|
new mw.Api().saveOption( 'echo-dismiss-beta-invitation', 1 );
|
2016-03-18 00:00:05 +00:00
|
|
|
// Save the preference for this session
|
2016-04-26 01:33:01 +00:00
|
|
|
mw.user.options.set( 'echo-dismiss-beta-invitation', 1 );
|
2016-03-18 00:00:05 +00:00
|
|
|
};
|
|
|
|
|
2015-09-17 00:05:52 +00:00
|
|
|
/**
|
|
|
|
* Respond to badge button click
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.onBadgeButtonClick = function () {
|
2015-09-30 00:02:48 +00:00
|
|
|
this.popup.toggle();
|
2015-09-17 00:05:52 +00:00
|
|
|
};
|
|
|
|
|
2015-09-03 21:24:03 +00:00
|
|
|
/**
|
|
|
|
* Update the badge icon with the read/unread versions if they exist.
|
|
|
|
*
|
|
|
|
* @param {boolean} hasUnseen Widget has unseen notifications
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.updateIcon = function ( hasUnseen ) {
|
|
|
|
var icon = typeof this.badgeIcon === 'string' ?
|
|
|
|
this.badgeIcon :
|
|
|
|
this.badgeIcon[ hasUnseen ? 'unseen' : 'seen' ];
|
2015-09-17 00:05:52 +00:00
|
|
|
|
|
|
|
this.badgeButton.setIcon( icon );
|
2015-09-03 21:24:03 +00:00
|
|
|
this.popupHeadIcon.setIcon( icon );
|
|
|
|
};
|
|
|
|
|
2016-03-09 04:50:31 +00:00
|
|
|
// Client-side version of NotificationController::getCappedNotificationCount.
|
|
|
|
/**
|
|
|
|
* Gets the count to use for display
|
|
|
|
*
|
|
|
|
* @param {number} count Count before cap is applied
|
|
|
|
*
|
|
|
|
* @return {number} Count with cap applied
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.getCappedNotificationCount = function ( count ) {
|
|
|
|
if ( count <= this.maxNotificationCount ) {
|
|
|
|
return count;
|
|
|
|
} else {
|
|
|
|
return this.maxNotificationCount + 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-08 22:56:01 +00:00
|
|
|
/**
|
|
|
|
* Respond to SeenTime model update event
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.onSeenTimeModelUpdate = function () {
|
|
|
|
this.updateBadgeSeenState( this.manager.hasUnseenInSource( 'local' ) );
|
|
|
|
};
|
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
/**
|
|
|
|
* Update the badge style to match whether it contains unseen notifications.
|
|
|
|
*
|
|
|
|
* @param {boolean} hasUnseen There are unseen notifications
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.updateBadgeSeenState = function ( hasUnseen ) {
|
2016-07-08 22:56:01 +00:00
|
|
|
hasUnseen = hasUnseen === undefined ? this.manager.hasUnseenInSource( 'local' ) : !!hasUnseen;
|
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
this.badgeButton.setFlags( { unseen: !!hasUnseen } );
|
|
|
|
this.updateIcon( !!hasUnseen );
|
|
|
|
};
|
|
|
|
|
2015-08-13 00:54:16 +00:00
|
|
|
/**
|
|
|
|
* Update the badge state and label based on changes to the model
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.updateBadge = function () {
|
2016-06-10 13:06:04 +00:00
|
|
|
var unreadCount, cappedUnreadCount, badgeLabel;
|
2015-09-23 00:04:14 +00:00
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
unreadCount = this.manager.getUnreadCounter().getCount();
|
2016-03-15 21:13:19 +00:00
|
|
|
cappedUnreadCount = this.getCappedNotificationCount( unreadCount );
|
|
|
|
cappedUnreadCount = mw.language.convertNumber( cappedUnreadCount );
|
|
|
|
badgeLabel = mw.message( 'echo-badge-count', cappedUnreadCount ).text();
|
|
|
|
this.badgeButton.setLabel( badgeLabel );
|
2015-09-08 20:46:57 +00:00
|
|
|
|
2016-04-10 13:31:02 +00:00
|
|
|
// Update seen state only if the counter is 0
|
|
|
|
// so we don't run into inconsistencies and have an unseen state
|
|
|
|
// for the badge with 0 unread notifications
|
|
|
|
if ( unreadCount === 0 ) {
|
|
|
|
this.updateBadgeSeenState( false );
|
|
|
|
}
|
|
|
|
|
2015-09-08 20:46:57 +00:00
|
|
|
// Check if we need to display the 'mark all unread' button
|
2016-06-10 13:06:04 +00:00
|
|
|
this.markAllReadButton.toggle( this.manager.hasLocalUnread() );
|
2015-08-13 00:54:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to 'mark all as read' button click
|
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.onMarkAllReadButtonClick = function () {
|
2016-06-07 20:08:16 +00:00
|
|
|
this.controller.markLocalNotificationsRead();
|
2015-08-13 00:54:16 +00:00
|
|
|
};
|
|
|
|
|
2015-09-15 06:13:51 +00:00
|
|
|
/**
|
|
|
|
* Extend the response to button click so we can also update the notification list.
|
2016-03-07 13:29:15 +00:00
|
|
|
*
|
2016-01-15 22:11:33 +00:00
|
|
|
* @fires finishLoading
|
2015-09-15 06:13:51 +00:00
|
|
|
*/
|
|
|
|
mw.echo.ui.NotificationBadgeWidget.prototype.onPopupToggle = function ( isVisible ) {
|
2015-09-24 21:23:23 +00:00
|
|
|
var widget = this;
|
|
|
|
|
2016-01-15 22:11:33 +00:00
|
|
|
if ( this.promiseRunning ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-15 06:13:51 +00:00
|
|
|
if ( !isVisible ) {
|
2016-04-10 13:31:02 +00:00
|
|
|
widget.notificationsWidget.resetInitiallyUnseenItems();
|
2015-09-15 06:13:51 +00:00
|
|
|
return;
|
2015-08-13 00:54:16 +00:00
|
|
|
}
|
2015-09-15 06:13:51 +00:00
|
|
|
|
|
|
|
// Log the click event
|
|
|
|
mw.echo.logger.logInteraction(
|
|
|
|
'ui-badge-link-click',
|
2015-10-08 22:20:31 +00:00
|
|
|
mw.echo.Logger.static.context.badge,
|
2015-09-15 06:13:51 +00:00
|
|
|
null,
|
2016-04-10 13:31:02 +00:00
|
|
|
this.controller.getTypeString()
|
2015-09-15 06:13:51 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if ( this.hasRunFirstTime ) {
|
|
|
|
// HACK: Clippable doesn't resize the clippable area when
|
|
|
|
// it calculates the new size. Since the popup contents changed
|
|
|
|
// and the popup is "empty" now, we need to manually set its
|
|
|
|
// size to 1px so the clip calculations will resize it properly.
|
|
|
|
// See bug report: https://phabricator.wikimedia.org/T110759
|
|
|
|
this.popup.$clippable.css( 'height', '1px' );
|
|
|
|
this.popup.clip();
|
|
|
|
}
|
2016-01-15 22:11:33 +00:00
|
|
|
|
|
|
|
this.pushPending();
|
|
|
|
this.markAllReadButton.toggle( false );
|
|
|
|
this.promiseRunning = true;
|
2016-04-10 13:31:02 +00:00
|
|
|
|
2015-09-16 20:42:17 +00:00
|
|
|
// Always populate on popup open. The model and widget should handle
|
|
|
|
// the case where the promise is already underway.
|
2016-04-10 13:31:02 +00:00
|
|
|
this.controller.fetchLocalNotifications( this.hasRunFirstTime )
|
|
|
|
.then(
|
|
|
|
// Success
|
|
|
|
function () {
|
|
|
|
if ( widget.popup.isVisible() ) {
|
|
|
|
widget.popup.clip();
|
|
|
|
// Update seen time
|
|
|
|
return widget.controller.updateLocalSeenTime();
|
2015-09-30 18:42:53 +00:00
|
|
|
}
|
2016-04-10 13:31:02 +00:00
|
|
|
},
|
|
|
|
// Failure
|
2016-05-29 20:49:48 +00:00
|
|
|
function () {
|
|
|
|
widget.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) );
|
2015-09-24 21:23:23 +00:00
|
|
|
}
|
2016-04-10 13:31:02 +00:00
|
|
|
)
|
|
|
|
.then( this.emit.bind( this, 'finishLoading' ) )
|
2016-01-15 22:11:33 +00:00
|
|
|
.always( function () {
|
|
|
|
// Pop pending
|
|
|
|
widget.popPending();
|
|
|
|
widget.promiseRunning = false;
|
2015-09-24 21:23:23 +00:00
|
|
|
} );
|
2015-09-16 20:42:17 +00:00
|
|
|
this.hasRunFirstTime = true;
|
2015-08-13 00:54:16 +00:00
|
|
|
};
|
|
|
|
} )( mediaWiki, jQuery );
|