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

Commit

Permalink
Helpers: resetActivePageHeight() ignores fixed toolbars
Browse files Browse the repository at this point in the history
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 gh-7802
Fixes gh-7739
  • Loading branch information
Gabriel Schulhof committed Oct 30, 2014
1 parent 9e73ab4 commit 2060bca
Show file tree
Hide file tree
Showing 3 changed files with 842 additions and 3 deletions.
25 changes: 22 additions & 3 deletions js/helpers.js
Expand Up @@ -10,13 +10,32 @@ define( [ "jquery", "./ns", "jquery-ui/jquery.ui.core" ], function( jQuery ) {
(function( $, window, undefined ) {

// Subtract the height of external toolbars from the page height, if the page does not have
// internal toolbars of the same type
// internal toolbars of the same type. We take care to use the widget options if we find a
// widget instance and the element's data-attributes otherwise.
var compensateToolbars = function( page, desiredHeight ) {
var pageParent = page.parent(),
toolbarsAffectingHeight = [],
externalHeaders = pageParent.children( ":jqmData(role='header')" ),

// We use this function to filter fixed toolbars with option updatePagePadding set to
// true (which is the default) from our height subtraction, because fixed toolbars with
// option updatePagePadding set to true compensate for their presence by adding padding
// to the active page. We want to avoid double-counting by also subtracting their
// height from the desired page height.
noPadders = function() {
var theElement = $( this ),
widgetOptions = $.mobile.toolbar && theElement.data( "mobile-toolbar" ) ?
theElement.toolbar( "option" ) : {
position: theElement.attr( "data-" + $.mobile.ns + "position" ),
updatePagePadding: ( theElement.attr( "data-" + $.mobile.ns +
"update-page-padding" ) !== false )
};

return !( widgetOptions.position === "fixed" &&
widgetOptions.updatePagePadding === true );
},
externalHeaders = pageParent.children( ":jqmData(role='header')" ).filter( noPadders ),
internalHeaders = page.children( ":jqmData(role='header')" ),
externalFooters = pageParent.children( ":jqmData(role='footer')" ),
externalFooters = pageParent.children( ":jqmData(role='footer')" ).filter( noPadders ),
internalFooters = page.children( ":jqmData(role='footer')" );

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

0 comments on commit 2060bca

Please sign in to comment.