Align page language selector in multilingual wikis

Align page language selector in multilingual wikis with the trigger button.

Bug: T314021
Change-Id: I68e3c55662d027a079c5204def04cdac0b105667
This commit is contained in:
NikG
2023-03-28 18:55:52 +03:00
committed by Santhosh
parent b3e15a7132
commit fcba642756

View File

@@ -504,6 +504,35 @@
quickList: function () {
return mw.uls.getFrequentLanguageList();
},
// partially copied from ext.uls.lauch
onPosition: function () {
// Default positioning of jquery.uls is middle of the screen under
// the trigger. This code aligns it under the trigger and to the
// trigger edge depending on which side of the page the trigger is
// It should work automatically both LTR and RTL.
var offset, height, width, positionCSS;
offset = $trigger.offset();
width = $trigger.outerWidth();
height = $trigger.outerHeight();
if ( offset.left + ( width / 2 ) > $( window ).width() / 2 ) {
// Midpoint of the trigger is on the right side of the viewport.
positionCSS = {
// Right dialog edge aligns with right edge of the trigger.
right: $( window ).width() - ( offset.left + width ),
top: offset.top + height
};
} else {
// Midpoint of the trigger is on the left side of the viewport.
positionCSS = {
// Left dialog edge aligns with left edge of the trigger.
left: offset.left,
top: offset.top + height
};
}
return positionCSS;
},
onReady: function () {
loadDisplayAndInputSettings( this );
},