Undo tooltip: position when shown, not when created

Especially on Special:CX, where page layout changes soon after load
(for example scrollbars get added when more content loads), the tooltip
would be positioned incorrectly. Now it is more likely to be positioned
correctly, and will get re-positioned again if it is shown again after
being hidden.

Bug: T145483
Change-Id: I527fc62b196e55101950cffcc6ec43926f63aa4a
This commit is contained in:
Niklas Laxström
2016-09-15 09:37:11 +02:00
committed by Nikerabbit
parent 91e4a564d4
commit 41f9a6f994

View File

@@ -196,7 +196,7 @@
* It also allows to undo the language selection.
*/
function showUndoTooltip( previousLang, previousAutonym ) {
var $ulsTrigger, ulsPopup, offset,
var $ulsTrigger, ulsPopup,
ulsPosition = mw.config.get( 'wgULSPosition' );
$ulsTrigger = ( ulsPosition === 'interlanguage' ) ?
@@ -208,7 +208,14 @@
}
function showTipsy( timeout ) {
var tipsyTimer = 0;
var offset, tipsyTimer = 0;
// Position popup
offset = $ulsTrigger.offset();
ulsPopup.$element.css( {
top: offset.top + 24,
left: offset.left + $ulsTrigger.outerWidth() / 2
} );
ulsPopup.toggle( true );
ulsPopup.toggleClipping( false );
@@ -276,12 +283,7 @@
}() )
} );
// Position popup
offset = $ulsTrigger.offset();
ulsPopup.$element.css( {
top: offset.top + 24,
left: offset.left + $ulsTrigger.outerWidth() / 2
} ).appendTo( 'body' );
ulsPopup.$element.appendTo( 'body' );
// The interlanguage position needs some time to settle down
window.setTimeout( function () {