@@ -1389,13 +1389,28 @@ define( [
1389
1389
//transition is false if it's the first page, undefined otherwise (and may be overridden by default)
1390
1390
transition = $ . mobile . urlHistory . stack . length === 0 ? "none" : undefined ,
1391
1391
1392
- originalCondition = ( urlHistory . stack . length > 1 && to . indexOf ( $ . mobile . dialogHashKey ) > - 1 ) ,
1393
- destinationIsFirstPageUrl = ( to === $ . mobile . dialogHashKey || to . replace ( $ . mobile . dialogHashKey , "" ) === ( urlHistory . stack [ 0 ] || { url : "" } ) . url ) ,
1394
1392
activeEntryHasHashKey = ( ( urlHistory . getActive ( ) || { url : "" } ) . url . indexOf ( $ . mobile . dialogHashKey ) > - 1 ) ,
1395
1393
activePageIsDialog = ( $ . mobile . activePage ? $ . mobile . activePage . is ( ".ui-dialog" ) : false ) ,
1396
- specialCaseForDialogs = ( urlHistory . activeIndex === 1 && urlHistory . firstVisitedPageHasDialogHash && destinationIsFirstPageUrl )
1397
- ? ( activeEntryHasHashKey && ! activePageIsDialog )
1398
- : originalCondition ,
1394
+
1395
+ // Definition of the corner case where the initial page has a dialog hash key and we're going to it
1396
+ dstIsDialogHashInitialPage =
1397
+ ( urlHistory . activeIndex === 1 &&
1398
+ urlHistory . firstVisitedPageHasDialogHash &&
1399
+ // Does the hash point to the first page? There are two ways that it can:
1400
+ // 1. When the initial page URL has the form:
1401
+ // http://domain/path/to/file.html#&ui-state=dialog
1402
+ ( to === $ . mobile . dialogHashKey ||
1403
+ // 2. When the initial page URL has the form:
1404
+ // http://domain/path/to/file.html#/path/to/another/file.html#&ui-state=dialog
1405
+ to . replace ( $ . mobile . dialogHashKey , "" ) === ( urlHistory . stack [ 0 ] || { url : "" } ) . url ) ) ,
1406
+
1407
+ // Decide whether we need to apply the special logic that deals with dialogs
1408
+ specialCaseForDialogs =
1409
+ dstIsDialogHashInitialPage
1410
+ // Decide for the corner case where the initial page has a dialog hash in the URL
1411
+ ? ( activeEntryHasHashKey && ! activePageIsDialog )
1412
+ // Decide for the general case
1413
+ : ( urlHistory . stack . length > 1 && to . indexOf ( $ . mobile . dialogHashKey ) > - 1 ) ,
1399
1414
1400
1415
// default options for the changPage calls made after examining the current state
1401
1416
// of the page and the hash
@@ -1448,9 +1463,7 @@ define( [
1448
1463
//determine if we're heading forward or backward and continue accordingly past
1449
1464
//the current dialog
1450
1465
1451
- if ( urlHistory . activeIndex === 1 &&
1452
- urlHistory . firstVisitedPageHasDialogHash &&
1453
- destinationIsFirstPageUrl ) {
1466
+ if ( dstIsDialogHashInitialPage ) {
1454
1467
urlHistory . activeIndex = 0 ;
1455
1468
}
1456
1469
else {
0 commit comments