Mhurd has uploaded a new change for review.
https://gerrit.wikimedia.org/r/203495
Change subject: Fix for side to side scrolling of wide images with div overlays.
......................................................................
Fix for side to side scrolling of wide images with div overlays.
See the following enwiki articles > sections:
- "Historic Counties of England" > "Southern England"
- "Poland" > "Administrive Divisions" ("More information" collapsed table)
Change-Id: Ic488e55b047afa549f31f2658fb51324f21c415f
---
M Wikipedia/assets/bundle.js
M www/js/transforms.js
2 files changed, 24 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia
refs/changes/95/203495/1
diff --git a/Wikipedia/assets/bundle.js b/Wikipedia/assets/bundle.js
index 23d1589..c492b8f 100644
--- a/Wikipedia/assets/bundle.js
+++ b/Wikipedia/assets/bundle.js
@@ -701,16 +701,21 @@
}
} );
+function firstAncestorWithMultipleChildren (el) {
+ while ((el = el.parentElement) && (el.childElementCount == 1));
+ return el;
+}
+
function addImageOverflowXContainer() {
var image = this;
if (image.width > (window.screen.width * 0.8)){
- var div = document.createElement( 'div' );
- div.className = 'image_overflow_x_container';
- image.parentElement.insertBefore( div, image );
- // Reminder: appendChild removes "image" from its previous location
- // so no need to do so explicitly.
- // See:
https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
- div.appendChild( image );
+ var ancestor = firstAncestorWithMultipleChildren (image);
+ if(ancestor){
+ var div = document.createElement( 'div' );
+ div.className = 'image_overflow_x_container';
+ ancestor.parentElement.insertBefore( div, ancestor );
+ div.appendChild( ancestor );
+ }
}
}
diff --git a/www/js/transforms.js b/www/js/transforms.js
index e95aafb..2c288bb 100644
--- a/www/js/transforms.js
+++ b/www/js/transforms.js
@@ -254,16 +254,21 @@
}
} );
+function firstAncestorWithMultipleChildren (el) {
+ while ((el = el.parentElement) && (el.childElementCount == 1));
+ return el;
+}
+
function addImageOverflowXContainer() {
var image = this;
if (image.width > (window.screen.width * 0.8)){
- var div = document.createElement( 'div' );
- div.className = 'image_overflow_x_container';
- image.parentElement.insertBefore( div, image );
- // Reminder: appendChild removes "image" from its previous location
- // so no need to do so explicitly.
- // See:
https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
- div.appendChild( image );
+ var ancestor = firstAncestorWithMultipleChildren (image);
+ if(ancestor){
+ var div = document.createElement( 'div' );
+ div.className = 'image_overflow_x_container';
+ ancestor.parentElement.insertBefore( div, ancestor );
+ div.appendChild( ancestor );
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/203495
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic488e55b047afa549f31f2658fb51324f21c415f
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits