jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/378906 )
Change subject: Support short language format on source selector
......................................................................
Support short language format on source selector
- Add support for short language codes (in BCP47 format)
on New translation dialog.
- Change long, autonym language names to language codes
and vice-versa, depending on screen size.
Change-Id: I1f967908f64b8d428d2626a24da0c12f9563f0fc
---
M modules/dashboard/styles/ext.cx.lists.common.less
M modules/source/ext.cx.source.selector.js
M modules/source/styles/ext.cx.source.selector.less
3 files changed, 36 insertions(+), 3 deletions(-)
Approvals:
jenkins-bot: Verified
Nikerabbit: Checked; Looks good to me, approved
diff --git a/modules/dashboard/styles/ext.cx.lists.common.less
b/modules/dashboard/styles/ext.cx.lists.common.less
index 69d9936..61a931e 100644
--- a/modules/dashboard/styles/ext.cx.lists.common.less
+++ b/modules/dashboard/styles/ext.cx.lists.common.less
@@ -78,6 +78,7 @@
.translation-source-language-filter,
.translation-target-language-filter {
background-color: @colorGray15;
+ color: @colorGray2;
padding: 8px;
font-size: 16px;
line-height: 1;
diff --git a/modules/source/ext.cx.source.selector.js
b/modules/source/ext.cx.source.selector.js
index eac283c..d16f2c5 100644
--- a/modules/source/ext.cx.source.selector.js
+++ b/modules/source/ext.cx.source.selector.js
@@ -55,6 +55,8 @@
this.$targetTitleInput = null;
this.overlay = null;
this.$translateFromButton = null;
+ this.narrowLimit = 700;
+ this.isNarrowScreenSize = false;
this.validator = new mw.cx.ContentTranslationValidator(
this.siteMapper );
this.init();
}
@@ -111,6 +113,8 @@
*/
CXSourceSelector.prototype.init = function () {
var self = this;
+
+ this.isNarrowScreenSize = document.documentElement.clientWidth
< this.narrowLimit;
this.getLanguagePairs().then( function () {
self.render();
@@ -245,7 +249,10 @@
};
this.$sourceLanguage.prop( langProps )
- .text( $.uls.data.getAutonym( this.sourceLanguage ) );
+ .text( this.isNarrowScreenSize ?
+ mw.language.bcp47( this.sourceLanguage ) :
+ $.uls.data.getAutonym( this.sourceLanguage )
+ );
mw.storage.set( 'cxSourceLanguage', this.sourceLanguage );
this.sourcePageSelector.setLanguage( this.sourceLanguage );
@@ -281,7 +288,10 @@
this.$targetTitleInput.prop( langProps );
}
this.$targetLanguage.prop( langProps )
- .text( $.uls.data.getAutonym( this.targetLanguage ) );
+ .text( this.isNarrowScreenSize ?
+ mw.language.bcp47( this.targetLanguage ) :
+ $.uls.data.getAutonym( this.targetLanguage )
+ );
this.sourcePageSelector.setTargetLanguage( language );
mw.storage.set( 'cxTargetLanguage', this.targetLanguage );
};
@@ -402,6 +412,28 @@
'.cx-sourceselector-page-title',
this.enterKeyHandler.bind( this )
);
+
+ // Resize handler
+ $( window ).resize( $.throttle( 250, this.resize.bind( this ) )
);
+ };
+
+ CXSourceSelector.prototype.resize = function () {
+ var isNarrowScreenSize = document.documentElement.clientWidth <
this.narrowLimit;
+
+ // Exit early if screen size stays above/under narrow screen
size limit
+ if ( this.isNarrowScreenSize === isNarrowScreenSize ) {
+ return;
+ }
+
+ this.isNarrowScreenSize = isNarrowScreenSize;
+ this.$sourceLanguage.text( isNarrowScreenSize ?
+ mw.language.bcp47( this.sourceLanguage ) :
+ $.uls.data.getAutonym( this.sourceLanguage )
+ );
+ this.$targetLanguage.text( isNarrowScreenSize ?
+ mw.language.bcp47( this.targetLanguage ) :
+ $.uls.data.getAutonym( this.targetLanguage )
+ );
};
/**
diff --git a/modules/source/styles/ext.cx.source.selector.less
b/modules/source/styles/ext.cx.source.selector.less
index 6ca19c2..7379988 100644
--- a/modules/source/styles/ext.cx.source.selector.less
+++ b/modules/source/styles/ext.cx.source.selector.less
@@ -226,7 +226,7 @@
}
.cx-sourceselector-embedded__language-filter {
- background: @colorGray15;
+ background-color: @colorGray15;
box-sizing: border-box;
width: auto;
max-width: 25%;
--
To view, visit https://gerrit.wikimedia.org/r/378906
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1f967908f64b8d428d2626a24da0c12f9563f0fc
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Petar.petkovic <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits