mediawiki-skins-Insurgency/resources/mobile-echo.js
Ed Sanders 7712f1bf22 build: Update eslint-config-wikimedia to 0.10.0
Change-Id: I58983b156eab7090c245ad6febfa47f1552c7188
2019-01-14 21:00:07 +00:00

56 lines
1.7 KiB
JavaScript

/* eslint-disable jquery/no-global-selector */
$( function () {
var mobileCutoffWidth = 550,
notificationIcons = $( '#pt-notifications-alert, #pt-notifications-notice' ),
echoHacked = false,
echoHackActive = false,
notifications = $( '#pt-notifications-alert a' ).data( 'counter-num' ) + $( '#pt-notifications-notice a' ).data( 'counter-num' ),
notificationsString;
// Move echo badges in/out of p-personal
function monoBookMobileMoveEchoIcons() {
if ( notificationIcons.length ) {
if ( !echoHackActive && $( window ).width() <= mobileCutoffWidth ) {
$( '#echo-hack-badges' ).append( notificationIcons );
echoHackActive = true;
} else if ( echoHackActive && $( window ).width() > mobileCutoffWidth ) {
$( notificationIcons ).insertBefore( '#pt-mytalk' );
echoHackActive = false;
}
}
}
function monoBookMobileEchoHack() {
if ( notificationIcons.length ) {
if ( !echoHacked && $( window ).width() <= mobileCutoffWidth ) {
if ( notifications ) {
notificationsString = mw.msg( 'monobook-notifications-link', notifications );
} else {
notificationsString = mw.msg( 'monobook-notifications-link-none' );
}
// add inline p-personal echo link
mw.util.addPortletLink(
'p-personal',
mw.util.getUrl( 'Special:Notifications' ),
notificationsString,
'pt-notifications',
$( '#pt-notifications-notice' ).attr( 'tooltip' ),
null,
'#pt-preferences'
);
$( '#p-personal-toggle' ).append( $( '<ul>' ).attr( 'id', 'echo-hack-badges' ) );
echoHacked = true;
}
monoBookMobileMoveEchoIcons();
}
}
$( window ).on( 'resize', monoBookMobileEchoHack );
monoBookMobileEchoHack();
} );