moved the iosfocusfix logic over to the selectmenu plugin. It's now toggled via a new option: preventFocusZoom (Default is true).

This commit is contained in:
scottjehl 2012-01-19 19:49:16 +07:00
parent 6077668af4
commit b7549b213c
3 changed files with 12 additions and 22 deletions

View file

@ -2,7 +2,7 @@
//>>description: Consistent styling for native select menus.
//>>label: Enhanced Native Selects
define( [ "jquery", "jquery.mobile.core", "jquery.mobile.widget", "jquery.mobile.buttonMarkup" ], function( $ ) {
define( [ "jquery", "jquery.mobile.core", "jquery.mobile.widget", "jquery.mobile.buttonMarkup", "jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
@ -21,6 +21,7 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
hidePlaceholderMenuItems: true,
closeText: "Close",
nativeMenu: true,
preventFocusZoom: true,
initSelector: "select:not(:jqmData(role='slider'))"
},
@ -148,6 +149,16 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
.bind( "change blur", function() {
self.button.removeClass( "ui-btn-down-" + self.options.theme );
});
// In many situations, iOS will zoom into the select upon tap, this prevents that from happening
if( self.options.preventFocusZoom ){
self.button.bind( "vmousedown", function() {
$.mobile.zoom.disable();
})
.bind( "mouseup", function() {
$.mobile.zoom.enable();
});
}
},
selected: function() {

View file

@ -41,7 +41,6 @@ define([
'jquery.mobile.links',
'jquery.mobile.fixedToolbar',
'jquery.mobile.zoom',
'jquery.mobile.zoom.iosfocusfix',
'jquery.mobile.zoom.iosorientationfix'
], function() {
require( [ 'jquery.mobile.init' ] );

View file

@ -1,20 +0,0 @@
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Prevents iOS from zooming into form fields on focus
//>>label: Prevent form focus zoom
define( [ "jquery", "jquery.mobile.core", "jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
( function( $, window ) {
$( document )
.bind( "focusin.iosfocusfix vmousedown.iosfocusfix", function( e ){
if( $( e.target ).is( "select, input" ) ){
$.mobile.zoom.disable();
setTimeout( $.mobile.zoom.enable, 500 );
}
} );
}( jQuery, this ));
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");