From 675cb6342e33f7036660b9f22b6ea18f0dfb3c20 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Thu, 8 Aug 2019 09:00:13 +0100 Subject: [PATCH] Reload article on contentInjectionMode change Former-commit-id: cf004536c31582a44b78c46a108be988f477ed48 [formerly bf33f4c4532a73ba5479e59771161517d98979b8] Former-commit-id: 0651c7d749f3ef425362556123d5d329b599bdb9 --- www/js/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index efcffffe..0edc3751 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1284,6 +1284,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki $('input:radio[name=contentInjectionMode]').prop('checked', false); $('input:radio[name=contentInjectionMode]').filter('[value="' + value + '"]').prop('checked', true); params.contentInjectionMode = value; + params.themeChanged = true; // This will reload the page // Save the value in a cookie, so that to be able to keep it after a reload/restart cookies.setItem('lastContentInjectionMode', value, Infinity); } @@ -2230,7 +2231,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki var iframeArticleContent = document.getElementById('articleContent'); // Hide the display while loading - iframeArticleContent.style.display = 'none'; + // iframeArticleContent.style.display = 'none'; // iframeArticleContent.onload = function(){}; // iframeArticleContent.src = 'article.html'; @@ -2273,7 +2274,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki console.log("Fast article retrieval from localStorage..."); setTimeout(function () { displayArticleInForm(dirEntry, htmlContent); - }, 100); + }); } else { //if (params.contentInjectionMode === 'jquery') { // In jQuery mode, we read the article content in the backend and manually insert it in the iframe @@ -2362,7 +2363,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki messagePort.postMessage({ 'action': 'sendRedirect', 'title': title, 'redirectUrl': redirectURL }); }); } else { - console.log('SW read dirEntry for: ' + dirEntry.url); var mimetype = dirEntry.getMimetype(); if (/\bhtml\b/i.test(mimetype)) { // Intercept files of type html and apply transformations @@ -2371,6 +2371,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki var message = { 'action': 'giveContent', 'title': title, 'mimetype': mimetype, 'imageDisplay': params.imageDisplayMode, 'content': params.transformedHTML }; + document.getElementById('articleContent').style.display = 'none'; messagePort.postMessage(message); params.transformedHTML = ''; } else { @@ -2800,7 +2801,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki $('#articleContent').contents().remove(); // Remove from DOM any download alert box that was activated in uiUtil.displayFileDownloadAlert function - $('.alert').hide(); + $('#downloadAlert').hide(); var iframeArticleContent = document.getElementById('articleContent'); @@ -3065,6 +3066,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki articleContent.write(htmlArticle); articleContent.close(); + // Hide the iframe while loading + iframeArticleContent.style.display = 'none'; + } // End of injectHtml function insertMediaBlobsJQuery() {