Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

added enable/disable switch using pushState navigation for pushstate branch. refs #16 #974

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -709,4 +712,9 @@
}
}
});

$.mobile.pushStateNavigate = function( bool ){
pushStateNavigate = bool && $.support.pushState;
};

})( jQuery );