jenkins-bot has submitted this change and it was merged. Change subject: Language Inspector Default Fix ......................................................................
Language Inspector Default Fix Fixes the situation where there's a language set but not a direction. Change-Id: If353b36ff0700717f1b8fd917b39c230de5ec272 --- M modules/ve/ui/inspectors/ve.ui.LanguageInspector.js 1 file changed, 26 insertions(+), 22 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js index 41ee0c4..0d4774e 100644 --- a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js @@ -96,8 +96,8 @@ // This will be called only if the annotation doesn't already exist, setting // the default value as the current language/dir of the selected text. if ( fragDOM ) { - this.initLang = fragDOM.$.closest('[lang]').attr('lang') || 'en'; - this.initDir = fragDOM.$.closest('[dir]').css('direction') || 'ltr'; + this.initLang = fragDOM.$.closest('[lang]').attr('lang'); + this.initDir = fragDOM.$.closest('[dir]').css('direction'); } // Parent method @@ -146,43 +146,47 @@ * @chainable */ ve.ui.LanguageInspector.prototype.setAnnotation = function ( annotation ) { - var langCode = '', - langDir = ''; + var langCode, langDir, annData; // Validate the given annotation: // Give precedence to dir value if it already exists // in the annotation: - if ( annotation.getAttribute( 'dir' ) ) { - langDir = annotation.getAttribute( 'dir' ); - } + langDir = annotation.getAttribute( 'dir' ); // Set language according to the one in the given annotation // or leave blank if element has no language set - if ( annotation.getAttribute( 'lang' ) ) { - langCode = annotation.getAttribute( 'lang' ); - } + langCode = annotation.getAttribute( 'lang' ); // If language exists, but dir is undefined/null, // fix the dir in terms of language: if ( langCode && !langDir ) { - langDir = $.uls.data.getDir( this.lang ); + langDir = $.uls.data.getDir( langCode ); } + // Set the annotation data: + annData = { + 'type': 'language', + 'attributes': {} + }; + + if ( langCode ) { + annData.attributes.lang = langCode; + } + + if ( langDir ) { + annData.attributes.dir = langDir; + } + + // Update the widget: + this.targetInput.setAttributes( langCode, langDir ); + + // Update inspector properties: this.lang = langCode; this.dir = langDir; - // Update the widget: - this.targetInput.setAttributes( this.lang, this.dir ); - - // Set the annotation: - this.annotation = new ve.dm.LanguageAnnotation( { - 'type': 'language', - 'attributes': { - 'lang': this.lang, - 'dir': this.dir - } - } ); + // Set up the annotation: + this.annotation = new ve.dm.LanguageAnnotation( annData ); return this; }; -- To view, visit https://gerrit.wikimedia.org/r/81136 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If353b36ff0700717f1b8fd917b39c230de5ec272 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits