Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 6dcea68

Browse files
author
Gabriel Schulhof
committed
Helpers: resetActivePageHeight now accounts for external toolbars
Fixes gh-7134
1 parent 0b9186c commit 6dcea68

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

js/jquery.mobile.helpers.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,36 @@ define( [ "jquery", "./jquery.mobile.ns", "jquery-ui/jquery.ui.core" ], function
99
//>>excludeEnd("jqmBuildExclude");
1010
(function( $, window, undefined ) {
1111

12+
// Subtract the height of external toolbars from the page height, if the page does not have
13+
// internal toolbars of the same type
14+
var compensateToolbars = function( page, desiredHeight ) {
15+
var pageParent = page.parent(),
16+
toolbarsAffectingHeight = [],
17+
externalHeaders = pageParent.children( ":jqmData(role='header')" ),
18+
internalHeaders = page.children( ":jqmData(role='header')" ),
19+
externalFooters = pageParent.children( ":jqmData(role='footer')" ),
20+
internalFooters = page.children( ":jqmData(role='footer')" );
21+
22+
// If we have no internal headers, but we do have external headers, then their height
23+
// reduces the page height
24+
if ( internalHeaders.length === 0 && externalHeaders.length > 0 ) {
25+
toolbarsAffectingHeight = toolbarsAffectingHeight.concat( externalHeaders.toArray() );
26+
}
27+
28+
// If we have no internal footers, but we do have external footers, then their height
29+
// reduces the page height
30+
if ( internalFooters.length === 0 && externalFooters.length > 0 ) {
31+
toolbarsAffectingHeight = toolbarsAffectingHeight.concat( externalFooters.toArray() );
32+
}
33+
34+
$.each( toolbarsAffectingHeight, function( index, value ) {
35+
desiredHeight -= $( value ).outerHeight();
36+
});
37+
38+
// Height must be at least zero
39+
return Math.max( 0, desiredHeight );
40+
};
41+
1242
$.extend( $.mobile, {
1343
// define the window and the document objects
1444
window: $( window ),
@@ -139,7 +169,8 @@ define( [ "jquery", "./jquery.mobile.ns", "jquery-ui/jquery.ui.core" ], function
139169
pageHeight = page.height(),
140170
pageOuterHeight = page.outerHeight( true );
141171

142-
height = ( typeof height === "number" ) ? height : $.mobile.getScreenHeight();
172+
height = compensateToolbars( page,
173+
( typeof height === "number" ) ? height : $.mobile.getScreenHeight() );
143174

144175
page.css( "min-height", height - ( pageOuterHeight - pageHeight ) );
145176
},

0 commit comments

Comments
 (0)