@@ -107,62 +107,70 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
107107 } ,
108108
109109 _bindPageEvents : function ( ) {
110- var self = this ,
111- o = self . options ,
112- $el = self . element ;
113-
110+ this . _thisPage = this . element . closest ( ".ui-page" ) ;
114111 //page event bindings
115112 // Fixed toolbars require page zoom to be disabled, otherwise usability issues crop up
116113 // This method is meant to disable zoom while a fixed-positioned toolbar page is visible
117- $el . closest ( ".ui-page" )
118- . bind ( "pagebeforeshow" , function ( ) {
119- if ( o . disablePageZoom ) {
120- $ . mobile . zoom . disable ( true ) ;
121- }
122- if ( ! o . visibleOnPageShow ) {
123- self . hide ( true ) ;
124- }
125- } )
126- . bind ( "webkitAnimationStart animationstart updatelayout" , function ( ) {
127- var thisPage = this ;
128- if ( o . updatePagePadding ) {
129- self . updatePagePadding ( thisPage ) ;
130- }
131- } )
132- . bind ( "pageshow" , function ( ) {
133- var thisPage = this ;
134- self . updatePagePadding ( thisPage ) ;
135- if ( o . updatePagePadding ) {
136- $ ( window ) . bind ( "throttledresize." + self . widgetName , function ( ) {
137- self . updatePagePadding ( thisPage ) ;
138- } ) ;
139- }
140- } )
141- . bind ( "pagebeforehide" , function ( e , ui ) {
142- if ( o . disablePageZoom ) {
143- $ . mobile . zoom . enable ( true ) ;
144- }
145- if ( o . updatePagePadding ) {
146- $ ( window ) . unbind ( "throttledresize." + self . widgetName ) ;
147- }
114+ this . _on ( this . _thisPage , {
115+ "pagebeforeshow" : "_handlePageBeforeShow" ,
116+ "webkitAnimationStart animationstart updatelayout" : "_handleAnimationStart" ,
117+ "pageshow" : "_handlePageShow" ,
118+ "pagebeforehide" : "_handlePageBeforeHide"
119+ } ) ;
120+ } ,
148121
149- if ( o . trackPersistentToolbars ) {
150- var thisFooter = $ ( ".ui-footer-fixed:jqmData(id)" , this ) ,
151- thisHeader = $ ( ".ui-header-fixed:jqmData(id)" , this ) ,
152- nextFooter = thisFooter . length && ui . nextPage && $ ( ".ui-footer-fixed:jqmData(id='" + thisFooter . jqmData ( "id" ) + "')" , ui . nextPage ) || $ ( ) ,
153- nextHeader = thisHeader . length && ui . nextPage && $ ( ".ui-header-fixed:jqmData(id='" + thisHeader . jqmData ( "id" ) + "')" , ui . nextPage ) || $ ( ) ;
122+ _handlePageBeforeShow : function ( ) {
123+ var o = this . options ;
124+ if ( o . disablePageZoom ) {
125+ $ . mobile . zoom . disable ( true ) ;
126+ }
127+ if ( ! o . visibleOnPageShow ) {
128+ this . hide ( true ) ;
129+ }
130+ } ,
154131
155- if ( nextFooter . length || nextHeader . length ) {
132+ _handleAnimationStart : function ( ) {
133+ if ( this . options . updatePagePadding ) {
134+ this . updatePagePadding ( this . _thisPage ) ;
135+ }
136+ } ,
137+
138+ _handlePageShow : function ( ) {
139+ this . updatePagePadding ( this . _thisPage ) ;
140+ if ( this . options . updatePagePadding ) {
141+ this . _on ( $ ( window ) , { "throttledresize" : "updatePagePadding" } ) ;
142+ }
143+ } ,
156144
157- nextFooter . add ( nextHeader ) . appendTo ( $ . mobile . pageContainer ) ;
145+ _handlePageBeforeHide : function ( e , ui ) {
146+ var o = this . options ;
158147
159- ui . nextPage . one ( "pageshow" , function ( ) {
160- nextHeader . prependTo ( this ) ;
161- nextFooter . appendTo ( this ) ;
162- } ) ;
163- }
164- }
165- } ) ;
148+ if ( o . disablePageZoom ) {
149+ $ . mobile . zoom . enable ( true ) ;
150+ }
151+ if ( o . updatePagePadding ) {
152+ this . _off ( $ ( window ) , "throttledresize" ) ;
153+ }
154+
155+ if ( o . trackPersistentToolbars ) {
156+ var thisFooter = $ ( ".ui-footer-fixed:jqmData(id)" , this . _thisPage ) ,
157+ thisHeader = $ ( ".ui-header-fixed:jqmData(id)" , this . _thisPage ) ,
158+ nextFooter = thisFooter . length && ui . nextPage && $ ( ".ui-footer-fixed:jqmData(id='" + thisFooter . jqmData ( "id" ) + "')" , ui . nextPage ) || $ ( ) ,
159+ nextHeader = thisHeader . length && ui . nextPage && $ ( ".ui-header-fixed:jqmData(id='" + thisHeader . jqmData ( "id" ) + "')" , ui . nextPage ) || $ ( ) ;
160+
161+ if ( nextFooter . length || nextHeader . length ) {
162+
163+ nextFooter . add ( nextHeader ) . appendTo ( $ . mobile . pageContainer ) ;
164+
165+ this . _on ( ui . nextPage , {
166+ pageshow : function ( ) {
167+ nextHeader . prependTo ( ui . nextPage ) ;
168+ nextFooter . appendTo ( ui . nextPage ) ;
169+ this . _off ( ui . nextPage , "pageshow" ) ;
170+ }
171+ } ) ;
172+ }
173+ }
166174 } ,
167175
168176 _visible : true ,
@@ -176,7 +184,7 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
176184 // This behavior only applies to "fixed", not "fullscreen"
177185 if ( this . options . fullscreen ) { return ; }
178186
179- tbPage = tbPage || $el . closest ( ".ui-page" ) ;
187+ tbPage = tbPage || this . _thisPage || $el . closest ( ".ui-page" ) ;
180188 $ ( tbPage ) . css ( "padding-" + ( header ? "top" : "bottom" ) , $el . outerHeight ( ) + pos ) ;
181189 } ,
182190
0 commit comments