Fix open all headings for SW mode

Former-commit-id: 8acd7c8fa628664d82b7cfa783ecdb5feb421899 [formerly 105744ed9b593075e3a7eacee2311d6658cf97f5 [formerly 5ea48e77e794d515ae306e9a682c8afd3c7527ca]]
Former-commit-id: 16683196935e043c09d05253dd5b66b1d5a4a576
Former-commit-id: ea66acf220d99ea0dc838e32dabe7fd899d4c33b
This commit is contained in:
Jaifroid 2021-01-16 22:36:46 +00:00
parent ee337bc393
commit eb0f040cc6

View File

@ -1316,6 +1316,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
document.getElementById('openAllSectionsCheck').addEventListener('click', function (e) {
params.openAllSections = this.checked;
settingsStore.setItem('openAllSections', params.openAllSections, Infinity);
if (params.contentInjectionMode === 'serviceworker') {
// We have to reload the article to respect user's choice
goToArticle(params.lastPageVisit.replace(/@[^@].+$/, ''));
return;
}
openAllSections();
});
$('input:radio[name=useMathJax]').on('click', function (e) {
@ -3093,7 +3098,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
// And make sure all sections are open - this doesn't work, because they are all subsequently closed by JS
// htmlArticle = htmlArticle.replace(/(<details\b(?![^>]+\sopen)[^>]+)>/ig, '$1 open>');
// Remove the script.js that closes top-level sections if user requested this
if (params.openAllSections) htmlArticle = htmlArticle.replace(/<script\b[^>]+-\/j\/js_modules\/script\.js"[^<]*<\/script>/i, "");
if (params.openAllSections) htmlArticle = htmlArticle.replace(/<script\b[^>]+-\/(j\/js_modules\/)?script\.js"[^<]*<\/script>/i, "");
// Remove landing page scripts that don't work in SW mode
if (params.cssCache) htmlArticle = htmlArticle.replace(/<script\b[^>]+-\/j\/js_modules\/((?:images_loaded|masonry)\.min|article_list_home)\.js"[^<]*<\/script>/gi, "");