2 * "degradeInputs" plugin - degrades inputs to another type after custom enhancements are made.
5 (function( $, undefined ) {
7 $.mobile.page.prototype.options.degradeInputs = {
11 "datetime-local": false,
24 //auto self-init widgets
25 $( document ).bind( "pagecreate create", function( e ){
27 var page = $(e.target).closest(':jqmData(role="page")').data("page"), options;
33 options = page.options;
35 // degrade inputs to avoid poorly implemented native functionality
36 $( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() {
37 var $this = $( this ),
38 type = this.getAttribute( "type" ),
39 optType = options.degradeInputs[ type ] || "text";
41 if ( options.degradeInputs[ type ] ) {
42 var html = $( "<div>" ).html( $this.clone() ).html(),
43 // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
44 hasType = html.indexOf( " type=" ) > -1,
45 findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/,
46 repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
48 $this.replaceWith( html.replace( findstr, repstr ) );