Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove vertical scrollbar (for unit tests) #599

Closed
wants to merge 14 commits into from
28 changes: 23 additions & 5 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,22 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'cookies','abstractFilesystemAcc
* Resize the IFrame height, so that it fills the whole available height in the window
*/
function resizeIFrame() {
var height = $(window).outerHeight()
- $("#top").outerHeight(true)
// TODO : this 5 should be dynamically computed, and not hard-coded
- 5;
$(".articleIFrame").css("height", height + "px");
var headerStyles = getComputedStyle(document.getElementById('top'));
var iframe = document.getElementById('articleContent');
var region = document.getElementById('search-article');
if (iframe.style.display === 'none') {
// We are in About or Configuration, so we only set the region height
region.style.height = window.innerHeight + 'px';
} else {
// IE cannot retrieve computed headerStyles till the next paint, so we wait a few ticks
setTimeout(function() {
// Get header height *including* its bottom margin
var headerHeight = parseFloat(headerStyles.height) + parseFloat(headerStyles.marginBottom);
iframe.style.height = window.innerHeight - headerHeight + 'px';
// We have to allow a minimum safety margin of 10px for 'iframe' and 'header' to fit within 'region'
region.style.height = window.innerHeight + 10 + 'px';
}, 100);
}
}
$(document).ready(resizeIFrame);
$(window).resize(resizeIFrame);
Expand Down Expand Up @@ -250,6 +261,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'cookies','abstractFilesystemAcc
$("#welcomeText").hide();
goToMainArticle();
}
// Use a timeout of 400ms because uiUtil.applyAnimationToSection uses a timeout of 300ms
setTimeout(resizeIFrame, 400);
return false;
});
$('#btnConfigure').on('click', function(e) {
Expand All @@ -274,6 +287,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'cookies','abstractFilesystemAcc
$('.alert').hide();
refreshAPIStatus();
refreshCacheStatus();
// Use a timeout of 400ms because uiUtil.applyAnimationToSection uses a timeout of 300ms
setTimeout(resizeIFrame, 400);
return false;
});
$('#btnAbout').on('click', function(e) {
Expand All @@ -297,6 +312,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'cookies','abstractFilesystemAcc
$('#articleListWithHeader').hide();
$("#searchingArticles").hide();
$('.alert').hide();
// Use a timeout of 400ms because uiUtil.applyAnimationToSection uses a timeout of 300ms
setTimeout(resizeIFrame, 400);
return false;
});
$('input:radio[name=contentInjectionMode]').on('change', function(e) {
Expand Down Expand Up @@ -1067,6 +1084,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'cookies','abstractFilesystemAcc
docBody.addEventListener('dragover', handleIframeDragover);
docBody.addEventListener('drop', handleIframeDrop);
}
resizeIFrame();
// Reset UI when the article is unloaded
if (iframeArticleContent.contentWindow) iframeArticleContent.contentWindow.onunload = function () {
$("#articleList").empty();
Expand Down