Skip to content

Commit 5572b5e

Browse files
author
Gabriel Schulhof
committed
[popup] To implement click-on-screen-to-dismiss-popup one must bind the "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.
1 parent 5463fc8 commit 5572b5e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

js/widgets/popup.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ define( [ "jquery",
5353
e.preventDefault();
5454
e.stopImmediatePropagation();
5555
this.close();
56+
return false;
5657
},
5758

5859
_handleWindowKeyUp: function( e ) {
5960
if ( this._isOpen && e.keyCode === $.mobile.keyCode.ESCAPE ) {
60-
this._eatEventAndClose( e );
61+
return this._eatEventAndClose( e );
6162
}
6263
},
6364

@@ -116,6 +117,12 @@ define( [ "jquery",
116117
}
117118
},
118119

120+
_closeOnScreenVClick: function( e ) {
121+
if ( e.target === this._ui.screen[ 0 ] ) {
122+
return this._eatEventAndClose( e );
123+
}
124+
},
125+
119126
_create: function() {
120127
var ui = {
121128
screen: $( "<div class='ui-screen-hidden ui-popup-screen fade'></div>" ),
@@ -175,7 +182,11 @@ define( [ "jquery",
175182
self._setOption( key, value, true );
176183
});
177184

178-
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
185+
if ( $.mobile.browser.ie ) {
186+
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
187+
} else {
188+
this._on( $( document ), { "vclick": "_closeOnScreenVClick" } );
189+
}
179190

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

0 commit comments

Comments
 (0)