From b7549b213cff4171cddf7f1b482eeec068a3f771 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 19 Jan 2012 19:49:16 +0700 Subject: [PATCH] moved the iosfocusfix logic over to the selectmenu plugin. It's now toggled via a new option: preventFocusZoom (Default is true). --- js/jquery.mobile.forms.select.js | 13 ++++++++++++- js/jquery.mobile.js | 1 - js/jquery.mobile.zoom.iosfocusfix.js | 20 -------------------- 3 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 js/jquery.mobile.zoom.iosfocusfix.js diff --git a/js/jquery.mobile.forms.select.js b/js/jquery.mobile.forms.select.js index feed45b2..80e968f8 100644 --- a/js/jquery.mobile.forms.select.js +++ b/js/jquery.mobile.forms.select.js @@ -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() { diff --git a/js/jquery.mobile.js b/js/jquery.mobile.js index a036c674..8a32934e 100644 --- a/js/jquery.mobile.js +++ b/js/jquery.mobile.js @@ -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' ] ); diff --git a/js/jquery.mobile.zoom.iosfocusfix.js b/js/jquery.mobile.zoom.iosfocusfix.js deleted file mode 100644 index 395b4a6e..00000000 --- a/js/jquery.mobile.zoom.iosfocusfix.js +++ /dev/null @@ -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");