Skip to content
This repository
Browse code

[popup] To implement click-on-screen-to-dismiss-popup one must bind t…

…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...
commit 5572b5e10e992a95302d618694fe8bf8b4a67300 1 parent 5463fc8
Gabriel "_|Nix|_" Schulhof authored August 15, 2012

Showing 1 changed file with 13 additions and 2 deletions. Show diff stats Hide diff stats

  1. 15  js/widgets/popup.js
15  js/widgets/popup.js
@@ -53,11 +53,12 @@ define( [ "jquery",
53 53
 			e.preventDefault();
54 54
 			e.stopImmediatePropagation();
55 55
 			this.close();
  56
+			return false;
56 57
 		},
57 58
 
58 59
 		_handleWindowKeyUp: function( e ) {
59 60
 			if ( this._isOpen && e.keyCode === $.mobile.keyCode.ESCAPE ) {
60  
-				this._eatEventAndClose( e );
  61
+				return this._eatEventAndClose( e );
61 62
 			}
62 63
 		},
63 64
 
@@ -116,6 +117,12 @@ define( [ "jquery",
116 117
 			}
117 118
 		},
118 119
 
  120
+		_closeOnScreenVClick: function( e ) {
  121
+			if ( e.target === this._ui.screen[ 0 ] ) {
  122
+				return this._eatEventAndClose( e );
  123
+			}
  124
+		},
  125
+
119 126
 		_create: function() {
120 127
 			var ui = {
121 128
 					screen: $( "<div class='ui-screen-hidden ui-popup-screen fade'></div>" ),
@@ -175,7 +182,11 @@ define( [ "jquery",
175 182
 				self._setOption( key, value, true );
176 183
 			});
177 184
 
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
+			}
179 190
 
180 191
 			$.each( this._globalHandlers, function( idx, value ) {
181 192
 				value.src.bind( value.handler );

0 notes on commit 5572b5e

Please sign in to comment.
Something went wrong with that request. Please try again.