Permalink
Browse files

[custom select menu] Make sure the UL ends up inside the popup when t…

…he menu is closed so that the next time its size needs to be measured to decide whether to show a dialog or a popup its size /can/ be measured. Also, centralize the close behaviour in the close method.
  • Loading branch information...
gabrielschulhof committed Nov 20, 2012
1 parent b0a802d commit ef88caf1a686fd7d2f9348dc12420986a3264f9c
Showing with 7 additions and 11 deletions.
  1. +7 −11 js/widgets/forms/select.custom.js
@@ -121,6 +121,10 @@ define( [
// Button events
self.button.bind( "vclick keydown" , function( event ) {
if ( self.options.disabled || self.isOpen ) {
return;
}
if (event.type === "vclick" ||
event.keyCode && (event.keyCode === $.mobile.keyCode.ENTER ||
event.keyCode === $.mobile.keyCode.SPACE)) {
@@ -238,9 +242,6 @@ define( [
// button refocus ensures proper height calculation
// by removing the inline style and ensuring page inclusion
self.menuPage.bind( "pagehide", function() {
self.list.appendTo( self.listbox );
self._focusButton();
// TODO centralize page removal binding / handling in the page plugin.
// Suggestion from @jblas to do refcounting
//
@@ -339,12 +340,12 @@ define( [
if ( self.menuType === "page" ) {
self.menuPage.dialog( "close" );
self.list.appendTo( self.listbox );
} else {
self.listbox.popup( "close" );
self.list.appendTo( self.listbox );
self._focusButton();
}
self._focusButton();
// allow the dialog to be closed again
self.isOpen = false;
},
@@ -354,10 +355,6 @@ define( [
},
_decideFormat: function() {
if ( this.options.disabled ) {
return;
}
var self = this,
$window = $( window ),
selfListParent = self.list.parent(),
@@ -398,10 +395,9 @@ define( [
self.menuPage
.one( "pageshow", function() {
focusMenuItem();
self.isOpen = true;
})
.one( "pagehide", function() {
self.isOpen = false;
self.close();
});
self.menuType = "page";

0 comments on commit ef88caf

Please sign in to comment.