mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-12 22:09:43 -04:00
Improve timing of articleContent display in jQuery mode
Former-commit-id: db7bc85654e025cb566c65301b575eb435da45e9 [formerly 9ee88b1de9616d29638be6f6354c1b0fd59d99ca] Former-commit-id: 2ce3a63456be04a54e681c47f4a220c47bb887ad
This commit is contained in:
parent
153e42a07a
commit
ad29aa660b
@ -2391,6 +2391,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
|||||||
htmlArticle = htmlArticle.replace(/(<\/h1>\s*)/i, "$1" + noexcerpt);
|
htmlArticle = htmlArticle.replace(/(<\/h1>\s*)/i, "$1" + noexcerpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Remove white background colour (causes flashes in dark mode)
|
||||||
|
htmlArticle = htmlArticle.replace(/(<body\b[^>]+style=["'][^"']*)background-color\s*:\s*[^;]+;\s*/i, '$1');
|
||||||
|
htmlArticle = htmlArticle.replace(/(<div\b(?=[^>]+class=\s*["'][^"']*mw-body)[^>]+style=["'][^"']*)background-color\s*:\s*[^;]+;\s*/i, '$1');
|
||||||
|
|
||||||
//Display IPA pronunciation info erroneously hidden in some ZIMs
|
//Display IPA pronunciation info erroneously hidden in some ZIMs
|
||||||
htmlArticle = htmlArticle.replace(/(<span\b[^>]+?class\s*=\s*"[^"]+?mcs-ipa[^>]+?display:\s*)none/i, "$1inline");
|
htmlArticle = htmlArticle.replace(/(<span\b[^>]+?class\s*=\s*"[^"]+?mcs-ipa[^>]+?display:\s*)none/i, "$1inline");
|
||||||
|
|
||||||
@ -2662,8 +2666,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
|||||||
// Inject the new article's HTML into the iframe
|
// Inject the new article's HTML into the iframe
|
||||||
var articleContent = iframeContentDocument.documentElement;
|
var articleContent = iframeContentDocument.documentElement;
|
||||||
articleContent.innerHTML = htmlArticle;
|
articleContent.innerHTML = htmlArticle;
|
||||||
// Make sure the article area is displayed
|
|
||||||
setTab();
|
|
||||||
|
|
||||||
var docBody = iframeContentDocument.getElementsByTagName('body');
|
var docBody = iframeContentDocument.getElementsByTagName('body');
|
||||||
docBody = docBody ? docBody[0] : null;
|
docBody = docBody ? docBody[0] : null;
|
||||||
@ -2813,7 +2815,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// function insertAnchorsJQuery
|
||||||
Array.prototype.slice.call(iframeContentDocument.querySelectorAll('a, area')).forEach(function (anchor) {
|
Array.prototype.slice.call(iframeContentDocument.querySelectorAll('a, area')).forEach(function (anchor) {
|
||||||
// Attempts to access any properties of 'this' with malformed URLs causes app crash in Edge/UWP [kiwix-js #430]
|
// Attempts to access any properties of 'this' with malformed URLs causes app crash in Edge/UWP [kiwix-js #430]
|
||||||
try {
|
try {
|
||||||
@ -2871,10 +2873,18 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
|
|||||||
|
|
||||||
// If we reloaded the page to print the desktop style, we need to return to the printIntercept dialogue
|
// If we reloaded the page to print the desktop style, we need to return to the printIntercept dialogue
|
||||||
if (params.printIntercept) printIntercept();
|
if (params.printIntercept) printIntercept();
|
||||||
|
|
||||||
|
// Make sure the article area is displayed
|
||||||
|
setTab();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load the blank article to clear the iframe (NB iframe onload event runs *after* this)
|
// Load the blank article to clear the iframe (NB iframe onload event runs *after* this)
|
||||||
iframeArticleContent.src = "article.html";
|
iframeArticleContent.src = "article.html";
|
||||||
|
|
||||||
|
// Hide the articleContent to prevent flashes in dark mode in some browsers
|
||||||
|
document.getElementById('articleContent').style.display = 'none';
|
||||||
|
|
||||||
//var articleContent = iframeArticleContent.contentDocument;
|
//var articleContent = iframeArticleContent.contentDocument;
|
||||||
//articleContent.open('text/html', 'replace');
|
//articleContent.open('text/html', 'replace');
|
||||||
//articleContent.write("<!DOCTYPE html>"); // Ensures browsers parse iframe in Standards mode
|
//articleContent.write("<!DOCTYPE html>"); // Ensures browsers parse iframe in Standards mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user