From 93b0b48a0668e937959ab1afe16500e1dfaca7ec Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 27 Mar 2013 13:34:24 -0700 Subject: [PATCH] create transition handler object --- js/jquery.mobile.navigation.js | 12 ++++++------ js/jquery.mobile.transition.js | 31 ++++++++++++++++++------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index ee2062ca9bd..f52466a4ee1 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -272,7 +272,7 @@ define( [ //isn't one in our transitionHandlers dictionary, use the default one. //call the handler immediately to kick-off the transition. var th = $.mobile.transitionHandlers[ transition || "default" ] || $.mobile.defaultTransitionHandler, - promise = th( transition, reverse, toPage, fromPage ); + promise = th.transition( transition, reverse, toPage, fromPage ); promise.done(function() { //trigger show/hide events @@ -296,7 +296,7 @@ define( [ aPageBorderB = parseFloat( aPage.css( "border-bottom-width" ) ); height = ( typeof height === "number" )? height : getScreenHeight(); - + aPage.css( "min-height", height - aPagePadT - aPagePadB - aPageBorderT - aPageBorderB ); }; @@ -430,7 +430,7 @@ define( [ .jqmData( "url", dataUrl ); } - + // If we failed to find a page in the DOM, check the URL to see if it // refers to the first page in the application. If it isn't a reference // to the first page and refers to non-existent embedded page, error out. @@ -452,7 +452,7 @@ define( [ return deferred.promise(); } } - + // If the page we are interested in is already in the DOM, // and the caller did not indicate that we should force a // reload of the file, we are done. Otherwise, track the @@ -461,7 +461,7 @@ define( [ if ( !settings.reloadPage ) { enhancePage( page, settings.role ); deferred.resolve( absUrl, options, page ); - //if we are reloading the page make sure we update the base if its not a prefetch + //if we are reloading the page make sure we update the base if its not a prefetch if( base && !options.prefetch ){ base.set(url); } @@ -499,7 +499,7 @@ define( [ }; } // Reset base to the default document base. - // only reset if we are not prefetching + // only reset if we are not prefetching if ( base && typeof options.prefetch === "undefined" ) { base.reset(); } diff --git a/js/jquery.mobile.transition.js b/js/jquery.mobile.transition.js index a7411e5e683..6fb1143fde0 100644 --- a/js/jquery.mobile.transition.js +++ b/js/jquery.mobile.transition.js @@ -9,14 +9,18 @@ define( [ "jquery", "./jquery.mobile.core" ], function( jQuery ) { //>>excludeEnd("jqmBuildExclude"); (function( $, window, undefined ) { -var createHandler = function( sequential ) { - - // Default to sequential - if ( sequential === undefined ) { - sequential = true; - } + $.mobile.TransitionHandler = function( sequential ) { + // Default to sequential + if ( sequential === undefined ) { + sequential = true; + } + + this.sequential = sequential; + }; - return function( name, reverse, $to, $from ) { + $.mobile.TransitionHandler.prototype.transition = function( name, reverse, $to, $from ) { + // TODO temporary + var self = this; var deferred = new $.Deferred(), reverseClass = reverse ? " reverse" : "", @@ -48,7 +52,7 @@ var createHandler = function( sequential ) { }, startOut = function() { // if it's not sequential, call the doneOut transition to start the TO page animating in simultaneously - if ( !sequential ) { + if ( !self.sequential ) { doneOut(); } else { @@ -64,7 +68,7 @@ var createHandler = function( sequential ) { doneOut = function() { - if ( $from && sequential ) { + if ( $from && self.sequential ) { cleanFrom(); } @@ -105,7 +109,7 @@ var createHandler = function( sequential ) { doneIn = function() { - if ( !sequential ) { + if ( !self.sequential ) { if ( $from ) { cleanFrom(); @@ -138,11 +142,12 @@ var createHandler = function( sequential ) { return deferred.promise(); }; -}; + + // generate the handlers from the above -var sequentialHandler = createHandler(), - simultaneousHandler = createHandler( false ), +var sequentialHandler = new $.mobile.TransitionHandler(), + simultaneousHandler = new $.mobile.TransitionHandler( false ), defaultGetMaxScrollForTransition = function() { return $.mobile.getScreenHeight() * 3; };