jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/366311 )

Change subject: Update Zim postprocessing to account for lazy loading of images.
......................................................................


Update Zim postprocessing to account for lazy loading of images.

Change-Id: I36f7c2b8b39decbb8befc58a3b2df95d9981a94e
---
M app/src/main/assets/bundle.js
M www/js/sections.js
2 files changed, 26 insertions(+), 4 deletions(-)

Approvals:
  Dbrant: Looks good to me, approved
  jenkins-bot: Verified
  Mholloway: Looks good to me, but someone else must approve



diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index 25d7139..b8df1ec 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -529,7 +529,8 @@
     var sectionJson;
     var i;
 
-    var currentSectionNode = document.createElement( "div" );
+    var lazyDocument = document.implementation.createHTMLDocument( );
+    var currentSectionNode = lazyDocument.createElement( "div" );
     currentSectionNode.setAttribute( "dir", window.directionality );
     currentSectionNode.id = "content_block_" + sectionIndex;
     contentElem.appendChild( currentSectionNode );
@@ -553,7 +554,8 @@
             sectionJson.anchor = "heading_" + sectionIndex;
             sectionsJson.push(sectionJson);
 
-            currentSectionNode = document.createElement( "div" );
+            lazyDocument = document.implementation.createHTMLDocument( );
+            currentSectionNode = lazyDocument.createElement( "div" );
             currentSectionNode.setAttribute( "dir", window.directionality );
             currentSectionNode.id = "content_block_" + sectionIndex;
             contentElem.appendChild( currentSectionNode );
@@ -583,6 +585,7 @@
         window.scrollTo( 0, payload.scrollY );
     }
     document.getElementById( "loading_sections").className = "";
+    lazyLoadTransformer.loadPlaceholders();
     bridge.sendMessage( "pageLoadComplete", {
       "sequence": payload.sequence,
       "savedPage": payload.savedPage,
@@ -600,6 +603,14 @@
             imgTags[i].setAttribute( 'src', imgSrc.replace("../I/", 
window.offlineContentProvider + "I/") );
         }
     }
+
+    var placeholderTags = currentSectionNode.querySelectorAll( 
'span.pagelib-lazy-load-placeholder' );
+    for ( i = 0; i < placeholderTags.length; i++ ) {
+        var dataSrc = placeholderTags[i].getAttribute( 'data-src' );
+        if (dataSrc !== null) {
+            placeholderTags[i].setAttribute( 'data-src', 
dataSrc.replace("../I/", window.offlineContentProvider + "I/") );
+        }
+    }
 }
 
 // -- End custom processing of ZIM html data --
diff --git a/www/js/sections.js b/www/js/sections.js
index 74c7943..2e04988 100644
--- a/www/js/sections.js
+++ b/www/js/sections.js
@@ -266,7 +266,8 @@
     var sectionJson;
     var i;
 
-    var currentSectionNode = document.createElement( "div" );
+    var lazyDocument = document.implementation.createHTMLDocument( );
+    var currentSectionNode = lazyDocument.createElement( "div" );
     currentSectionNode.setAttribute( "dir", window.directionality );
     currentSectionNode.id = "content_block_" + sectionIndex;
     contentElem.appendChild( currentSectionNode );
@@ -290,7 +291,8 @@
             sectionJson.anchor = "heading_" + sectionIndex;
             sectionsJson.push(sectionJson);
 
-            currentSectionNode = document.createElement( "div" );
+            lazyDocument = document.implementation.createHTMLDocument( );
+            currentSectionNode = lazyDocument.createElement( "div" );
             currentSectionNode.setAttribute( "dir", window.directionality );
             currentSectionNode.id = "content_block_" + sectionIndex;
             contentElem.appendChild( currentSectionNode );
@@ -320,6 +322,7 @@
         window.scrollTo( 0, payload.scrollY );
     }
     document.getElementById( "loading_sections").className = "";
+    lazyLoadTransformer.loadPlaceholders();
     bridge.sendMessage( "pageLoadComplete", {
       "sequence": payload.sequence,
       "savedPage": payload.savedPage,
@@ -337,6 +340,14 @@
             imgTags[i].setAttribute( 'src', imgSrc.replace("../I/", 
window.offlineContentProvider + "I/") );
         }
     }
+
+    var placeholderTags = currentSectionNode.querySelectorAll( 
'span.pagelib-lazy-load-placeholder' );
+    for ( i = 0; i < placeholderTags.length; i++ ) {
+        var dataSrc = placeholderTags[i].getAttribute( 'data-src' );
+        if (dataSrc !== null) {
+            placeholderTags[i].setAttribute( 'data-src', 
dataSrc.replace("../I/", window.offlineContentProvider + "I/") );
+        }
+    }
 }
 
 // -- End custom processing of ZIM html data --

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I36f7c2b8b39decbb8befc58a3b2df95d9981a94e
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to