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

Commit e09195f

Browse files
author
Gabriel Schulhof
committed
[popup] Re-introduce interruptible transitions -- Fixes #5094
Conflicts: js/widgets/popup.js
1 parent 6c9135d commit e09195f

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
@@ -451,6 +451,7 @@ define( [ "jquery",
451451
.addClass( args.containerClassToAdd )
452452
.removeClass( args.classToRemove );
453453
} else {
454+
this._ui.container.removeClass( args.classToRemove );
454455
args.prereqs.container.resolve();
455456
}
456457
},
@@ -629,7 +630,7 @@ define( [ "jquery",
629630
self._trigger( "afterclose" );
630631
},
631632

632-
_close: function() {
633+
_close: function( immediate ) {
633634
this._ui.container.removeClass( "ui-popup-active" );
634635
this._page.removeClass( "ui-popup-open" );
635636

@@ -645,7 +646,7 @@ define( [ "jquery",
645646

646647
this._animate( {
647648
additionalCondition: this._ui.screen.hasClass( "in" ),
648-
transition: ( this._currentTransition || this.options.transition ),
649+
transition: ( immediate ? "none" : ( this._currentTransition || this.options.transition ) ),
649650
classToRemove: "in",
650651
screenClassToAdd: "out",
651652
containerClassToAdd: "reverse out",
@@ -683,14 +684,42 @@ define( [ "jquery",
683684
}
684685
},
685686

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

692721
self.options.container
693-
.one( self.options.closeEvents, $.proxy( self._close, self ));
722+
.one( self.options.closeEvents, $.proxy( self, "_closePopup" ) );
694723
},
695724

696725
// TODO no clear deliniation of what should be here and
@@ -732,7 +761,7 @@ define( [ "jquery",
732761
hashkey = $.mobile.dialogHashKey;
733762
activePage = $.mobile.activePage;
734763
currentIsDialog = activePage.is( ".ui-dialog" );
735-
url = $.mobile.urlHistory.getActive().url;
764+
this._myUrl = url = $.mobile.urlHistory.getActive().url;
736765
hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog;
737766
urlHistory = $.mobile.urlHistory;
738767

0 commit comments

Comments
 (0)