Reload article on contentInjectionMode change

Former-commit-id: cf004536c31582a44b78c46a108be988f477ed48 [formerly bf33f4c4532a73ba5479e59771161517d98979b8]
Former-commit-id: 0651c7d749f3ef425362556123d5d329b599bdb9
This commit is contained in:
Jaifroid 2019-08-08 09:00:13 +01:00
parent 0e190d02ca
commit 675cb6342e

View File

@ -1284,6 +1284,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
$('input:radio[name=contentInjectionMode]').prop('checked', false); $('input:radio[name=contentInjectionMode]').prop('checked', false);
$('input:radio[name=contentInjectionMode]').filter('[value="' + value + '"]').prop('checked', true); $('input:radio[name=contentInjectionMode]').filter('[value="' + value + '"]').prop('checked', true);
params.contentInjectionMode = value; 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 // Save the value in a cookie, so that to be able to keep it after a reload/restart
cookies.setItem('lastContentInjectionMode', value, Infinity); cookies.setItem('lastContentInjectionMode', value, Infinity);
} }
@ -2230,7 +2231,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
var iframeArticleContent = document.getElementById('articleContent'); var iframeArticleContent = document.getElementById('articleContent');
// Hide the display while loading // Hide the display while loading
iframeArticleContent.style.display = 'none'; // iframeArticleContent.style.display = 'none';
// iframeArticleContent.onload = function(){}; // iframeArticleContent.onload = function(){};
// iframeArticleContent.src = 'article.html'; // iframeArticleContent.src = 'article.html';
@ -2273,7 +2274,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
console.log("Fast article retrieval from localStorage..."); console.log("Fast article retrieval from localStorage...");
setTimeout(function () { setTimeout(function () {
displayArticleInForm(dirEntry, htmlContent); displayArticleInForm(dirEntry, htmlContent);
}, 100); });
} else { } else {
//if (params.contentInjectionMode === 'jquery') { //if (params.contentInjectionMode === 'jquery') {
// In jQuery mode, we read the article content in the backend and manually insert it in the iframe // 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 }); messagePort.postMessage({ 'action': 'sendRedirect', 'title': title, 'redirectUrl': redirectURL });
}); });
} else { } else {
console.log('SW read dirEntry for: ' + dirEntry.url);
var mimetype = dirEntry.getMimetype(); var mimetype = dirEntry.getMimetype();
if (/\bhtml\b/i.test(mimetype)) { if (/\bhtml\b/i.test(mimetype)) {
// Intercept files of type html and apply transformations // Intercept files of type html and apply transformations
@ -2371,6 +2371,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
var message = { var message = {
'action': 'giveContent', 'title': title, 'mimetype': mimetype, 'imageDisplay': params.imageDisplayMode, 'content': params.transformedHTML 'action': 'giveContent', 'title': title, 'mimetype': mimetype, 'imageDisplay': params.imageDisplayMode, 'content': params.transformedHTML
}; };
document.getElementById('articleContent').style.display = 'none';
messagePort.postMessage(message); messagePort.postMessage(message);
params.transformedHTML = ''; params.transformedHTML = '';
} else { } else {
@ -2800,7 +2801,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
$('#articleContent').contents().remove(); $('#articleContent').contents().remove();
// Remove from DOM any download alert box that was activated in uiUtil.displayFileDownloadAlert function // Remove from DOM any download alert box that was activated in uiUtil.displayFileDownloadAlert function
$('.alert').hide(); $('#downloadAlert').hide();
var iframeArticleContent = document.getElementById('articleContent'); var iframeArticleContent = document.getElementById('articleContent');
@ -3065,6 +3066,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki
articleContent.write(htmlArticle); articleContent.write(htmlArticle);
articleContent.close(); articleContent.close();
// Hide the iframe while loading
iframeArticleContent.style.display = 'none';
} // End of injectHtml } // End of injectHtml
function insertMediaBlobsJQuery() { function insertMediaBlobsJQuery() {