Brion VIBBER has submitted this change and it was merged.

Change subject: Fix for infobox relocation leaving parent table with empty 
space.
......................................................................


Fix for infobox relocation leaving parent table with empty space.

Relocates the most distant ancestor table encountered before the
content_block_0 div is encountered. If no parent tables found it
just moves the infobox the same as before.

Change-Id: Id4733126aa843680869da47cc027f161b77e7262
---
M wikipedia/assets/bundle.js
M www/js/transforms.js
2 files changed, 34 insertions(+), 0 deletions(-)

Approvals:
  Brion VIBBER: Verified; Looks good to me, approved



diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js
index eb6aa77..73c061c 100644
--- a/wikipedia/assets/bundle.js
+++ b/wikipedia/assets/bundle.js
@@ -468,6 +468,23 @@
     
     if (!soughtP) return;
 
+    /*
+    If the infobox table itself sits within a table or series of tables,
+    move the most distant ancestor table instead of just moving the 
+    infobox. Otherwise you end up with table(s) with a hole where the 
+    infobox had been. World War II article on enWiki has this issue.
+    Note that we need to stop checking ancestor tables when we hit
+    content_block_0.
+    */
+    var infoboxParentTable = null;
+    var el = infobox;
+    while (el.parentNode) {
+        el = el.parentNode;
+        if (el.id === 'content_block_0') break;
+        if (el.tagName === 'TABLE') infoboxParentTable = el;
+    }
+    if(infoboxParentTable)infobox = infoboxParentTable;
+
     // Found the first P tag whose direct parent has id of #content_block_0.
     // Now safe to detach the infobox and stick it after the P.
     soughtP.appendChild(infobox.parentNode.removeChild(infobox));
diff --git a/www/js/transforms.js b/www/js/transforms.js
index ad7c55d..e9abf82 100644
--- a/www/js/transforms.js
+++ b/www/js/transforms.js
@@ -34,6 +34,23 @@
     
     if (!soughtP) return;
 
+    /*
+    If the infobox table itself sits within a table or series of tables,
+    move the most distant ancestor table instead of just moving the 
+    infobox. Otherwise you end up with table(s) with a hole where the 
+    infobox had been. World War II article on enWiki has this issue.
+    Note that we need to stop checking ancestor tables when we hit
+    content_block_0.
+    */
+    var infoboxParentTable = null;
+    var el = infobox;
+    while (el.parentNode) {
+        el = el.parentNode;
+        if (el.id === 'content_block_0') break;
+        if (el.tagName === 'TABLE') infoboxParentTable = el;
+    }
+    if(infoboxParentTable)infobox = infoboxParentTable;
+
     // Found the first P tag whose direct parent has id of #content_block_0.
     // Now safe to detach the infobox and stick it after the P.
     soughtP.appendChild(infobox.parentNode.removeChild(infobox));

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id4733126aa843680869da47cc027f161b77e7262
Gerrit-PatchSet: 2
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to