diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 6661fda4..81c711ed 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -173,6 +173,12 @@ //kill the keyboard $( window.document.activeElement ).add(':focus').blur(); + function defaultTransition(){ + if(transition === undefined){ + transition = $.mobile.defaultTransition; + } + } + // if the new href is the same as the previous one if ( back ) { var pop = urlStack.pop(); @@ -181,9 +187,12 @@ if( pop && !transition ){ transition = pop.transition; } + + // ensure a transition has been set where pop is undefined + defaultTransition(); } else { - // if no transition passed set the default - transition = transition || $.mobile.defaultTransition; + // If no transition has been passed + defaultTransition(); // push the url and transition onto the stack urlStack.push({ url: url, transition: transition }); @@ -247,8 +256,6 @@ addContainerClass('ui-mobile-viewport-perspective'); } - console.log(transition); - addContainerClass('ui-mobile-viewport-transitioning'); // animate in / out diff --git a/tests/unit/navigation/index.html b/tests/unit/navigation/index.html index ae4b0243..d2910d52 100644 --- a/tests/unit/navigation/index.html +++ b/tests/unit/navigation/index.html @@ -12,7 +12,7 @@ - +n @@ -84,5 +84,9 @@
+ +
+ +
diff --git a/tests/unit/navigation/navigation_core.js b/tests/unit/navigation/navigation_core.js index 34dc120f..b1af8fb8 100644 --- a/tests/unit/navigation/navigation_core.js +++ b/tests/unit/navigation/navigation_core.js @@ -4,14 +4,14 @@ // TODO move tests to navigation_transitions.js var perspective = "ui-mobile-viewport-perspective", transitioning = "ui-mobile-viewport-transitioning", - animationCompleteFn = $.fn.animationComplete, + animationCompleteFn = $.fn.animationComplete, removeBodyClasses = function(){ $("body").removeClass([perspective, transitioning].join(" ")); }, removePageTransClasses = function(){ - $("[data-role='page']").removeClass("in out fade slide flip reverse"); + $("[data-role='page']").removeClass("in out fade slide flip reverse pop"); }; module('jquery.mobile.navigation.js', { @@ -26,7 +26,7 @@ module('jquery.mobile.navigation.js', { // required cleanup from animation complete mocking removeBodyClasses(); - } + } }); test( "changePage applys perspective class to mobile viewport for flip", function(){ @@ -94,3 +94,17 @@ test( "previous transition used when not set and going back through url stack", start(); }, 900); }); + +test( "default transition is slide", function(){ + stop(); + setTimeout(function(){ + //guarantee that we check only the newest changes + removePageTransClasses(); + + $("#default-trans > a").click(); + + ok($("#no-trans").hasClass("slide"), "has slide class"); + + start(); + }, 900); +});