diff --git a/www/js/app.js b/www/js/app.js index d25584fa..de4f5ef1 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1399,7 +1399,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images settingsStore.setItem('hideActiveContentWarning', params.hideActiveContentWarning, Infinity); refreshCacheStatus(); }); - // Run lockDisplayOrientation on startup + // Check lockDisplayOrientation on startup document.getElementById('lockDisplayOrientationDrop').value = params.lockDisplayOrientation || ''; var topArea = document.getElementById('search-article'); var refreshFullScreen = function (evt) { @@ -1434,8 +1434,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images topArea.addEventListener('mouseup', refreshFullScreen); document.getElementById('lockDisplayOrientationDrop').addEventListener('change', function (event) { var that = this; - var message = event.target.value ? ('
Attempting to set the orientation lock to: ' + event.target.value + '
') : 'Attempting to clear the orientation lock.
'; - if (event.target.value) message += 'Please be aware that this setting may only work in mobile contexts where the app is installed or in standalone mode.
' + if (event.target.value) { return uiUtil.lockDisplayOrientation(event.target.value).then(function (rtn) { if (rtn === 'unsupported') { uiUtil.systemAlert('The Screen Orientation Lock API is not supported on this device!'); @@ -1443,6 +1442,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images } else { params.lockDisplayOrientation = event.target.value || ''; settingsStore.setItem('lockDisplayOrientation', params.lockDisplayOrientation, Infinity); + if (rtn === 'click') { + uiUtil.systemAlert('Please click the button top-right to enter full-screen mode.
' + (params.PWAInstalled && + /iOS/.test(params.appType) ?'In Safari on iOS, consider adding this app to your homescreen (Share --> Add to Home), which will give a better experience than full-screen mode.
' : '') + ); + } } setDynamicIcons(); }).catch(function (err) { @@ -1460,7 +1464,16 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images } setDynamicIcons(); }); - }) + } else { + params.lockDisplayOrientation = ''; + settingsStore.setItem('lockDisplayOrientation', '', Infinity); + uiUtil.lockDisplayOrientation().then(function () { + setDynamicIcons(); + }).catch(function () { + return; + }); + } + }); document.getElementById('debugLibzimASMDrop').addEventListener('change', function (event) { var that = this; var message = 'App will reload to apply the new setting.
' diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js index de691dea..0c827198 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -1009,7 +1009,7 @@ define(rqDef, function(util) { function requestOrCancelFullScreen(el) { // Don't do anything if already in full-screen mode, and user has not requested to exit full-screen mode if (el && appIsFullScreen()) { - console.log('Display is already full screen'); + console.debug('Display is already full screen'); return Promise.resolve(true); } // Choose the correct method to request or cancel full-screen mode @@ -1065,12 +1065,20 @@ define(rqDef, function(util) { return rtn; // return Promise.resolve(rtn); } + } else { + if (document.documentElement.webkitRequestFullscreen || document.documentElement.msRequestFullscreen) { + // We are in a Safari browser or IE11, and a click is required to enter full-screen mode + return 'click'; + } } }); } else { + // User wants to cancel full-screen mode and unlock the display orientation + if (screen && screen.orientation && screen.orientation.unlock) { + screen.orientation.unlock(); // NB This doesn't return a Promise + } return requestOrCancelFullScreen(); } - }