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

Commit

Permalink
support disabling pushstate with option
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Dec 17, 2012
1 parent fbd7288 commit 9b5ae16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion js/navigation/events/navigate.js
Expand Up @@ -18,6 +18,10 @@ define([ "jquery",

originalEventName: undefined,

isPushStateEnabled: function() {
return $.support.pushState && $.mobile && $.mobile.pushStateEnabled;
},

// TODO a lot of duplication between popstate and hashchange
popstate: function( event ) {
var newEvent = new $.Event( "navigate" ),
Expand Down Expand Up @@ -86,7 +90,7 @@ define([ "jquery",

self.bound = true;

if( $.support.pushState && self.pushStateEnabled ) {
if( self.isPushStateEnabled() ) {
self.originalEventName = "popstate";
$win.bind( "popstate.navigate", self.popstate );
} else {
Expand Down
10 changes: 5 additions & 5 deletions js/navigation/navigate.js
Expand Up @@ -11,13 +11,13 @@ define([
//>>excludeEnd("jqmBuildExclude");

(function( $, undefined ) {
var path = $.mobile.path, history, popstateEvent;
var path = $.mobile.path, history;

// TODO consider queueing navigation activity until previous activities have completed
// so that end users don't have to think about it. Punting for now
// TODO !! move the event bindings into callbacks on the navigate event
$.navigate = function( url, data, noEvents ) {
var state, href, parsed, loc, hash,
var state, href, parsed, loc, hash, popstateEvent,
resolutionUrl = path.isPath( url ) ? path.getLocation() : $.mobile.getDocumentUrl();

// Get the url as it would look squashed on to the current resolution url
Expand Down Expand Up @@ -69,7 +69,7 @@ define([
title: document.title
}, data);

if( $.support.pushState ) {
if( $.event.special.navigate.isPushStateEnabled() ) {
popstateEvent = new $.Event( "popstate" );
popstateEvent.originalEvent = {
type: "popstate",
Expand Down Expand Up @@ -134,7 +134,7 @@ define([

// Partly to support our test suite which manually alters the support
// value to test hashchange. Partly to prevent all around weirdness
if( !$.support.pushState ){
if( !$.event.special.navigate.isPushStateEnabled() ){
return;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ define([

// If pushstate is supported the state will be included in the popstate event
// data and appended to the navigate event. Late check here for late settings (eg tests)
if( $.support.pushState ) {
if( $.event.special.navigate.isPushStateEnabled() ) {
return;
}

Expand Down

0 comments on commit 9b5ae16

Please sign in to comment.