jenkins-bot has submitted this change and it was merged. Change subject: LanguageAnnotation Touchup ......................................................................
LanguageAnnotation Touchup Fixing a couple of mishaps in the language annotation, including adding a getComparableObject in the ve.dm.LanguageAnnotation class. Change-Id: Ia28900df55969f60576cfd716c70ffc1ba5f4c27 --- M modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js M modules/ve/ui/inspectors/ve.ui.LanguageInspector.js 2 files changed, 19 insertions(+), 13 deletions(-) Approvals: Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js b/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js index f8477e3..70eb7e3 100644 --- a/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js +++ b/modules/ve/dm/annotations/ve.dm.LanguageAnnotation.js @@ -60,9 +60,15 @@ /* Methods */ -// TODO: -// Set up a proper comparable method for lang and dir attributes -// ve.dm.LanguageAnnotation.prototype.getComparableObject +/** + * @returns {Object} + */ +ve.dm.LanguageAnnotation.prototype.getComparableObject = function () { + return { + 'type': 'meta/language', + 'lang': this.getAttribute( 'lang' ) + }; +}; /* Registration */ diff --git a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js index 55e1823..f6d299f 100644 --- a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js +++ b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js @@ -20,8 +20,8 @@ ve.ui.AnnotationInspector.call( this, surface, config ); // Placeholder for the dm properties: - this.initLang = ''; - this.initDir = ''; + this.lang = ''; + this.dir = ''; // Placeholder for the annotation: this.annotation = null; @@ -98,8 +98,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' ); - this.initDir = fragDOM.$.closest( '[dir]' ).css( 'direction' ); + this.lang = fragDOM.$.closest( '[lang]' ).attr( 'lang' ); + this.dir = fragDOM.$.closest( '[dir]' ).css( 'direction' ); } // Parent method @@ -161,19 +161,19 @@ langCode = annotation.getAttribute( 'lang' ); } else { // No annotation (empty text or collapsed fragment on empty line) - langCode = this.initLang; - langDir = this.initDir; + langCode = this.lang; + langDir = this.dir; } // If language exists, but dir is undefined/null, // fix the dir in terms of language: - if ( langCode && !langDir ) { + if ( langCode && !langDir && $.uls ) { langDir = $.uls.data.getDir( langCode ); } // Set the annotation data: annData = { - 'type': 'language', + 'type': 'meta/language', 'attributes': {} }; @@ -205,8 +205,8 @@ return new ve.dm.LanguageAnnotation( { 'type': 'meta/language', 'attributes': { - 'lang': this.initLang, - 'dir': this.initDir + 'lang': this.lang, + 'dir': this.dir } } ); }; -- To view, visit https://gerrit.wikimedia.org/r/85700 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia28900df55969f60576cfd716c70ffc1ba5f4c27 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits