Mhurd has uploaded a new change for review.

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

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

Fix for infobox relocation leaving parent table with empty space.

Relocates the parent table.

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


  git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia 
refs/changes/66/166066/1

diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js
index eb6aa77..c5d0d30 100644
--- a/wikipedia/assets/bundle.js
+++ b/wikipedia/assets/bundle.js
@@ -468,6 +468,21 @@
     
     if (!soughtP) return;
 
+    /*
+        If the infobox table itself sits in another table, move that parent 
table instead of just the infobox.
+        Otherwise you end up with a table with a hole where the infobox had 
been. World War II article on 
+        enWiki has this issue.
+    */
+    var el = infobox;
+    while (el.parentNode) {
+        el = el.parentNode;
+        if (el.id === 'content_block_0') break;
+        if (el.tagName === 'TABLE'){
+            infobox = el;
+            break;
+        }
+    }
+
     // 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..f6eb235 100644
--- a/www/js/transforms.js
+++ b/www/js/transforms.js
@@ -34,6 +34,21 @@
     
     if (!soughtP) return;
 
+    /*
+        If the infobox table itself sits in another table, move that parent 
table instead of just the infobox.
+        Otherwise you end up with a table with a hole where the infobox had 
been. World War II article on 
+        enWiki has this issue.
+    */
+    var el = infobox;
+    while (el.parentNode) {
+        el = el.parentNode;
+        if (el.id === 'content_block_0') break;
+        if (el.tagName === 'TABLE'){
+            infobox = el;
+            break;
+        }
+    }
+
     // 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: newchange
Gerrit-Change-Id: Id4733126aa843680869da47cc027f161b77e7262
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <mh...@wikimedia.org>

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

Reply via email to