Skip to content
This repository
Browse code

abstracted out some of the page hide behavior to fix issues with the …

…close button not returning focus to the button after closing. Also fixes an issue where a full page custom menu would open as a misplaced small custom menu the second time it opens (if the menu was closed via the custom close button). Fixes #1618. Fixes #1692. Fixes #1750.
  • Loading branch information...
commit ada46734ecd45bb9f964e925ed228fb5f1607376 1 parent 2de817d
authored July 10, 2011

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

  1. 28  js/jquery.mobile.forms.select.js
28  js/jquery.mobile.forms.select.js
@@ -305,6 +305,13 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
305 305
 					break;
306 306
 				}
307 307
 			});
  308
+			
  309
+			// button refocus ensures proper height calculation
  310
+			// by removing the inline style and ensuring page inclusion
  311
+			self.menuPage.bind( "pagehide", function(){
  312
+				self.list.appendTo( self.listbox );
  313
+				self._focusButton();
  314
+			});
308 315
 
309 316
 			// Events on "screen" overlay
310 317
 			screen.bind( "vclick", function( event ) {
@@ -551,6 +558,13 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
551 558
 			self.isOpen = true;
552 559
 		}
553 560
 	},
  561
+	
  562
+	_focusButton : function(){
  563
+		var self = this;
  564
+		setTimeout(function() {
  565
+			self.button.focus();
  566
+		}, 40);
  567
+	},
554 568
 
555 569
 	close: function() {
556 570
 		if ( this.options.disabled || !this.isOpen || this.options.nativeMenu ) {
@@ -559,19 +573,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
559 573
 
560 574
 		var self = this;
561 575
 
562  
-		function focusButton() {
563  
-			setTimeout(function() {
564  
-				self.button.focus();
565  
-			}, 40);
566  
-
567  
-			self.listbox.removeAttr( "style" ).append( self.list );
568  
-		}
569  
-
570 576
 		if ( self.menuType == "page" ) {
571  
-			// button refocus ensures proper height calculation
572  
-			// by removing the inline style and ensuring page inclusion
573  
-			self.menuPage.one( "pagehide", focusButton);
574  
-
575 577
 			// doesn't solve the possible issue with calling change page
576 578
 			// where the objects don't define data urls which prevents dialog key
577 579
 			// stripping - changePage has incoming refactor
@@ -580,7 +582,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
580 582
 		else{
581 583
 			self.screen.addClass( "ui-screen-hidden" );
582 584
 			self.listbox.addClass( "ui-selectmenu-hidden" ).removeAttr( "style" ).removeClass( "in" );
583  
-			focusButton();
  585
+			self._focusButton();
584 586
 		}
585 587
 
586 588
 		// allow the dialog to be closed again

0 notes on commit ada4673

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