summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/UniversalLanguageSelector/resources')
-rw-r--r--MLEB/UniversalLanguageSelector/resources/css/ext.uls-vector.less2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/css/ext.uls.compactlinks.less6
-rw-r--r--MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-default.less16
-rw-r--r--MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-vector.less9
-rw-r--r--MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt.less16
-rw-r--r--MLEB/UniversalLanguageSelector/resources/images/back-grey-ltr.svg2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/images/close.svg4
-rw-r--r--MLEB/UniversalLanguageSelector/resources/images/language-base20.svg2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/images/remove-input.svg2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/js/ext.uls.displaysettings.js2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/js/ext.uls.interface.js315
-rw-r--r--MLEB/UniversalLanguageSelector/resources/js/ext.uls.launch.js9
-rw-r--r--MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.js2
-rw-r--r--MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.repository.js54
14 files changed, 254 insertions, 187 deletions
diff --git a/MLEB/UniversalLanguageSelector/resources/css/ext.uls-vector.less b/MLEB/UniversalLanguageSelector/resources/css/ext.uls-vector.less
index 6dca27d3..da149ecf 100644
--- a/MLEB/UniversalLanguageSelector/resources/css/ext.uls-vector.less
+++ b/MLEB/UniversalLanguageSelector/resources/css/ext.uls-vector.less
@@ -5,7 +5,7 @@
.skin-vector {
.uls-menu {
border-color: #c8ccd1;
- .box-shadow( 0 2px 2px 0 rgba( 0, 0, 0, 0.25 ) );
+ box-shadow: 0 2px 2px 0 rgba( 0, 0, 0, 0.25 );
// Not inherited from `.mw-body-content`, as we insert at `body`.
font-size: 0.875em;
}
diff --git a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.compactlinks.less b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.compactlinks.less
index 03c80242..01f3f47c 100644
--- a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.compactlinks.less
+++ b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.compactlinks.less
@@ -7,10 +7,9 @@
background-image: none;
padding: 0;
}
-/* stylelint-enable selector-max-id */
-.mw-interlanguage-selector,
-.mw-interlanguage-selector:active {
+#p-lang .mw-interlanguage-selector,
+#p-lang .mw-interlanguage-selector:active {
background-image: url( ../images/language-base20.svg );
background-position: left 4px center;
background-repeat: no-repeat;
@@ -22,6 +21,7 @@
text-align: left;
cursor: pointer;
}
+/* stylelint-enable selector-max-id */
.mw-interlanguage-selector.selector-open {
background-color: #c8ccd1;
diff --git a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-default.less b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-default.less
new file mode 100644
index 00000000..31f646fe
--- /dev/null
+++ b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-default.less
@@ -0,0 +1,16 @@
+/* stylelint-disable selector-max-id */
+/* Opera for some inexplicable reason confuses right and left padding with */
+/* RTL text direction here (bug T47142). x:-o-prefocus won't match anything, */
+/* but will make other browsers ignore this rule. */
+/* stylelint-disable selector-type-no-unknown */
+x:-o-prefocus,
+body.rtl li#pt-uls {
+ /* @noflip */
+ direction: ltr;
+}
+/* stylelint-enable selector-type-no-unknown */
+
+/* Don't show it to users who disabled JS */
+.client-nojs #pt-uls {
+ display: none;
+}
diff --git a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-vector.less b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-vector.less
new file mode 100644
index 00000000..3ad507d0
--- /dev/null
+++ b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt-vector.less
@@ -0,0 +1,9 @@
+// Resets the background set in jquery.uls for Modern Vector
+.vector-user-links .uls-trigger {
+ background: none;
+}
+
+// Applies old styling rules to legacy Vector
+.skin-vector-legacy {
+ @import 'ext.uls.pt.less';
+}
diff --git a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt.less b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt.less
index 51202e02..af73f0ee 100644
--- a/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt.less
+++ b/MLEB/UniversalLanguageSelector/resources/css/ext.uls.pt.less
@@ -52,19 +52,3 @@
}
}
}
-
-/* Opera for some inexplicable reason confuses right and left padding with */
-/* RTL text direction here (bug T47142). x:-o-prefocus won't match anything, */
-/* but will make other browsers ignore this rule. */
-/* stylelint-disable selector-type-no-unknown */
-x:-o-prefocus,
-body.rtl li#pt-uls {
- /* @noflip */
- direction: ltr;
-}
-/* stylelint-enable selector-type-no-unknown */
-
-/* Don't show it to users who disabled JS */
-.client-nojs #pt-uls {
- display: none;
-}
diff --git a/MLEB/UniversalLanguageSelector/resources/images/back-grey-ltr.svg b/MLEB/UniversalLanguageSelector/resources/images/back-grey-ltr.svg
index adcad48c..49a86d66 100644
--- a/MLEB/UniversalLanguageSelector/resources/images/back-grey-ltr.svg
+++ b/MLEB/UniversalLanguageSelector/resources/images/back-grey-ltr.svg
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
- <path fill="#54595d" d="M7 13.1l8.9 8.9c.8-.8.8-2 0-2.8l-6.1-6.1 6-6.1c.8-.8.8-2 0-2.8L7 13.1z"/>
+ <path fill="#54595d" d="m7 13.1 8.9 8.9c.8-.8.8-2 0-2.8l-6.1-6.1 6-6.1c.8-.8.8-2 0-2.8L7 13.1z"/>
</svg>
diff --git a/MLEB/UniversalLanguageSelector/resources/images/close.svg b/MLEB/UniversalLanguageSelector/resources/images/close.svg
index 22619b95..57c8603a 100644
--- a/MLEB/UniversalLanguageSelector/resources/images/close.svg
+++ b/MLEB/UniversalLanguageSelector/resources/images/close.svg
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
- <path d="M3.636 2.222l14.142 14.142-1.414 1.414L2.222 3.636z"/>
- <path d="M17.778 3.636L3.636 17.778l-1.414-1.414L16.364 2.222z"/>
+ <path d="m3.636 2.222 14.142 14.142-1.414 1.414L2.222 3.636z"/>
+ <path d="M17.778 3.636 3.636 17.778l-1.414-1.414L16.364 2.222z"/>
</svg>
diff --git a/MLEB/UniversalLanguageSelector/resources/images/language-base20.svg b/MLEB/UniversalLanguageSelector/resources/images/language-base20.svg
index 4567fbba..007c96ac 100644
--- a/MLEB/UniversalLanguageSelector/resources/images/language-base20.svg
+++ b/MLEB/UniversalLanguageSelector/resources/images/language-base20.svg
@@ -3,5 +3,5 @@
<title>
language
</title>
- <path fill="#54595d" d="M20 18h-1.44a.61.61 0 01-.4-.12.81.81 0 01-.23-.31L17 15h-5l-1 2.54a.77.77 0 01-.22.3.59.59 0 01-.4.14H9l4.55-11.47h1.89zm-3.53-4.31L14.89 9.5a11.62 11.62 0 01-.39-1.24q-.09.37-.19.69l-.19.56-1.58 4.19zm-6.3-1.58a13.43 13.43 0 01-2.91-1.41 11.46 11.46 0 002.81-5.37H12V4H7.31a4 4 0 00-.2-.56C6.87 2.79 6.6 2 6.6 2l-1.47.5s.4.89.6 1.5H0v1.33h2.15A11.23 11.23 0 005 10.7a17.19 17.19 0 01-5 2.1q.56.82.87 1.38a23.28 23.28 0 005.22-2.51 15.64 15.64 0 003.56 1.77zM3.63 5.33h4.91a8.11 8.11 0 01-2.45 4.45 9.11 9.11 0 01-2.46-4.45z"/>
+ <path fill="#54595d" d="M20 18h-1.44a.61.61 0 0 1-.4-.12.81.81 0 0 1-.23-.31L17 15h-5l-1 2.54a.77.77 0 0 1-.22.3.59.59 0 0 1-.4.14H9l4.55-11.47h1.89zm-3.53-4.31L14.89 9.5a11.62 11.62 0 0 1-.39-1.24q-.09.37-.19.69l-.19.56-1.58 4.19zm-6.3-1.58a13.43 13.43 0 0 1-2.91-1.41 11.46 11.46 0 0 0 2.81-5.37H12V4H7.31a4 4 0 0 0-.2-.56C6.87 2.79 6.6 2 6.6 2l-1.47.5s.4.89.6 1.5H0v1.33h2.15A11.23 11.23 0 0 0 5 10.7a17.19 17.19 0 0 1-5 2.1q.56.82.87 1.38a23.28 23.28 0 0 0 5.22-2.51 15.64 15.64 0 0 0 3.56 1.77zM3.63 5.33h4.91a8.11 8.11 0 0 1-2.45 4.45 9.11 9.11 0 0 1-2.46-4.45z"/>
</svg>
diff --git a/MLEB/UniversalLanguageSelector/resources/images/remove-input.svg b/MLEB/UniversalLanguageSelector/resources/images/remove-input.svg
index 09b98974..cb6ce8cf 100644
--- a/MLEB/UniversalLanguageSelector/resources/images/remove-input.svg
+++ b/MLEB/UniversalLanguageSelector/resources/images/remove-input.svg
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="0 0 20 16">
<path fill="#202122" d="M9.2.825c-.1.207-.148.479-.4.55-.44.065-.906.015-1.35 0-.693-.025-1.387-.118-2.076 0-.47.126-.762.582-.95 1A4.323 4.323 0 0 0 4.149 3.4h-2.15v9.2h16V3.4H4.922c.087-.416.163-.846.45-1.175.178-.185.47-.136.7-.15.97.002 1.933.143 2.9.05.371-.047.65-.364.776-.7l.15-.35-.7-.251zM3.5 5.5h1.25a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15H3.5c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.275 0h1.25c.076 0 .125.074.125.15v1.225c0 .075-.05.15-.124.15h-1.25c-.076 0-.126-.074-.126-.15V5.65c0-.075.05-.15.125-.15zm2.275 0H9.3c.076 0 .126.074.126.15v1.225c0 .075-.05.15-.125.15H8.05a.161.161 0 0 1-.151-.15V5.65a.16.16 0 0 1 .15-.15zm2.25 0h1.251a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15h-1.25c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.276 0h1.25c.076 0 .125.074.125.15v1.225c0 .075-.05.15-.125.15h-1.25c-.075 0-.125-.074-.125-.15V5.65c0-.075.05-.15.125-.15zm2.275 0h1.225a.16.16 0 0 1 .15.15v1.225a.16.16 0 0 1-.15.15h-1.225a.161.161 0 0 1-.15-.15V5.65a.16.16 0 0 1 .15-.15zM4.576 7.9h1.25c.076 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm2.325 0h1.25a.16.16 0 0 1 .15.15V9.3c0 .076-.074.126-.15.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm2.35 0h1.225a.16.16 0 0 1 .15.15V9.3c0 .076-.074.126-.15.126H9.251c-.075 0-.15-.05-.15-.125V8.05c0-.076.074-.151.15-.151zm2.325 0h1.25c.076 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.15-.05-.15-.125V8.05c0-.076.074-.151.15-.151zm2.325 0h1.25c.075 0 .125.074.125.15V9.3c0 .076-.05.126-.125.126h-1.25c-.075 0-.125-.05-.125-.125V8.05c0-.076.05-.151.125-.151zm-8.7 2.85h9.6c.07 0 .125.055.125.125v.675c0 .07-.055.125-.125.125H5.2a.123.123 0 0 1-.125-.125v-.675c0-.07.054-.125.125-.125z"/>
- <path stroke="#202122" stroke-width="1.2" d="M2.719 15.279L17.28.72"/>
+ <path stroke="#202122" stroke-width="1.2" d="M2.719 15.279 17.28.72"/>
</svg>
diff --git a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.displaysettings.js b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.displaysettings.js
index 3e532bac..ac0bff16 100644
--- a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.displaysettings.js
+++ b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.displaysettings.js
@@ -122,7 +122,7 @@
*/
setupWebFonts: function () {
var d = $.Deferred();
- mw.loader.using( [ 'ext.uls.webfonts.fonts' ] ).then( function () {
+ mw.loader.using( [ 'ext.uls.webfonts.repository' ] ).then( function () {
if ( this.isWebFontsEnabled ) {
mw.webfonts.setup();
}
diff --git a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.interface.js b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.interface.js
index 1518afee..eca35256 100644
--- a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.interface.js
+++ b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.interface.js
@@ -57,11 +57,11 @@
* on the contents of the page.
* For other skins, check if ULSDisplayInputAndDisplaySettingsInInterlanguage contains the current skin.
*
- * @return {bool}
+ * @return {boolean}
*/
function isUsingStandaloneLanguageButton() {
var skin = mw.config.get( 'skin' );
- // special handling for Vector. This can be removed when Vector is split into 2 separate skins.
+ // special handling for Vector.
return skin === 'vector' ? $( '#p-lang-btn' ).length > 0 :
mw.config.get( 'wgULSDisplaySettingsInInterlanguage' );
}
@@ -118,33 +118,30 @@
* @param {string} previousAutonym
*/
function showUndoTooltip( previousLang, previousAutonym ) {
- var $ulsTrigger, ulsPopup, ulsPopupPosition,
- ulsPosition = mw.config.get( 'wgULSPosition' );
-
- $ulsTrigger = ( ulsPosition === 'interlanguage' ) ?
- $( '.uls-settings-trigger, .mw-interlanguage-selector' ) :
- $( '.uls-trigger' );
+ var trigger, popup, popupPosition,
+ configPosition = mw.config.get( 'wgULSPosition' ),
+ triggerSelector = ( configPosition === 'interlanguage' ) ?
+ '.uls-settings-trigger, .mw-interlanguage-selector' :
+ '.uls-trigger';
// Fallback if no entry point is present
- if ( !$ulsTrigger.length ) {
- $ulsTrigger = $( '#pt-preferences' );
- }
+ trigger = document.querySelector( triggerSelector ) || document.querySelector( '#pt-preferences' );
// Skip tooltip if there is no element to attach the tooltip to.
// It will cause errors otherwise.
- if ( !$ulsTrigger.length ) {
+ if ( !trigger ) {
return;
}
function hideTipsy() {
- ulsPopup.toggle( false );
+ popup.toggle( false );
}
function showTipsy( timeout ) {
var tipsyTimer = 0;
- ulsPopup.toggle( true );
- ulsPopup.toggleClipping( false );
+ popup.toggle( true );
+ popup.toggleClipping( false );
// if the mouse is over the tooltip, do not hide
$( '.uls-tipsy' ).on( 'mouseover', function () {
@@ -156,18 +153,18 @@
tipsyTimer = setTimeout( hideTipsy, timeout );
}
- if ( ulsPosition === 'interlanguage' ) {
- ulsPopupPosition = 'after';
+ if ( configPosition === 'interlanguage' ) {
+ popupPosition = 'after';
} else {
- ulsPopupPosition = 'below';
+ popupPosition = 'below';
}
- ulsPopup = new OO.ui.PopupWidget( {
+ popup = new OO.ui.PopupWidget( {
padded: true,
width: 300,
classes: [ 'uls-tipsy' ],
// Automatically positioned relative to the trigger
- $floatableContainer: $ulsTrigger,
- position: ulsPopupPosition,
+ $floatableContainer: $( trigger ),
+ position: popupPosition,
$content: ( function () {
var messageKey, $link;
@@ -206,7 +203,7 @@
}() )
} );
- ulsPopup.$element.appendTo( document.body );
+ popup.$element.appendTo( document.body );
// The interlanguage position needs some time to settle down
setTimeout( function () {
@@ -215,7 +212,7 @@
}, 700 );
// manually show the tooltip
- $ulsTrigger.on( 'mouseover', function () {
+ $( trigger ).on( 'mouseover', function () {
// show only if the ULS panel is not shown
// eslint-disable-next-line no-jquery/no-sizzle
if ( !$( '.uls-menu:visible' ).length ) {
@@ -228,6 +225,7 @@
* Adds display and input settings to the ULS dialog after loading their code.
*
* @param {ULS} uls instance
+ * @return {jQuery.Promise}
*/
function loadDisplayAndInputSettings( uls ) {
return mw.loader.using( languageSettingsModules ).then( function () {
@@ -236,122 +234,124 @@
} );
}
- function initInterface() {
- var $pLang,
- clickHandler,
- // T273928: No change to the heading should be made in modern Vector when the language button is present
- isButton = isUsingStandaloneLanguageButton(),
- $ulsTrigger = $( '.uls-trigger' ),
- anonMode = ( mw.user.isAnon() &&
- !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
- ulsPosition = mw.config.get( 'wgULSPosition' );
-
- if ( ulsPosition === 'interlanguage' ) {
- // TODO: Refactor this block
- // The interlanguage links section.
- $pLang = $( '#p-lang' );
- // Add an element near the interlanguage links header
- $ulsTrigger = $( '<button>' )
- .addClass( 'uls-settings-trigger' );
- // Append ULS cog to languages section.
- $pLang.prepend( $ulsTrigger );
- // Take care of any other elements with this class.
- $ulsTrigger = $( '.uls-settings-trigger' );
-
- if ( !$pLang.find( 'div ul' ).children().length && isButton ) {
- // Replace the title of the interlanguage links area
- // if there are no interlanguage links
- $pLang.find( 'h3' )
- .text( mw.msg( 'uls-plang-title-languages' ) );
- }
-
- $ulsTrigger.attr( {
- title: mw.msg( 'ext-uls-select-language-settings-icon-tooltip' )
+ function initSecondaryEntryPoints() {
+ $( '.uls-settings-trigger' ).one( 'click', function ( e ) {
+ e.preventDefault();
+ mw.loader.using( languageSettingsModules, function () {
+ $( e.target ).languagesettings();
+ $( e.target ).trigger( 'click' );
} );
+ } );
+ }
- clickHandler = function ( e, eventParams ) {
- var languagesettings = $ulsTrigger.data( 'languagesettings' ),
- languageSettingsOptions;
+ function initInterlanguageEntryPoint() {
+ var $pLang = $( '#p-lang' );
- if ( languagesettings ) {
- if ( !languagesettings.shown ) {
- mw.hook( 'mw.uls.settings.open' ).fire( eventParams && eventParams.source || 'interlanguage' );
- }
+ var $trigger = $( '<button>' )
+ .addClass( 'uls-settings-trigger' )
+ .prop( 'title', mw.msg( 'ext-uls-select-language-settings-icon-tooltip' ) );
+
+ // Append ULS cog to interlanguage section header in the sidebar
+ $pLang.prepend( $trigger );
- return;
+ // Replace the title of the interlanguage links area from "In other languages" to
+ // "Languages" if there are no language links. TODO: Remove this feature?
+ if ( !$pLang.find( 'div ul' ).children().length && isUsingStandaloneLanguageButton ) {
+ $pLang.find( 'h3' ).text( mw.msg( 'uls-plang-title-languages' ) );
+ }
+
+ var clickHandler = function ( e ) {
+ var languagesettings = $trigger.data( 'languagesettings' ),
+ languageSettingsOptions;
+
+ if ( languagesettings ) {
+ if ( !languagesettings.shown ) {
+ mw.hook( 'mw.uls.settings.open' ).fire( 'interlanguage' );
}
- // Initialize the Language settings window
- languageSettingsOptions = {
- defaultModule: 'display',
- onPosition: function () {
- var caretRadius, top, left,
- ulsTriggerHeight = this.$element.height(),
- ulsTriggerWidth = this.$element[ 0 ].offsetWidth,
- ulsTriggerOffset = this.$element.offset();
-
- // Same as border width in mixins.less, or near enough
- caretRadius = 12;
-
- if ( ulsTriggerOffset.left > $( window ).width() / 2 ) {
- left = ulsTriggerOffset.left - this.$window.width() - caretRadius;
- this.$window.removeClass( 'selector-left' ).addClass( 'selector-right' );
- } else {
- left = ulsTriggerOffset.left + ulsTriggerWidth + caretRadius;
- this.$window.removeClass( 'selector-right' ).addClass( 'selector-left' );
- }
-
- // The top of the dialog is aligned in relation to
- // the middle of the trigger, so that middle of the
- // caret aligns with it. 16 is trigger icon height in pixels
- top = ulsTriggerOffset.top +
- ( ulsTriggerHeight / 2 ) -
- ( caretRadius + 16 );
-
- return { top: top, left: left };
- },
- onVisible: function () {
- this.$window.addClass( 'callout' );
- }
- };
+ return;
+ }
- mw.loader.using( languageSettingsModules, function () {
- $ulsTrigger.languagesettings( languageSettingsOptions ).trigger( 'click' );
- } );
+ // Initialize the Language settings window
+ languageSettingsOptions = {
+ defaultModule: 'display',
+ onPosition: function () {
+ var caretRadius, top, left,
+ ulsTriggerHeight = this.$element.height(),
+ ulsTriggerWidth = this.$element[ 0 ].offsetWidth,
+ ulsTriggerOffset = this.$element.offset();
+
+ // Same as border width in mixins.less, or near enough
+ caretRadius = 12;
+
+ if ( ulsTriggerOffset.left > $( window ).width() / 2 ) {
+ left = ulsTriggerOffset.left - this.$window.width() - caretRadius;
+ this.$window.removeClass( 'selector-left' ).addClass( 'selector-right' );
+ } else {
+ left = ulsTriggerOffset.left + ulsTriggerWidth + caretRadius;
+ this.$window.removeClass( 'selector-right' ).addClass( 'selector-left' );
+ }
- e.stopPropagation();
+ // The top of the dialog is aligned in relation to
+ // the middle of the trigger, so that middle of the
+ // caret aligns with it. 16 is trigger icon height in pixels
+ top = ulsTriggerOffset.top +
+ ( ulsTriggerHeight / 2 ) -
+ ( caretRadius + 16 );
+
+ return { top: top, left: left };
+ },
+ onVisible: function () {
+ this.$window.addClass( 'callout' );
+ }
};
- } else if ( anonMode ) {
- clickHandler = function ( e, eventParams ) {
- var languagesettings = $ulsTrigger.data( 'languagesettings' );
+
+ mw.loader.using( languageSettingsModules, function () {
+ $trigger.languagesettings( languageSettingsOptions ).trigger( 'click' );
+ } );
+
+ e.stopPropagation();
+ };
+
+ $trigger.on( 'click', clickHandler );
+ }
+
+ function initPersonalEntryPoint() {
+ var $trigger = $( '.uls-trigger' );
+ var clickHandler;
+
+ var anonMode = ( mw.user.isAnon() && !mw.config.get( 'wgULSAnonCanChangeLanguage' ) );
+ if ( anonMode ) {
+ clickHandler = function ( e ) {
+ var languagesettings = $trigger.data( 'languagesettings' );
e.preventDefault();
if ( languagesettings ) {
if ( !languagesettings.shown ) {
- mw.hook( 'mw.uls.settings.open' ).fire( eventParams && eventParams.source || 'personal' );
+ mw.hook( 'mw.uls.settings.open' ).fire( 'personal' );
}
} else {
mw.loader.using( languageSettingsModules, function () {
- $ulsTrigger.languagesettings();
+ $trigger.languagesettings();
- $ulsTrigger.trigger( 'click', eventParams );
+ $trigger.trigger( 'click' );
} );
}
};
} else {
clickHandler = function ( e, eventParams ) {
- var uls = $ulsTrigger.data( 'uls' );
+ var uls = $trigger.data( 'uls' );
e.preventDefault();
if ( uls ) {
if ( !uls.shown ) {
- mw.hook( 'mw.uls.settings.open' ).fire( eventParams && eventParams.source || 'personal' );
+ mw.hook( 'mw.uls.settings.open' ).fire( 'personal' );
}
} else {
mw.loader.using( 'ext.uls.mediawiki', function () {
- $ulsTrigger.uls( {
+ $trigger.uls( {
quickList: function () {
return mw.uls.getFrequentLanguageList();
},
@@ -374,32 +374,17 @@
// Allow styles to apply first and position to work by
// delaying the activation after them.
setTimeout( function () {
- $ulsTrigger.trigger( 'click', eventParams );
+ $trigger.trigger( 'click', eventParams );
}, 0 );
} );
}
};
}
- $ulsTrigger.on( 'click', clickHandler );
-
- // Bind language settings to preferences page link
- $( '#uls-preferences-link' )
- .on( 'click keypress', function ( e ) {
- if (
- e.type === 'click' ||
- e.type === 'keypress' && e.which === 13
- ) {
- $ulsTrigger.trigger( 'click', {
- source: 'preferences'
- } );
- }
-
- return false;
- } );
+ $trigger.on( 'click', clickHandler );
}
- function initTooltip() {
+ function initLanguageChangeUndoTooltip() {
var previousLanguage, currentLanguage, previousAutonym, currentAutonym;
if ( !userCanChangeLanguage() ) {
@@ -454,8 +439,28 @@
* @param {jQuery.Event} ev
*/
function loadContentLanguageSelector( ev ) {
- var $target = $( ev.currentTarget );
+ var targetNode = ev.currentTarget,
+ $target = $( targetNode );
ev.preventDefault();
+ // Special handling for checkboxes
+ if (
+ targetNode &&
+ targetNode.tagName === 'INPUT' &&
+ targetNode.getAttribute( 'type' ) === 'checkbox'
+ ) {
+ // Disabled checked status. If the ULS button is also a checkbox, we can
+ // conclude that it's using the checkbox hack.
+ // Setting checked to false disables the default behavior of that checkbox.
+ targetNode.checked = false;
+ $target.on( 'click', function () {
+ targetNode.checked = false;
+ } );
+ }
+
+ // Avoid reinitializing ULS multiple times for an element
+ if ( $target.attr( 'data-uls-loaded' ) ) {
+ return;
+ }
mw.loader.using( 'ext.uls.mediawiki' ).then( function () {
var parent, languageNodes, standalone, uls;
@@ -464,6 +469,8 @@
languageNodes = parent ? parent.querySelectorAll( '.interlanguage-link-target' ) : [];
standalone = isUsingStandaloneLanguageButton();
+ $target.attr( 'data-uls-loaded', true );
+
// Setup click handler for ULS
launchULS(
$target,
@@ -475,8 +482,8 @@
// Trigger the click handler to open ULS once ready
if ( standalone ) {
- // Provide access to display and input settings if this entry point is the single point
- // of access to all language settings.
+ // Provide access to display and input settings if this entry point is the single
+ // point of access to all language settings.
uls = $target.data( 'uls' );
loadDisplayAndInputSettings( uls ).always( function () {
$target.trigger( 'click' );
@@ -498,15 +505,57 @@
// if there are many languages. Warning: Both this module and ext.uls.compactlinks
// module may run simultaneously. Using event delegation to avoid race conditions where
// the trigger may be created after this code.
- $( document ).one( 'click', '.mw-interlanguage-selector', loadContentLanguageSelector );
+ $( document ).on( 'click', '.mw-interlanguage-selector', loadContentLanguageSelector );
+
}
}
function init() {
- initInterface();
- initTooltip();
+ initLanguageChangeUndoTooltip();
initIme();
- initContentLanguageSelectorClickHandler();
+
+ // There are three basic components of ULS interface:
+ // - language selection for interface
+ // - language selection for content
+ // - settings view (access to language selection for interface, fonts, input methods)
+ //
+ // These can be combined in different ways:
+ // - Vector skin (recently) has an omni selector that has content language selection as
+ // primary action with access to the settings view. It is on top right corner (LTR) of
+ // the page content area. It may not be present on all pages.
+ // - Compact language links provides access to content language selection only and it is in
+ // the interlanguage section of the sidebar. This is in addition to one of the main entry
+ // points below.
+ // - Personal entry point appears at the top of the page. It provides quick access to the
+ // interface language selection with access to the settings view, except if user is not
+ // logged in and not allowed to change a language. In this case it defaults to settings
+ // view without language selection.
+ // - Interlanguage entry point (a cog) appears in the interlanguage section in the sidebar.
+ // It defaults to the settings view.
+ //
+ // The three main entry points (omni selector, personal, interlanguage) are mutually
+ // exclusive. There may be secondary entry points anywhere on the page using the
+ // uls-settings-trigger class.
+
+ // First init secondary to avoid initing the interlanguage entry point multiple times
+ initSecondaryEntryPoints();
+ var position = mw.config.get( 'wgULSPosition' );
+ if ( position === 'interlanguage' ) {
+ initInterlanguageEntryPoint();
+ } else {
+ initPersonalEntryPoint();
+ }
+
+ var compact = mw.config.get( 'wgULSisCompactLinksEnabled' );
+ // The scope of the compact language links user preference has been expanded to also
+ // determine whether to show the omni box or not. Compact language links is already not
+ // loaded server side, so this is only relevant for the omnibox.
+ if ( compact ) {
+ // Init compact languages OR omni selector using the mw-interlanguage-selector class
+ initContentLanguageSelectorClickHandler();
+ } else {
+ $( '.mw-interlanguage-selector' ).removeClass( 'mw-interlanguage-selector' );
+ }
}
// Early execute of init
diff --git a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.launch.js b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.launch.js
index e2bfe9de..ebba612d 100644
--- a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.launch.js
+++ b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.launch.js
@@ -60,6 +60,12 @@ function launchULS( $trigger, languagesObject, forCLS ) {
) {
return;
}
+
+ // TODO: The name of this hook should probably be changed to reflect that it covers
+ // both the user changing their interface language and the user switching to a
+ // different language.
+ mw.hook( 'mw.uls.interface.language.change' ).fire( language, 'content-language-switcher' );
+
location.href = languagesObject[ language ].href;
},
onPosition: function () {
@@ -91,6 +97,9 @@ function launchULS( $trigger, languagesObject, forCLS ) {
},
onVisible: function () {
$trigger.addClass( 'selector-open' );
+
+ // Note well that this hook is unstable.
+ mw.hook( 'mw.uls.compact_language_links.open' ).fire( $trigger );
},
languageDecorator: function ( $languageLink, language ) {
var element = languagesObject[ language ];
diff --git a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.js b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.js
index 9d7d7372..e2d61624 100644
--- a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.js
+++ b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.js
@@ -137,7 +137,7 @@
if ( mw.webfonts.preferences.isEnabled() ) {
// Queue to next idle period to optimize loading.
mw.requestIdleCallback( function () {
- mw.loader.using( 'ext.uls.webfonts.fonts' ).then( mw.webfonts.setup );
+ mw.loader.using( 'ext.uls.webfonts.repository' ).then( mw.webfonts.setup );
} );
}
} );
diff --git a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.repository.js b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.repository.js
index 2ea5aafe..30e6f72c 100644
--- a/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.repository.js
+++ b/MLEB/UniversalLanguageSelector/resources/js/ext.uls.webfonts.repository.js
@@ -5,7 +5,7 @@
"base": "../data/fontrepo/fonts/",
"languages": {
"adx": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"af": [
"system",
@@ -51,10 +51,10 @@
"Siyam Rupali"
],
"bo": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"bod": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"bpy": [
"Siyam Rupali"
@@ -104,13 +104,13 @@
"OpenDyslexic"
],
"dre": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"dv": [
"FreeFont-Thaana"
],
"dz": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"en": [
"system",
@@ -169,7 +169,7 @@
"OpenDyslexic"
],
"goe": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"got": [
"system",
@@ -198,7 +198,7 @@
"OpenDyslexic"
],
"hut": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"id": [
"system",
@@ -238,10 +238,10 @@
"Pustaka Bali"
],
"kbg": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"khg": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"km": [
"KhmerOSbattambang",
@@ -251,17 +251,17 @@
"Suwannaphum"
],
"kte": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"lb": [
"system",
"OpenDyslexic"
],
"lbj": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"lhm": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"li": [
"system",
@@ -271,13 +271,13 @@
"Phetsarath"
],
"loy": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"luk": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"lya": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"mak": [
"Saweri"
@@ -297,7 +297,7 @@
"Pustaka Bali"
],
"muk": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"my": [
"TharLon",
@@ -323,10 +323,10 @@
"OpenDyslexic"
],
"ola": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"otb": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"pal": [
"Shapour"
@@ -385,10 +385,10 @@
"SertoUrhoy"
],
"tcn": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"thw": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"ti": [
"AbyssinicaSIL"
@@ -406,7 +406,7 @@
"OpenDyslexic"
],
"tsk": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"ur": [
"system",
@@ -418,14 +418,14 @@
"OpenDyslexic"
],
"xct": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
],
"yi": [
"system",
"Alef"
],
"zau": [
- "Jomolhari"
+ "BabelStoneTibetanSlim"
]
},
"fonts": {
@@ -478,6 +478,10 @@
"woff": "Artaxerxes/Artaxerxes.woff?c1ed7",
"woff2": "Artaxerxes/Artaxerxes.woff2?7a96e"
},
+ "BabelStoneTibetanSlim": {
+ "woff": "BabelStoneTibetanSlim/BabelStoneTibetanSlim.woff?c48ba",
+ "woff2": "BabelStoneTibetanSlim/BabelStoneTibetanSlim.woff2?46398"
+ },
"Boyo Gagrai": {
"woff2": "BoyoGagrai/BoyoGagrai.woff2?d1060"
},
@@ -579,10 +583,6 @@
"woff": "IranianSerif/irseri.woff?d153b",
"woff2": "IranianSerif/irseri.woff2?2e4dd"
},
- "Jomolhari": {
- "woff": "Jomolhari/Jomolhari.woff?3a60b",
- "woff2": "Jomolhari/Jomolhari.woff2?f448a"
- },
"Junicode": {
"woff": "Junicode/Junicode.woff?19f4e",
"woff2": "Junicode/Junicode.woff2?1a244",