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

Commit

Permalink
move event blocking to navigator object
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Dec 18, 2012
1 parent 7d438a4 commit dc37693
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/jquery.mobile.navigation.js
Expand Up @@ -844,7 +844,7 @@ define( [
// Set the location hash.
if ( settings.changeHash !== false && url ) {
//disable hash listening temporarily
urlHistory.ignoreNextHashChange = true;
$.navigate.navigator.ignoreNextHashChange = true;

// rebuilding the hash here since we loose it earlier on
// TODO preserve the originally passed in path
Expand Down
26 changes: 13 additions & 13 deletions js/navigation/navigator.js
Expand Up @@ -77,9 +77,9 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {
// history management. In the case of hashchange we don't swallow it
// if there will be no hashchange fired (since that won't reset the value)
// and will swallow the following hashchange
this.history.ignoreNextHashChange = true;
this.ignoreNextHashChange = true;
if( noEvents && hash !== path.stripHash(path.parseLocation().hash) ) {
this.history.preventNextHashChange = noEvents;
this.preventNextHashChange = noEvents;
}

// IMPORTANT in the case where popstate is supported the event will be triggered
Expand Down Expand Up @@ -112,7 +112,7 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {
// Trigger a new faux popstate event to replace the one that we
// caught that was triggered by the hash setting above.
if( !noEvents ) {
this.history.ignoreNextPopState = true;
this.ignoreNextPopState = true;
$( window ).trigger( popstateEvent );
}
}
Expand Down Expand Up @@ -142,16 +142,16 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {

// If this is the popstate triggered by the actual alteration of the hash
// prevent it completely to prevent handling
if( this.history.ignoreNextHashChange ) {
this.history.ignoreNextHashChange = false;
if( this.ignoreNextHashChange ) {
this.ignoreNextHashChange = false;
event.stopImmediatePropagation();
return;
}

// if this is the popstate triggered after the replaceState call in the navigate
// method, then simply ignore it
if( this.history.ignoreNextPopState ) {
this.history.ignoreNextPopState = false;
if( this.ignoreNextPopState ) {
this.ignoreNextPopState = false;
return;
}

Expand Down Expand Up @@ -219,23 +219,23 @@ define([ "jquery", "./events/navigate", "./path", "./history" ], function( $ ) {

// On occasion explicitly want to prevent the next hash from propogating because we only
// with to alter the url to represent the new state do so here
if( this.history.preventNextHashChange ){
this.history.preventNextHashChange = false;
this.history.ignoreNextHashChange = false;
if( this.preventNextHashChange ){
this.preventNextHashChange = false;
this.ignoreNextHashChange = false;
event.stopImmediatePropagation();
return;
}

// If the hashchange has been explicitly ignored or we have no history at
// this point skip the history managment and the addition of the history
// entry to the event for the `navigate` bindings
if( this.history.ignoreNextHashChange ) {
this.history.ignoreNextHashChange = false;
if( this.ignoreNextHashChange ) {
this.ignoreNextHashChange = false;
}

// If the stack is empty (it's been reset or some such) don't return,
// we need to record it in the missing callback below.
if( this.history.ignoreNextHashChange && this.history.stack.length > 0 ) {
if( this.ignoreNextHashChange && this.history.stack.length > 0 ) {
return;
}

Expand Down

0 comments on commit dc37693

Please sign in to comment.