[MediaWiki-commits] [Gerrit] mediawiki...ContentTranslation[master]: Alignment and editor positioning corrections for multipart t...
jenkins-bot has submitted this change and it was merged. Change subject: Alignment and editor positioning corrections for multipart templates .. Alignment and editor positioning corrections for multipart templates When source template has fragments and some hidden(or height 0) the alignment calculation and positioning of editor were going wrong. Example articles: Tasmanian Devil (en->he), Samuel L. Jackson (en->*) Change-Id: Iabea86f7ce30f136eae37dd7a3c32e1e1ba5f0bb --- M modules/tools/ext.cx.tools.template.editor.js M modules/tools/ext.cx.tools.template.js M modules/translation/ext.cx.translation.aligner.js M modules/ui/styles/mw.cx.ui.TranslationView.less 4 files changed, 111 insertions(+), 57 deletions(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/tools/ext.cx.tools.template.editor.js b/modules/tools/ext.cx.tools.template.editor.js index 9eed7d2..01bcb98 100644 --- a/modules/tools/ext.cx.tools.template.editor.js +++ b/modules/tools/ext.cx.tools.template.editor.js @@ -40,21 +40,13 @@ * Initialize the template editor */ TemplateEditor.prototype.init = function () { - var sourceId, self = this; + var self = this; this.$sourceTemplateContainer = this.buildSourceFormContainer(); this.$targetTemplateContainer = this.buildTargetFormContainer(); - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection = this.targetTemplate.$template.parents( '[data-source]' ); - sourceId = this.targetTemplate.$parentSection.data( 'source' ); - this.sourceTemplate.$parentSection = $( document.getElementById( sourceId ) ); - this.sourceTemplate.$parentSection.after( this.$sourceTemplateContainer ); - this.targetTemplate.$parentSection.after( this.$targetTemplateContainer ); - } else { - this.sourceTemplate.$template.after( this.$sourceTemplateContainer ); - this.targetTemplate.$template.after( this.$targetTemplateContainer ); - } + this.sourceTemplate.getEditorContainer().after( this.$sourceTemplateContainer ); + this.targetTemplate.getEditorContainer().after( this.$targetTemplateContainer ); this.sourceTemplate.init().then( function () { self.buildSourceTemplateForm(); @@ -497,14 +489,8 @@ * Show the editor. */ TemplateEditor.prototype.show = function () { - - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection.hide(); - this.sourceTemplate.$parentSection.hide(); - } else { - this.targetTemplate.$template.hide(); - this.sourceTemplate.$template.hide(); - } + this.targetTemplate.hide(); + this.sourceTemplate.hide(); this.$sourceTemplateContainer.show(); this.$targetTemplateContainer.show(); @@ -527,13 +513,8 @@ this.$sourceTemplateContainer.hide(); this.$targetTemplateContainer.hide(); - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection.show(); - this.sourceTemplate.$parentSection.show(); - } else { - this.targetTemplate.$template.show(); - this.sourceTemplate.$template.show(); - } + this.targetTemplate.show(); + this.sourceTemplate.show(); }; diff --git a/modules/tools/ext.cx.tools.template.js b/modules/tools/ext.cx.tools.template.js index 769aed2..eba5ae4 100644 --- a/modules/tools/ext.cx.tools.template.js +++ b/modules/tools/ext.cx.tools.template.js @@ -162,13 +162,18 @@ * @return {jQuery} */ Template.static.getTemplateDef = function ( $template ) { - var $sourceTemplate = $( [] ); + var aboutAttr, + $sourceTemplate = $( [] ); if ( !$template ) { return $sourceTemplate; } - mw.cx.Template.static.getFragments( $template ).each( function ( index, fragment ) { + aboutAttr = $template.attr( 'about' ) || + mw.cx.getSourceSection( $template.data( 'source' ) ).attr( 'about' ); + + // Template definition is usually at source template at source column + $( '[about="' + aboutAttr + '"]' ).each( function ( index, fragment ) { var $fragment = $( fragment ); if ( @@ -203,34 +208,77 @@
[MediaWiki-commits] [Gerrit] mediawiki...ContentTranslation[master]: Alignment and editor positioning corrections for multipart t...
Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/323120 Change subject: Alignment and editor positioning corrections for multipart templates .. Alignment and editor positioning corrections for multipart templates When source template has fragments and some hidden(or height 0) the alignment calculation and positioning of editor were going wrong. Example articles: Tasmanian Devil (en->he), Samuel L. Jackson (en->*) Change-Id: Iabea86f7ce30f136eae37dd7a3c32e1e1ba5f0bb --- M modules/tools/ext.cx.tools.template.editor.js M modules/tools/ext.cx.tools.template.js M modules/translation/ext.cx.translation.aligner.js M modules/ui/styles/mw.cx.ui.TranslationView.less 4 files changed, 113 insertions(+), 57 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/20/323120/1 diff --git a/modules/tools/ext.cx.tools.template.editor.js b/modules/tools/ext.cx.tools.template.editor.js index 9eed7d2..01bcb98 100644 --- a/modules/tools/ext.cx.tools.template.editor.js +++ b/modules/tools/ext.cx.tools.template.editor.js @@ -40,21 +40,13 @@ * Initialize the template editor */ TemplateEditor.prototype.init = function () { - var sourceId, self = this; + var self = this; this.$sourceTemplateContainer = this.buildSourceFormContainer(); this.$targetTemplateContainer = this.buildTargetFormContainer(); - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection = this.targetTemplate.$template.parents( '[data-source]' ); - sourceId = this.targetTemplate.$parentSection.data( 'source' ); - this.sourceTemplate.$parentSection = $( document.getElementById( sourceId ) ); - this.sourceTemplate.$parentSection.after( this.$sourceTemplateContainer ); - this.targetTemplate.$parentSection.after( this.$targetTemplateContainer ); - } else { - this.sourceTemplate.$template.after( this.$sourceTemplateContainer ); - this.targetTemplate.$template.after( this.$targetTemplateContainer ); - } + this.sourceTemplate.getEditorContainer().after( this.$sourceTemplateContainer ); + this.targetTemplate.getEditorContainer().after( this.$targetTemplateContainer ); this.sourceTemplate.init().then( function () { self.buildSourceTemplateForm(); @@ -497,14 +489,8 @@ * Show the editor. */ TemplateEditor.prototype.show = function () { - - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection.hide(); - this.sourceTemplate.$parentSection.hide(); - } else { - this.targetTemplate.$template.hide(); - this.sourceTemplate.$template.hide(); - } + this.targetTemplate.hide(); + this.sourceTemplate.hide(); this.$sourceTemplateContainer.show(); this.$targetTemplateContainer.show(); @@ -527,13 +513,8 @@ this.$sourceTemplateContainer.hide(); this.$targetTemplateContainer.hide(); - if ( this.targetTemplate.options.inline ) { - this.targetTemplate.$parentSection.show(); - this.sourceTemplate.$parentSection.show(); - } else { - this.targetTemplate.$template.show(); - this.sourceTemplate.$template.show(); - } + this.targetTemplate.show(); + this.sourceTemplate.show(); }; diff --git a/modules/tools/ext.cx.tools.template.js b/modules/tools/ext.cx.tools.template.js index 53c49e0..875350b 100644 --- a/modules/tools/ext.cx.tools.template.js +++ b/modules/tools/ext.cx.tools.template.js @@ -162,13 +162,17 @@ * @return {jQuery} */ Template.static.getTemplateDef = function ( $template ) { - var $sourceTemplate = $( [] ); + var aboutAttr, + $sourceTemplate = $( [] ); if ( !$template ) { return $sourceTemplate; } - mw.cx.Template.static.getFragments( $template ).each( function ( index, fragment ) { + aboutAttr = $template.attr( 'about' ) || + mw.cx.getSourceSection( $template.data( 'source' ) ).attr( 'about' ); + + $( '[about="' + aboutAttr + '"]' ).each( function ( index, fragment ) { var $fragment = $( fragment ); if ( @@ -203,34 +207,81 @@ }; /**