Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124794

Change subject: Fix the miss-alignment of sections by few pixels
......................................................................

Fix the miss-alignment of sections by few pixels

From tests, it is found that sections alignment go wrong by
a few pixels even after correct height is set. Browser does not
use that exact value probably due to rounding and other unknown
factors.

This patch tries to fix it by adjusting the height till an agreable
height is found

Change-Id: Ic8b846e86e1e855d91254969fb35ed461baeb6cc
---
M modules/translation/ext.cx.translation.js
1 file changed, 23 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/94/124794/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index dca569f..f2e1c9a 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -183,15 +183,20 @@
                        var $section, sourceSectionId, $sourceSection;
 
                        $section = $( this );
+                       if ( $section.height() === 0 ) {
+                               // Source section has height as 0. This 
indicates an empty
+                               // section - mainly resulting from spurious 
wikitext
+                               return;
+                       }
                        sourceSectionId = $section.attr( 'id' );
                        $sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
-                       $section.css( 'min-height', $section.height() )
+                       $section.empty();
+                       $section.css( 'min-height', $sourceSection.height() )
                                .attr( {
                                        'id': 't' + sourceSectionId,
                                        'data-source': sourceSectionId,
                                        'contenteditable': true
                                } );
-                       $section.empty();
                        $section.on( 'input', keepAlignment );
                        // Bind events to the placeholder sections
                        $sourceSection.click( function () {
@@ -216,11 +221,26 @@
                /*jshint validthis:true */
                $section = $( this );
                $sourceSection = $( '#' + $section.data( 'source' ) );
-               sectionHeight = $section.height();
                $sourceSection.css( 'min-height', '' );
+
                sourceSectionHeight = $sourceSection.height();
+               sectionHeight = $section.height();
+
                if ( sourceSectionHeight < sectionHeight ) {
                        $sourceSection.css( 'min-height', sectionHeight );
+                       sourceSectionHeight = $sourceSection.height();
+                       sectionHeight = $section.height();
+                       // Fun stuff - setting a calculated min-height will not 
guarantee
+                       // equal height for all kind of section pairs.
+                       // Experiments shows a few pixels difference
+                       // Here we do it by 10px steps till we reach equal 
height.
+                       while ( sectionHeight !== sourceSectionHeight ) {
+                               sectionHeight = sectionHeight = sectionHeight + 
10;
+                               $sourceSection.css( 'min-height', sectionHeight 
);
+                               $section.css( 'min-height', sectionHeight );
+                               sectionHeight = $section.height();
+                               sourceSectionHeight = $sourceSection.height();
+                       }
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/124794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8b846e86e1e855d91254969fb35ed461baeb6cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to