diff --git a/www/js/app.js b/www/js/app.js index 9aca55da..fb19e2cb 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -710,10 +710,19 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki $("#searchingArticles").hide(); $("#welcomeText").hide(); if (params.beforeinstallpromptFired) { - if (activeBtn !== 'btnConfigure' && !params.installLater) - document.getElementById('divInstall1').style.display = 'block'; - else - document.getElementById('divInstall1').style.display = 'none'; + var divInstall1 = document.getElementById('divInstall1'); + if (activeBtn !== 'btnConfigure' && !params.installLater && (params.pagesLoaded === 3 || params.pagesLoaded === 9)) { + divInstall1.style.display = 'block'; + setTimeout(function() { + // If installLater is now true, then the user clicked the Later button and the timeout in init.js will hide the display + if (!params.installLater) { + divInstall1.style.display = 'none'; + resizeIFrame(); + } + }, 9000); + } else { + divInstall1.style.display = 'none'; + } } setTimeout(resizeIFrame, 100); } @@ -2389,7 +2398,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki * @param {DirEntry} dirEntry The directory entry of the article to read */ function readArticle(dirEntry) { - + params.pagesLoaded++; if (dirEntry.isRedirect()) { state.selectedArchive.resolveRedirect(dirEntry, readArticle); } else { diff --git a/www/js/init.js b/www/js/init.js index a303b524..dfae0c92 100644 --- a/www/js/init.js +++ b/www/js/init.js @@ -81,6 +81,7 @@ params['printIntercept'] = false; params['printInterception'] = false; params['appIsLaunching'] = true; //Allows some routines to tell if the app has just been launched params['PWAInstalled'] = decodeURIComponent(getCookie('PWAInstalled')); +params.pagesLoaded = 0; // Page counter used to show PWA Install Prompt only after user has played with the app for a while //Prevent app boot loop with problematic pages that cause an app crash if (getCookie('lastPageLoad') == 'failed') { @@ -182,16 +183,13 @@ window.addEventListener('beforeinstallprompt', function(e) { if (!params.beforeinstallpromptFired && params.PWAInstalled !== params.version) { params.beforeinstallpromptFired = true; var config = document.getElementById('configuration'); - if (config.style.display === 'none') { - divInstall1.style.display = 'block'; - } btnInstall1.addEventListener('click', installApp); btnLater.addEventListener('click', function (e) { e.preventDefault(); - divInstall1.style.display = 'none'; - if (config.style.display === 'none') { - alert('You can install this app later from Configuration'); - } + divInstall1.innerHTML = 'You can install this app later from Configuration'; + setTimeout(function() { + divInstall1.style.display = 'none'; + }, 4000); params.installLater = true; }); divInstall2.style.display = 'block';