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

Commit 4d9575b

Browse files
author
Gabriel Schulhof
committed
[popup] Re-introduce interruptible transitions -- Fixes #5094
1 parent 016468d commit 4d9575b

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

js/widgets/popup.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ define( [ "jquery",
461461
.addClass( args.containerClassToAdd )
462462
.removeClass( args.classToRemove );
463463
} else {
464+
this._ui.container.removeClass( args.classToRemove );
464465
args.prereqs.container.resolve();
465466
}
466467
},
@@ -639,7 +640,7 @@ define( [ "jquery",
639640
this._trigger( "afterclose" );
640641
},
641642

642-
_close: function() {
643+
_close: function( immediate ) {
643644
this._ui.container.removeClass( "ui-popup-active" );
644645
this._page.removeClass( "ui-popup-open" );
645646

@@ -655,7 +656,7 @@ define( [ "jquery",
655656

656657
this._animate( {
657658
additionalCondition: this._ui.screen.hasClass( "in" ),
658-
transition: ( this._currentTransition || this.options.transition ),
659+
transition: ( immediate ? "none" : ( this._currentTransition || this.options.transition ) ),
659660
classToRemove: "in",
660661
screenClassToAdd: "out",
661662
containerClassToAdd: "reverse out",
@@ -684,12 +685,40 @@ define( [ "jquery",
684685
}
685686
},
686687

688+
_closePopup: function( e, data ) {
689+
var parsedDst, toUrl;
690+
691+
if ( e.type === "pagebeforechange" && data ) {
692+
// Determine whether we need to rapid-close the popup, or whether we can
693+
// take the time to run the closing transition
694+
if ( typeof data.toPage === "string" ) {
695+
parsedDst = data.toPage;
696+
} else {
697+
parsedDst = data.toPage.jqmData( "url" );
698+
}
699+
parsedDst = $.mobile.path.parseUrl( parsedDst );
700+
toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash;
701+
702+
if ( this._myUrl !== toUrl ) {
703+
// Going to a different page - close immediately
704+
this.options.container.unbind( this.options.closeEvents );
705+
this._close( true );
706+
} else {
707+
this._close();
708+
}
709+
710+
return;
711+
}
712+
713+
this._close();
714+
},
715+
687716
// any navigation event after a popup is opened should close the popup
688717
// NOTE the pagebeforechange is bound to catch navigation events that don't
689718
// alter the url (eg, dialogs from popups)
690719
_bindContainerClose: function() {
691720
this.options.container
692-
.one( this.options.closeEvents, $.proxy( this._close, this ));
721+
.one( this.options.closeEvents, $.proxy( this, "_closePopup" ) );
693722
},
694723

695724
// TODO no clear deliniation of what should be here and
@@ -731,7 +760,7 @@ define( [ "jquery",
731760
hashkey = $.mobile.dialogHashKey;
732761
activePage = $.mobile.activePage;
733762
currentIsDialog = activePage.is( ".ui-dialog" );
734-
url = $.mobile.urlHistory.getActive().url;
763+
this._myUrl = url = $.mobile.urlHistory.getActive().url;
735764
hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog;
736765
urlHistory = $.mobile.urlHistory;
737766

0 commit comments

Comments
 (0)