diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index dcf4831b..18d14d98 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -3,7 +3,7 @@ * Copyright (c) jQuery Project * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license -*/ +*/ (function($, undefined ) { $.widget( "mobile.checkboxradio", $.mobile.widget, { options: { @@ -30,17 +30,17 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { icon: this.element.parents( "[data-type='horizontal']" ).length ? undefined : uncheckedicon, shadow: false }); - - // wrap the input + label in a div + + // wrap the input + label in a div input .add( label ) .wrapAll( "
" ); - + label.bind({ mouseover: function() { if( $(this).parent().is('.ui-disabled') ){ return false; } }, - + "touchmove": function( event ){ var oe = event.originalEvent.touches[0]; if( label.data("movestart") ){ @@ -53,13 +53,13 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { label.data("movestart", [ parseFloat( oe.pageX ), parseFloat( oe.pageY ) ]); } }, - + "touchend mouseup": function( event ){ - if ( input.is( ":disabled" ) ) - { + 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"); @@ -74,46 +74,46 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { self._updateAll(); event.preventDefault(); }, - + click: false - + }); - + input .bind({ mousedown: function(){ this._cacheVals(); }, - + click: function(){ self._updateAll(); }, - focus: function() { - label.addClass( "ui-focus" ); + focus: function() { + label.addClass( "ui-focus" ); }, blur: function() { label.removeClass( "ui-focus" ); } }); - + this.refresh(); - + }, - + _cacheVals: function(){ this._getInputSet().each(function(){ $(this).data("cacheVal", $(this).is(":checked") ); - }); + }); }, - + //returns either a set of radios with the same name attribute, or a single checkbox _getInputSet: function(){ return this.element.closest( "form,fieldset,[data-role='page']" ) .find( "input[name='"+ this.element.attr( "name" ) +"'][type='"+ this.element.attr( "type" ) +"']" ); }, - + _updateAll: function(){ this._getInputSet().each(function(){ var dVal = $(this).data("cacheVal"); @@ -123,7 +123,7 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { }) .checkboxradio( "refresh" ); }, - + refresh: function( ){ var input = this.element, label = input.closest("form,fieldset,[data-role='page']").find("label[for='" + input.attr( "id" ) + "']"), @@ -131,18 +131,18 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { icon = label.find( ".ui-icon" ), checkedicon = "ui-icon-" + inputtype + "-on", uncheckedicon = "ui-icon-" + inputtype + "-off"; - + if ( input[0].checked ) { label.addClass( "ui-btn-active" ); icon.addClass( checkedicon ); icon.removeClass( uncheckedicon ); } else { - label.removeClass( "ui-btn-active" ); + label.removeClass( "ui-btn-active" ); icon.removeClass( checkedicon ); icon.addClass( uncheckedicon ); } - + if( input.is( ":disabled" ) ){ this.disable(); } @@ -150,11 +150,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { this.enable(); } }, - + disable: function(){ this.element.attr("disabled",true).parent().addClass("ui-disabled"); }, - + enable: function(){ this.element.attr("disabled",false).parent().removeClass("ui-disabled"); }