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

Commit

Permalink
[popup] To implement click-on-screen-to-dismiss-popup one must bind t…
Browse files Browse the repository at this point in the history
…he "vclick" handler to the document rather than the screen, in order to prevent unpleasantness on Android 4.0. WP7 nevertheless requires the code to remain as is, because handling the screen vclick after it has bubbled to the document causes text and inputs underneath the screen to handle and then swallow the event.
  • Loading branch information
Gabriel Schulhof committed Aug 15, 2012
1 parent 5463fc8 commit 5572b5e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions js/widgets/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ define( [ "jquery",
e.preventDefault();
e.stopImmediatePropagation();
this.close();
return false;
},

_handleWindowKeyUp: function( e ) {
if ( this._isOpen && e.keyCode === $.mobile.keyCode.ESCAPE ) {
this._eatEventAndClose( e );
return this._eatEventAndClose( e );
}
},

Expand Down Expand Up @@ -116,6 +117,12 @@ define( [ "jquery",
}
},

_closeOnScreenVClick: function( e ) {
if ( e.target === this._ui.screen[ 0 ] ) {
return this._eatEventAndClose( e );
}
},

_create: function() {
var ui = {
screen: $( "<div class='ui-screen-hidden ui-popup-screen fade'></div>" ),
Expand Down Expand Up @@ -175,7 +182,11 @@ define( [ "jquery",
self._setOption( key, value, true );
});

ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
if ( $.mobile.browser.ie ) {
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
} else {
this._on( $( document ), { "vclick": "_closeOnScreenVClick" } );
}

$.each( this._globalHandlers, function( idx, value ) {
value.src.bind( value.handler );
Expand Down

0 comments on commit 5572b5e

Please sign in to comment.