From a46fb8ac83a639e34e9c8a78a042e032d79a2ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 21 Dec 2013 14:24:29 +0100 Subject: [PATCH] Make sure the overlay is visible, even if the badge is near the edge We just shift it a bit to fit it on the screen. Bug: 58728 Change-Id: I61847ed7b9f08ce6618a903bb4f5e0d6afb07e9b --- modules/overlay/ext.echo.overlay.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/overlay/ext.echo.overlay.js b/modules/overlay/ext.echo.overlay.js index 6b462233a..fd4ac2002 100644 --- a/modules/overlay/ext.echo.overlay.js +++ b/modules/overlay/ext.echo.overlay.js @@ -301,6 +301,19 @@ // 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 ) ) ); + } } ); } );