Skip to content

Commit e612aa8

Browse files
author
Gabriel Schulhof
committed
[popup] Do not worry so much about keeping focus inside the popup. Instead, handle the case where the user tries to open the same popup while it is already open.
1 parent 92c5f34 commit e612aa8

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

js/jquery.mobile.navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ define( [
13811381
role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined;
13821382

13831383
if ( role === "popup" ) {
1384-
$.mobile.popup.handleLink( $link, removeActiveLinkClass );
1384+
$.mobile.popup.handleLink( $link );
13851385
}
13861386
else {
13871387
$.mobile.changePage( href, { transition: transition, reverse: reverse, role: role } );

js/jquery.mobile.popup.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,6 @@ define( [ "jquery",
6969

7070
ui.screen.bind( "vclick", function( e ) { eatEventAndClose( e ); });
7171

72-
// St00pid browser, y u no tell me where focus go?
73-
ui.container.bind( "focusout focusin", function( e ) {
74-
function maybeClearTimeout() {
75-
if ( self._focusTimeout ) {
76-
clearTimeout( self._focusTimeout );
77-
self._focusTimeout = 0;
78-
}
79-
}
80-
81-
if ( self._isOpen ) {
82-
if ( e.type === "focusout" ) {
83-
maybeClearTimeout();
84-
self._focusTimeout = setTimeout( function() {
85-
self._ui.container.focus();
86-
}, 100 );
87-
}
88-
else
89-
if ( e.type === "focusin" ) {
90-
maybeClearTimeout();
91-
}
92-
}
93-
});
94-
9572
$( window )
9673
.bind( "resize", function( e ) {
9774
if ( self._isOpen ) {
@@ -660,7 +637,7 @@ define( [ "jquery",
660637
}
661638
}
662639

663-
$.mobile.popup.handleLink = function( $link, whenOpenedCb ) {
640+
$.mobile.popup.handleLink = function( $link ) {
664641
var closestPage = $link.closest( ":jqmData(role='page')" ),
665642
scope = ( ( closestPage.length === 0 ) ? $( "body" ) : closestPage ),
666643
popup = $( $link.attr( "href" ), scope[0] ),
@@ -670,16 +647,17 @@ define( [ "jquery",
670647
offset = $link.offset();
671648

672649
popup
673-
.one( "opened", whenOpenedCb )
674650
.one( "closed", function() { $link.focus(); } )
675651
.popup( "open",
676652
offset.left + $link.outerWidth() / 2,
677653
offset.top + $link.outerHeight() / 2,
678654
$link.jqmData( "transition" ) );
679655
}
680-
else {
681-
whenOpenedCb();
682-
}
656+
657+
//remove after delay
658+
setTimeout( function() {
659+
$link.removeClass( $.mobile.activeBtnClass );
660+
}, 300 );
683661
};
684662

685663
$( document ).bind( "pagecreate create", function( e ) {

0 commit comments

Comments
 (0)