cleaned up vars for transition and back conditions - removed a couple unnecessary vars. Added $.mobile.defaultTransition, which defaults to "slide" but can be set to other transition names, or false, to disable default transitions (note: this won't prevent data-transition attrs from working when manually applied).

This commit is contained in:
scottjehl 2010-11-06 14:04:59 -04:00
parent b0d1063ee8
commit c707f63918

View file

@ -6,6 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function( $, window, undefined ) {
//define jQuery.mobile hash
@ -27,6 +28,9 @@
//available CSS transitions
transitions: ['slide', 'slideup', 'slidedown', 'pop', 'flip', 'fade'],
//set default transition
defaultTransition: 'slide',
//support conditions that must be met in order to proceed
gradeA: function(){
return jQuery.support.mediaquery;
@ -48,12 +52,9 @@
$startPage,
$pageContainer,
activeClickedLink = null,
pageTransition,
forceBack,
transitionDuration = 350,
urlStack = [ {
url: location.hash.replace( /^#/, "" ),
transition: "slide"
url: location.hash.replace( /^#/, "" )
} ],
focusable = "[tabindex],a,button:visible,select:visible,input",
nextPageRole = null,
@ -150,8 +151,8 @@
}
else {
//use ajax
var pageTransition = $this.data( "transition" ) || "slide",
forceBack = $this.data( "back" ) || undefined,
var transition = $this.data( "transition" ),
back = $this.data( "back" ),
changeHashOnSuccess = !$this.is( $.mobile.nonHistorySelectors );
nextPageRole = $this.attr( "data-rel" );
@ -163,7 +164,7 @@
href.replace(/^#/,'');
changePage(href, pageTransition, forceBack, changeHashOnSuccess);
changePage(href, transition, back, changeHashOnSuccess);
}
event.preventDefault();
});
@ -233,7 +234,7 @@
isFormRequest = false,
duplicateCachedPage = null,
back = (back !== undefined) ? back : ( urlStack.length > 1 && urlStack[ urlStack.length - 2 ].url === url ),
transition = (transition !== undefined) ? transition : ( pageTransition || "slide" );
transition = transition || $.mobile.defaultTransition;
if( $.type(to) === "object" && to.url ){
url = to.url,
@ -246,10 +247,6 @@
data = undefined;
}
}
//unset pageTransition, forceBack
pageTransition = undefined;
forceBack = undefined;
//reset base to pathname for new request
resetBaseURL();