Skip to content

Commit

Permalink
Popup: updated the safelyBlur method Gabriels feedback. TESTS FAIL.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldeluca committed Oct 16, 2014
1 parent 66e5702 commit 3118be2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/widgets/popup.js
Expand Up @@ -299,7 +299,7 @@ $.widget( "mobile.popup", {
target = $( targetElement );
if ( !$.contains( ui.container[ 0 ], targetElement ) ) {
$( this.document[ 0 ].activeElement ).one( "focus", $.proxy( function(/* theEvent */) {
this._safelyBlur( targetElement );
this._safelyBlur( ui.container[ 0 ] );
}, this ) );
ui.focusElement.focus();
theEvent.preventDefault();
Expand Down Expand Up @@ -631,9 +631,14 @@ $.widget( "mobile.popup", {
}
},

_safelyBlur: function( currentElement ){
if (currentElement !== this.window[ 0 ] && currentElement.nodeName.toLowerCase() !== "body") {
$( currentElement ).blur();
_safelyBlur: function( container ){
if ( container !== this.window[ 0 ] && container.nodeName.toLowerCase() !== "body") {
var ui = this._ui;
// Find a focusable element within the container.
$( container ).find( ":focusable" ).blur( function() {
// If we find such an element, we assign it to this._ui.focusElement, which _handleDocumentFocusIn() later uses to redirect focus away from an element that is not part of the popup and onto an element that is.
ui.focusElement = this;
} );
}
},

Expand All @@ -646,7 +651,7 @@ $.widget( "mobile.popup", {

// Check to see if currElement is not a child of the container. If it's not, blur
if ( !$.contains( this._ui.container[ 0 ], this.document[ 0 ].activeElement ) ) {
this._safelyBlur( this.document[ 0 ].activeElement );
this._safelyBlur( this._ui.container[ 0 ] );
}
this._ignoreResizeEvents();
if ( id ) {
Expand Down

0 comments on commit 3118be2

Please sign in to comment.