1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Changes input type to another after custom enhancements are made (ex. range > numberic).
3 //>>label: Degrade Inputs
7 define( [ "jquery", "./jquery.mobile.page" ], function( $ ) {
8 //>>excludeEnd("jqmBuildExclude");
9 (function( $, undefined ) {
11 $.mobile.page.prototype.options.degradeInputs = {
15 "datetime-local": false,
28 //auto self-init widgets
29 $( document ).bind( "pagecreate create", function( e ){
31 var page = $.mobile.closestPageData($(e.target)), options;
37 options = page.options;
39 // degrade inputs to avoid poorly implemented native functionality
40 $( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() {
41 var $this = $( this ),
42 type = this.getAttribute( "type" ),
43 optType = options.degradeInputs[ type ] || "text";
45 if ( options.degradeInputs[ type ] ) {
46 var html = $( "<div>" ).html( $this.clone() ).html(),
47 // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
48 hasType = html.indexOf( " type=" ) > -1,
49 findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/,
50 repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
52 $this.replaceWith( html.replace( findstr, repstr ) );
59 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
61 //>>excludeEnd("jqmBuildExclude");