' )
.attr( 'id', 'mw-echo-overlay-footer' );
// add link to notifications archive
$overlayFooter.append(
$( '
' )
.html( $prefLink.html() )
.attr( 'id', 'mw-echo-overlay-pref-link' )
.addClass( 'mw-echo-grey-link' )
.attr( 'href', $prefLink.attr( 'href' ) + '#mw-prefsection-echo' )
.click( function () {
mw.echo.logInteraction( 'ui-prefs-click', 'flyout' );
} )
.hover(
function() {
$( this ).removeClass( 'mw-echo-grey-link' );
},
function() {
$( this ).addClass( 'mw-echo-grey-link' );
}
)
);
$overlay.append( $overlayFooter );
callback( $overlay );
// only need to mark as read if there is unread item
if ( unread.length > 0 ) {
api.post( mw.echo.desktop.appendUseLang( {
'action' : 'echomarkread',
'list' : unread.join( '|' ),
'token': mw.user.tokens.get( 'editToken' )
} ) ).done( function ( result ) {
if ( result.query.echomarkread.count !== undefined ) {
count = result.query.echomarkread.count;
mw.echo.overlay.updateCount( count, result.query.echomarkread.rawcount );
}
} );
}
} ).fail( function () {
window.location.href = $( '#pt-notifications a' ).attr( 'href' );
} );
}
};
$( function () {
var $link = $( '#pt-notifications a' );
if ( ! $link.length ) {
return;
}
$link.click( function ( e ) {
var $target;
// log the badge click
mw.echo.logInteraction( 'ui-badge-link-click' );
// If the link is not near the top of the window, showing the overlay below it
// will likely look very silly, so let's not do this and just go the special page
if ( $link.offset().top > 0.2 * $( window ).height() ) {
return;
}
e.preventDefault();
$target = $( e.target );
// If the user clicked on the overlay or any child, ignore the click
if ( $target.hasClass( 'mw-echo-overlay' ) || $target.is( '.mw-echo-overlay *' ) ) {
return;
}
if ( $( '.mw-echo-overlay' ).length ) {
mw.echo.overlay.removeOverlay();
return;
}
mw.echo.overlay.buildOverlay(
function ( $overlay ) {
$overlay
.hide()
.appendTo( $( '#pt-notifications' ) );
// Create the pokey (aka chevron)
$overlay.before( $( '' ).addClass( 'mw-echo-overlay-pokey' ) );
mw.hook( 'ext.echo.overlay.beforeShowingOverlay' ).fire( $overlay );
// Show the notifications overlay
$overlay.show();
// Make sure the overlay is visible, even if the badge is near the edge of browser window.
// 10 is an arbitrarily chosen "close enough" number.
// We are careful not to slide out from below the pokey (which is 21px wide) (200-21/2+1 == 189)
var
offset = $overlay.offset(),
width = $overlay.width(),
windowWidth = $( window ).width();
if ( offset.left < 10 ) {
$overlay.css( 'left', '+=' + Math.min( 189, 10 - offset.left ) );
} else if ( offset.left + width > windowWidth - 10 ) {
$overlay.css( 'left', '-=' + Math.min( 189, ( offset.left + width ) - ( windowWidth - 10 ) ) );
}
}
);
} );
$( 'body' ).click( function ( e ) {
if ( ! $( e.target ).is( '.mw-echo-overlay, .mw-echo-overlay *, .mw-echo-overlay-pokey, #pt-notifications a' ) ) {
mw.echo.overlay.removeOverlay();
}
} );
// Closes the notifications overlay when ESC key pressed
$( document ).on( 'keydown', function ( e ) {
if ( e.which === 27 ) {
mw.echo.overlay.removeOverlay();
}
} );
} );
} )( jQuery, mediaWiki );