mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
0eb5d53375
Bug: T112254 Change-Id: Id468763ac2f678dde0794ff401147e8be834ce0c
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
( function ( mw, $ ) {
|
|
'use strict';
|
|
|
|
if ( mw.echo.Logger.static.clickThroughEnabled ) {
|
|
mw.loader.using( 'ext.eventLogging', function () {
|
|
mw.eventLog.setDefaults( 'EchoInteraction', {
|
|
version: mw.config.get( 'wgEchoConfig' ).version,
|
|
userId: +mw.config.get( 'wgUserId' ),
|
|
editCount: +mw.config.get( 'wgUserEditCount' )
|
|
} );
|
|
} );
|
|
}
|
|
|
|
// Activate ooui
|
|
$( document ).ready( function () {
|
|
var $existingAlertLink = $( '#pt-notifications-alert a' ),
|
|
$existingMessageLink = $( '#pt-notifications-message a' ),
|
|
numAlerts = $existingAlertLink.text(),
|
|
numMessages = $existingMessageLink.text(),
|
|
hasUnseenAlerts = $existingAlertLink.hasClass( 'mw-echo-unseen-notifications' ),
|
|
hasUnseenMessages = $existingMessageLink.hasClass( 'mw-echo-unseen-notifications' ),
|
|
// Store links
|
|
links = {
|
|
notifications: $( '#pt-notifications-alert a' ).attr( 'href' ),
|
|
preferences: $( '#pt-preferences a' ).attr( 'href' ) + '#mw-prefsection-echo'
|
|
};
|
|
|
|
if ( $existingMessageLink.length ) {
|
|
mw.echo.ui.messageWidget = new mw.echo.ui.NotificationBadgeWidget( {
|
|
type: 'message',
|
|
markReadWhenSeen: false,
|
|
numItems: numMessages,
|
|
hasUnseen: hasUnseenMessages,
|
|
badgeIcon: 'speechBubble',
|
|
links: links
|
|
} );
|
|
// avoid late debouncedUpdateThemeClasses
|
|
mw.echo.ui.messageWidget.debouncedUpdateThemeClasses();
|
|
$existingMessageLink.replaceWith( mw.echo.ui.messageWidget.$element );
|
|
}
|
|
|
|
mw.echo.ui.alertWidget = new mw.echo.ui.NotificationBadgeWidget( {
|
|
type: 'alert',
|
|
markReadWhenSeen: true,
|
|
numItems: numAlerts,
|
|
hasUnseen: hasUnseenAlerts,
|
|
badgeIcon: {
|
|
seen: 'bell',
|
|
unseen: 'bellOn'
|
|
},
|
|
links: links
|
|
} );
|
|
|
|
// avoid late debouncedUpdateThemeClasses
|
|
mw.echo.ui.alertWidget.debouncedUpdateThemeClasses();
|
|
$existingAlertLink.replaceWith( mw.echo.ui.alertWidget.$element );
|
|
} );
|
|
|
|
} )( mediaWiki, jQuery );
|