From 6414e35ceeef9b53566a262a81517c266bd7e10d Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Wed, 9 Mar 2011 12:37:20 -0800 Subject: [PATCH] Convert checkbox/radio and navbar over to virtual mouse events. --- js/jquery.mobile.forms.checkboxradio.js | 34 ++++++++----------------- js/jquery.mobile.navbar.js | 4 +-- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 18d14d98..0e337bd9 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -37,55 +37,41 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { .wrapAll( "
" ); label.bind({ - mouseover: function() { + vmouseover: function() { if( $(this).parent().is('.ui-disabled') ){ return false; } }, - "touchmove": function( event ){ - var oe = event.originalEvent.touches[0]; - if( label.data("movestart") ){ - if( Math.abs( label.data("movestart")[0] - oe.pageX ) > 10 || - Math.abs( label.data("movestart")[1] - oe.pageY ) > 10 ){ - label.data("moved", true); - } - } - else{ - label.data("movestart", [ parseFloat( oe.pageX ), parseFloat( oe.pageY ) ]); - } + vmousecancel: function( event ){ + label.data("moved", true); }, - "touchend mouseup": function( event ){ + vmouseup: function( event ){ if ( input.is( ":disabled" ) ){ event.preventDefault(); return; } - - label.removeData("movestart"); - if( label.data("etype") && label.data("etype") !== event.type || label.data("moved") ){ - label.removeData("etype").removeData("moved"); - if( label.data("moved") ){ - label.removeData("moved"); - } + + if( label.data("moved") ){ + label.removeData("moved"); return false; } - label.data( "etype", event.type ); self._cacheVals(); input.attr( "checked", inputtype === "radio" && true || !input.is( ":checked" ) ); self._updateAll(); event.preventDefault(); }, - click: false + vclick: false }); input .bind({ - mousedown: function(){ + vmousedown: function(){ this._cacheVals(); }, - click: function(){ + vclick: function(){ self._updateAll(); }, diff --git a/js/jquery.mobile.navbar.js b/js/jquery.mobile.navbar.js index 13f0da8d..0b266593 100755 --- a/js/jquery.mobile.navbar.js +++ b/js/jquery.mobile.navbar.js @@ -32,10 +32,10 @@ $.widget( "mobile.navbar", $.mobile.widget, { iconpos: iconpos }); - $navbar.delegate("a", "click",function(event){ + $navbar.delegate("a", "vclick",function(event){ $navbtns.removeClass( "ui-btn-active" ); $( this ).addClass( "ui-btn-active" ); }); } }); -})( jQuery ); \ No newline at end of file +})( jQuery );