Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[navigation] Handle corner case where first visited page has a dialog…

… hash key - Fixes: #4423

Conflicts:

	js/jquery.mobile.popup.js
  • Loading branch information...
commit 52745d26bfd25bbe6f30c9ddabefe20338ea9fb6 1 parent 60c83ec
@gabrielschulhof gabrielschulhof authored
Showing with 38 additions and 16 deletions.
  1. +38 −16 js/jquery.mobile.navigation.js
View
54 js/jquery.mobile.navigation.js
@@ -307,7 +307,7 @@ define( [
directHashChange: function( opts ) {
var back , forward, newActiveIndex, prev = this.getActive();
- // check if url isp in history and if it's ahead or behind current page
+ // check if url is in history and if it's ahead or behind current page
$.each( urlHistory.stack, function( i, historyEntry ) {
//if the url is in the stack, it's a forward or a back
@@ -1363,6 +1363,14 @@ define( [
//transition is false if it's the first page, undefined otherwise (and may be overridden by default)
transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined,
+ originalCondition = ( urlHistory.stack.length > 1 && to.indexOf( $.mobile.dialogHashKey ) > -1 ),
+ destinationIsFirstPageUrl = ( to === $.mobile.dialogHashKey || to.replace( $.mobile.dialogHashKey, "" ) === ( urlHistory.stack[0] || { url: "" } ).url ),
+ activeEntryHasHashKey = ( ( urlHistory.getActive() || { url: "" } ).url.indexOf( $.mobile.dialogHashKey ) > -1 ),
+ activePageIsDialog = ( $.mobile.activePage ? $.mobile.activePage.is( ".ui-dialog" ) : false ),
+ specialCaseForDialogs = ( urlHistory.activeIndex === 1 && urlHistory.firstVisitedPageHasDialogHash && destinationIsFirstPageUrl )
+ ? ( activeEntryHasHashKey && !activePageIsDialog )
+ : originalCondition,
+
// default options for the changPage calls made after examining the current state
// of the page and the hash
changePageOptions = {
@@ -1371,6 +1379,11 @@ define( [
fromHashChange: true
};
+ // Record the fact that the first visited page has a dialogHashKey
+ if ( urlHistory.stack.length === 0 && to.indexOf( dialogHashKey ) > -1 ) {
+ urlHistory.firstVisitedPageHasDialogHash = true;
+ }
+
//if listening is disabled (either globally or temporarily), or it's a dialog hash
if( !$.mobile.hashListeningEnabled || urlHistory.ignoreNextHashChange ) {
urlHistory.ignoreNextHashChange = false;
@@ -1378,22 +1391,9 @@ define( [
}
// special case for dialogs
- if( urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 ) {
+ if( specialCaseForDialogs ) {
- // If current active page is not a dialog skip the dialog and continue
- // in the same direction
- if(!$.mobile.activePage.is( ".ui-dialog" )) {
- //determine if we're heading forward or backward and continue accordingly past
- //the current dialog
- urlHistory.directHashChange({
- currentUrl: to,
- isBack: function() { window.history.back(); },
- isForward: function() { window.history.forward(); }
- });
-
- // prevent changePage()
- return;
- } else {
+ if( activePageIsDialog ) {
// if the current active page is a dialog and we're navigating
// to a dialog use the dialog objected saved in the stack
urlHistory.directHashChange({
@@ -1416,6 +1416,28 @@ define( [
}
});
}
+ // If current active page is not a dialog skip the dialog and continue
+ // in the same direction
+ else {
+ //determine if we're heading forward or backward and continue accordingly past
+ //the current dialog
+
+ if ( urlHistory.activeIndex === 1 &&
+ urlHistory.firstVisitedPageHasDialogHash &&
+ destinationIsFirstPageUrl ) {
+ urlHistory.activeIndex = 0;
+ }
+ else {
+ urlHistory.directHashChange({
+ currentUrl: to,
+ isBack: function() { window.history.back(); },
+ isForward: function() { window.history.forward(); }
+ });
+ }
+
+ // prevent changePage()
+ return;
+ }
}
//if to is defined, load it
Please sign in to comment.
Something went wrong with that request. Please try again.