From 5e31a4e8120955090a3bf4190cbe2561a061cd04 Mon Sep 17 00:00:00 2001 From: Kazuhiro Osawa Date: Fri, 4 Feb 2011 21:50:01 +0900 Subject: [PATCH] added switch enable and disable which changes navigation using pushState $.mobile.pushStateNavigate(true); // using pushState navigation (default) $.mobile.pushStateNavigate(flase); // unusing pushState navigation --- js/jquery.mobile.navigation.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index ee952323edc..17caacdf7af 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -17,7 +17,7 @@ //get path from current hash, or from a file path get: function( newPath ){ if ( newPath == undefined ) { - if ( $.support.pushState ) { + if ( pushStateNavigate ) { newPath = location.pathname; } else { newPath = location.hash; @@ -34,7 +34,7 @@ //set location hash to path set: function( path ) { - if ( $.support.pushState ) { + if ( pushStateNavigate ) { //replace with a proper page title from the loaded page's title element, or title attr on a multipage history.pushState({ "url": path }, null, path ); } else { @@ -140,7 +140,10 @@ popEnabled = false, //nonsense hash change key for dialogs, so they create a history entry - dialogHashKey = "&ui-state=dialog"; + dialogHashKey = "&ui-state=dialog", + + //using pushState navigation + pushStateNavigate = $.support.pushState; //existing base tag? var $base = $head.children("base"), @@ -670,7 +673,7 @@ transition = triggered ? false : undefined; // replace current location in loading first page - if ($.support.pushState) { + if (pushStateNavigate) { if (triggered) { if (to == "") { //using pathname for first page if hash is empty @@ -709,4 +712,9 @@ } } }); + + $.mobile.pushStateNavigate = function( bool ){ + pushStateNavigate = bool && $.support.pushState; + }; + })( jQuery );