RTL positioning for compact interlanguage links
Bug: 62981 Change-Id: If68975431eb58a7fcafcb7fec9f8a95f5e09ad80
This commit is contained in:
committed by
Santhosh Thottingal
parent
d4c2053fc0
commit
2ac455bd2a
@@ -90,9 +90,10 @@
|
|||||||
*/
|
*/
|
||||||
listen: function () {
|
listen: function () {
|
||||||
var languages,
|
var languages,
|
||||||
ulsTop, ulsLeft,
|
|
||||||
compactLinks = this,
|
compactLinks = this,
|
||||||
triggerPosition = compactLinks.$trigger.offset(),
|
dir = $( 'html' ).prop( 'dir' ),
|
||||||
|
interlanguageListLeft,
|
||||||
|
interlanguageListWidth,
|
||||||
ulsLanguageList = {};
|
ulsLanguageList = {};
|
||||||
|
|
||||||
languages = $.map( compactLinks.interlanguageList, function ( language, languageCode ) {
|
languages = $.map( compactLinks.interlanguageList, function ( language, languageCode ) {
|
||||||
@@ -101,9 +102,9 @@
|
|||||||
return languageCode;
|
return languageCode;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
ulsTop = triggerPosition.top - compactLinks.$trigger.height() / 2 - 250 + 'px';
|
// Calculate the left and width values
|
||||||
ulsLeft = triggerPosition.left + compactLinks.$trigger.width() + compactLinks.$interlanguageList.width() + 'px';
|
interlanguageListLeft = compactLinks.$interlanguageList.offset().left;
|
||||||
|
interlanguageListWidth = compactLinks.$interlanguageList.width();
|
||||||
// Attach ULS to the trigger
|
// Attach ULS to the trigger
|
||||||
compactLinks.$trigger.uls( {
|
compactLinks.$trigger.uls( {
|
||||||
onReady: function () {
|
onReady: function () {
|
||||||
@@ -121,13 +122,21 @@
|
|||||||
mw.uls.setPreviousLanguages( previousLanguages );
|
mw.uls.setPreviousLanguages( previousLanguages );
|
||||||
window.location.href = compactLinks.interlanguageList[ language ].href;
|
window.location.href = compactLinks.interlanguageList[ language ].href;
|
||||||
},
|
},
|
||||||
|
onVisible: function () {
|
||||||
|
// Calculate the positioning of the panel
|
||||||
|
// according to the position of the trigger icon
|
||||||
|
if ( dir === 'rtl' ) {
|
||||||
|
this.left = interlanguageListLeft - this.$menu.width();
|
||||||
|
} else {
|
||||||
|
this.left = interlanguageListLeft + interlanguageListWidth;
|
||||||
|
}
|
||||||
|
this.$menu.css( 'left', this.left );
|
||||||
|
},
|
||||||
// Use compact version of ULS
|
// Use compact version of ULS
|
||||||
compact: true,
|
compact: true,
|
||||||
// Left position of the language selector
|
|
||||||
left: ulsLeft,
|
|
||||||
// Top position of the language selector. Top it 250px above to take care of
|
// Top position of the language selector. Top it 250px above to take care of
|
||||||
// caret pointing the trigger. See .interlanguage-uls-menu:after style definition
|
// caret pointing the trigger. See .interlanguage-uls-menu:after style definition
|
||||||
top: ulsTop,
|
top: compactLinks.$trigger.offset().top - compactLinks.$trigger.height() / 2 - 250,
|
||||||
// List of languages to be shown
|
// List of languages to be shown
|
||||||
languages: ulsLanguageList,
|
languages: ulsLanguageList,
|
||||||
// Show common languages
|
// Show common languages
|
||||||
|
|||||||
Reference in New Issue
Block a user