Open headers and blocks if they are closed.

Because they can not be opened with javascript for now.
Fixes #355
This commit is contained in:
Jaifroid 2018-04-23 19:02:07 +01:00 committed by Mossroy
parent ca740126e7
commit 107250eaaa

View File

@ -932,6 +932,17 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
}
function loadCSSJQuery() {
// Ensure all sections are open for clients that lack JavaScript support, or that have some restrictive CSP [kiwix-js #355].
// This is needed only for some versions of ZIM files generated by mwoffliner (at least in early 2018), where the article sections are closed by default on small screens.
// These sections can be opened by clicking on them, but this is done with some javascript.
// The code below is a workaround, a better fix is tracked on [mwoffliner #324]
var iframe = document.getElementById('articleContent').contentDocument;
var collapsedBlocks = iframe.querySelectorAll('.collapsible-block:not(.open-block), .collapsible-heading:not(.open-block)');
// Using decrementing loop to optimize performance : see https://stackoverflow.com/questions/3520688
for (var i = collapsedBlocks.length; i--;) {
collapsedBlocks[i].classList.add('open-block');
}
$('#articleContent').contents().find('link[rel=stylesheet]').each(function() {
var link = $(this);
// We try to find its name (from an absolute or relative URL)