mediawiki-skins-Insurgency/resources/mobile-echo.js
Isarra ca53e721ab Mobile - reorganise and clean up p-personal js dropdown
* Reorder ULS and Echo links
* Rename conditional module load hook to be more generic, and add
  ULS module
* Remove .active bolding from dropdown

Change-Id: I7e746e7c5af8ffd7c4ca06742ab1fe6bc94ba531
2018-05-20 10:29:50 +00:00

57 lines
1.7 KiB
JavaScript

( function ( mw, $ ) {
$( function () {
var mobileCutoffWidth = 850,
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 ).resize( monoBookMobileEchoHack );
monoBookMobileEchoHack();
} );
}( mediaWiki, jQuery ) );