Permalink
Browse files

Panel: update to use extend in the create method also exposed resetAc…

…tivePageHeight in mobile.navigation so panel can use it.
  • Loading branch information...
1 parent 40fb7d8 commit 27563481c4ccaf655e6288e8ef2beb845a035471 @arschmitz arschmitz committed Jan 17, 2013
Showing with 22 additions and 18 deletions.
  1. +6 −5 js/jquery.mobile.navigation.js
  2. +16 −13 js/widgets/panel.js
@@ -285,14 +285,15 @@ define( [
}
//simply set the active page's minimum height to screen height, depending on orientation
- function resetActivePageHeight() {
- var aPage = $( "." + $.mobile.activePageClass ),
+ $.mobile.resetActivePageHeight = function resetActivePageHeight( height ) {
+ var height = typeof height !== "undefined" ? height : getScreenHeight(),
+ aPage = $( "." + $.mobile.activePageClass ),
aPagePadT = parseFloat( aPage.css( "padding-top" ) ),
aPagePadB = parseFloat( aPage.css( "padding-bottom" ) ),
aPageBorderT = parseFloat( aPage.css( "border-top-width" ) ),
aPageBorderB = parseFloat( aPage.css( "border-bottom-width" ) );
- aPage.css( "min-height", getScreenHeight() - aPagePadT - aPagePadB - aPageBorderT - aPageBorderB );
+ aPage.css( "min-height", height - aPagePadT - aPagePadB - aPageBorderT - aPageBorderB );
}
//shared page enhancements
@@ -1312,8 +1313,8 @@ define( [
});
//set page min-heights to be device specific
- $.mobile.document.bind( "pageshow", resetActivePageHeight );
- $.mobile.window.bind( "throttledresize", resetActivePageHeight );
+ $.mobile.document.bind( "pageshow", $.mobile.resetActivePageHeight );
+ $.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight );
};//navreadyDeferred done callback
View
@@ -49,8 +49,9 @@ $.widget( "mobile.panel", $.mobile.widget, {
_create: function() {
var self = this,
$el = self.element,
+ page = $el.closest( ":jqmData(role='page')" ),
_getPageTheme = function() {
- var $theme = $.data( self._page[0], "mobilePage" ).options.theme,
+ var $theme = $.data( page[0], "mobilePage" ).options.theme,
$pageThemeClass = "ui-body-" + $theme;
return $pageThemeClass;
},
@@ -62,19 +63,19 @@ $.widget( "mobile.panel", $.mobile.widget, {
return $pannelInner;
},
_getWrapper = function() {
- var $wrapper = self._page.find( "." + self.options.classes.contentWrap );
+ var $wrapper = page.find( "." + self.options.classes.contentWrap );
if ( $wrapper.length === 0 ) {
- $wrapper = self._page.children( ".ui-header:not(:jqmData(position='fixed')), .ui-content:not(.ui-popup), .ui-footer:not(:jqmData(position='fixed'))" ).wrapAll( '<div class="' + self.options.classes.contentWrap + ' ' + _getPageTheme() + '" />' ).parent();
+ $wrapper = page.children( ".ui-header:not(:jqmData(position='fixed')), .ui-content:not(.ui-popup), .ui-footer:not(:jqmData(position='fixed'))" ).wrapAll( '<div class="' + self.options.classes.contentWrap + ' ' + _getPageTheme() + '" />' ).parent();
if ( $.support.cssTransform3d && !!self.options.animate ) {
$wrapper.addClass( self.options.classes.animate );
}
}
return $wrapper;
},
_getFixedToolbar = function() {
- var $fixedToolbar = self._page.find( "." + self.options.classes.contentFixedToolbar );
+ var $fixedToolbar = page.find( "." + self.options.classes.contentFixedToolbar );
if ( $fixedToolbar.length === 0 ) {
- $fixedToolbar = self._page.find( ".ui-header:jqmData(position='fixed'), .ui-footer:jqmData(position='fixed')" ).addClass( self.options.classes.contentFixedToolbar );
+ $fixedToolbar = page.find( ".ui-header:jqmData(position='fixed'), .ui-footer:jqmData(position='fixed')" ).addClass( self.options.classes.contentFixedToolbar );
if ( $.support.cssTransform3d && !!self.options.animate ) {
$fixedToolbar.addClass( self.options.classes.animate );
}
@@ -83,17 +84,19 @@ $.widget( "mobile.panel", $.mobile.widget, {
};
// expose some private props to other methods
- self._panelID = $el.attr( "id" );
- self._closeLink = $el.find( ":jqmData(rel='close')" );
- self._page = $el.closest( ":jqmData(role='page')" );
- self._pageTheme = _getPageTheme();
- self._pannelInner = _getPanelInner();
- self._wrapper = _getWrapper();
- self._fixedToolbar = _getFixedToolbar();
+ $.extend( this, {
+ _panelID: $el.attr( "id" ),
+ _closeLink: $el.find( ":jqmData(rel='close')" ),
+ _page: $el.closest( ":jqmData(role='page')" ),
+ _pageTheme: _getPageTheme(),
+ _pannelInner: _getPanelInner(),
+ _wrapper: _getWrapper(),
+ _fixedToolbar: _getFixedToolbar()
+ });
+
self._addPanelClasses();
self._wrapper.addClass( this.options.classes.contentWrapClosed );
self._fixedToolbar.addClass( this.options.classes.contentFixedToolbarClosed );
-
// add class to page so we can set "overflow-x: hidden;" for it to fix Android zoom issue
self._page.addClass( self.options.classes.pagePanel );

0 comments on commit 2756348

Please sign in to comment.