diff --git a/www/js/app.js b/www/js/app.js index dc11d1cf..7b0ea464 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -2647,7 +2647,6 @@ function removePageMaxWidth () { if (!appstate.wikimediaZimLoaded) return; // Note that the UWP app has no access to the content of opened windows, so we can't access the DOM of the articleWindow if (/UWP/.test(params.appType) && appstate.target !== 'iframe') return; - var zimType; var cssSource; var contentElement; var docStyle; @@ -2657,8 +2656,8 @@ function removePageMaxWidth () { var body = doc.body; // Remove max-width: 100ex; from the element's style attribute (in new ZIMs from mobile html enpoint) if (body.style) body.style.maxWidth = ''; - zimType = /]+(?:minerva|mobile)/i.test(doc.head.innerHTML) ? 'mobile' : 'desktop'; - cssSource = params.cssSource === 'auto' ? zimType : params.cssSource; + appstate.zimThemeType = /]+(?:minerva|mobile)/i.test(doc.head.innerHTML) ? 'mobile' : 'desktop'; + cssSource = params.cssSource === 'auto' ? appstate.zimThemeType : params.cssSource; var idArray = ['content', 'bodyContent']; for (var i = 0; i < idArray.length; i++) { contentElement = doc.getElementById(idArray[i]); @@ -2680,7 +2679,7 @@ function removePageMaxWidth () { updatedCssText = params.removePageMaxWidth ? '100%' : '55.8em'; docStyle.maxWidth = updatedCssText; docStyle.cssText = docStyle.cssText.replace(/max-width:[^;]+/i, 'max-width: ' + updatedCssText + ' !important'); - if (params.removePageMaxWidth || zimType == 'mobile') docStyle.border = '0'; + if (params.removePageMaxWidth || appstate.zimThemeType == 'mobile') docStyle.border = '0'; } docStyle.margin = '0 auto'; } @@ -4336,6 +4335,7 @@ function archiveReadyCallback (archive) { // (this only affects Restricted mode) appstate.target = 'iframe'; appstate.wikimediaZimLoaded = /wikipedia|wikivoyage|mdwiki|wiktionary/i.test(archive.file.name); + appstate.zimThemeType = 'desktop'; appstate.pureMode = false; // Reset params.assetsCache in case it was changed below params.assetsCache = settingsStore.getItem('assetsCache') !== 'false'; @@ -6291,26 +6291,27 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) { htmlArticle = htmlArticle.replace(noexcerpt[1], ''); htmlArticle = htmlArticle.replace(/(<\/h1>\s*)/i, '$1' + noexcerpt[1]); } - // Put misplaced hatnote headers inside