Permalink
Browse files

DegradeInput: move to $.mobile.degradeInputs deprecate on page widget

  • Loading branch information...
arschmitz committed Aug 9, 2013
1 parent 791754f commit 20433c629c1db129175933707b0460ebdf2c79f1
Showing with 12 additions and 17 deletions.
  1. +12 −17 js/jquery.mobile.degradeInputs.js
@@ -8,7 +8,7 @@ define( [ "jquery", "./widgets/page" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.mobile.page.prototype.options.degradeInputs = {
$.mobile.degradeInputs = {
color: false,
date: false,
datetime: false,
@@ -23,34 +23,29 @@ $.mobile.page.prototype.options.degradeInputs = {
url: false,
week: false
};
// Backcompat remove in 1.5
$.mobile.page.prototype.options.degradeInputs = $.mobile.degradeInputs;
//auto self-init widgets
// Auto self-init widgets
$.mobile.degradeInputsWithin = function( target ) {
var $target = $( target ),
page = $.mobile.closestPageData( $target ), options;
target = $( target );
if ( !page ) {
return;
}
options = page.options;
// degrade inputs to avoid poorly implemented native functionality
$target.find( "input" ).not( page.keepNativeSelector() ).each(function() {
var $this = $( this ),
// Degrade inputs to avoid poorly implemented native functionality
target.find( "input" ).not( $.mobile.page.prototype.keepNativeSelector() ).each(function() {
var element = $( this ),
type = this.getAttribute( "type" ),
optType = options.degradeInputs[ type ] || "text",
optType = $.mobile.degradeInputs[ type ] || "text",
html, hasType, findstr, repstr;
if ( options.degradeInputs[ type ] ) {
html = $( "<div>" ).html( $this.clone() ).html();
if ( $.mobile.degradeInputs[ type ] ) {
html = $( "<div>" ).html( element.clone() ).html();
// In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead
hasType = html.indexOf( " type=" ) > -1;
findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/;
repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" );
$this.replaceWith( html.replace( findstr, repstr ) );
element.replaceWith( html.replace( findstr, repstr ) );
}
});

0 comments on commit 20433c6

Please sign in to comment.