Skip to content

Commit 2060bca

Browse files
author
Gabriel Schulhof
committed
Helpers: resetActivePageHeight() ignores fixed toolbars
Any external fixed toolbar widget with option updatePagePadding set to true need not be accounted for when calculating page height, because it updates the page padding to account for itself. Closes jquery-archivegh-7802 Fixes jquery-archivegh-7739
1 parent 9e73ab4 commit 2060bca

File tree

3 files changed

+842
-3
lines changed

3 files changed

+842
-3
lines changed

js/helpers.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,32 @@ define( [ "jquery", "./ns", "jquery-ui/jquery.ui.core" ], function( jQuery ) {
1010
(function( $, window, undefined ) {
1111

1212
// Subtract the height of external toolbars from the page height, if the page does not have
13-
// internal toolbars of the same type
13+
// internal toolbars of the same type. We take care to use the widget options if we find a
14+
// widget instance and the element's data-attributes otherwise.
1415
var compensateToolbars = function( page, desiredHeight ) {
1516
var pageParent = page.parent(),
1617
toolbarsAffectingHeight = [],
17-
externalHeaders = pageParent.children( ":jqmData(role='header')" ),
18+
19+
// We use this function to filter fixed toolbars with option updatePagePadding set to
20+
// true (which is the default) from our height subtraction, because fixed toolbars with
21+
// option updatePagePadding set to true compensate for their presence by adding padding
22+
// to the active page. We want to avoid double-counting by also subtracting their
23+
// height from the desired page height.
24+
noPadders = function() {
25+
var theElement = $( this ),
26+
widgetOptions = $.mobile.toolbar && theElement.data( "mobile-toolbar" ) ?
27+
theElement.toolbar( "option" ) : {
28+
position: theElement.attr( "data-" + $.mobile.ns + "position" ),
29+
updatePagePadding: ( theElement.attr( "data-" + $.mobile.ns +
30+
"update-page-padding" ) !== false )
31+
};
32+
33+
return !( widgetOptions.position === "fixed" &&
34+
widgetOptions.updatePagePadding === true );
35+
},
36+
externalHeaders = pageParent.children( ":jqmData(role='header')" ).filter( noPadders ),
1837
internalHeaders = page.children( ":jqmData(role='header')" ),
19-
externalFooters = pageParent.children( ":jqmData(role='footer')" ),
38+
externalFooters = pageParent.children( ":jqmData(role='footer')" ).filter( noPadders ),
2039
internalFooters = page.children( ":jqmData(role='footer')" );
2140

2241
// If we have no internal headers, but we do have external headers, then their height

0 commit comments

Comments
 (0)