Skip to content

Commit

Permalink
Input types can now degrade to alternate types, instead of text. Firs…
Browse files Browse the repository at this point in the history
…t such example is type=range degrades to type=number. Fixes issue jquery-archive#415, Fixes jquery-archive#404
  • Loading branch information
scottjehl committed Nov 12, 2010
1 parent 4db0734 commit e89ebc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions js/jquery.mobile.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $.widget( "mobile.page", $.mobile.widget, {
email: false,
month: false,
number: false,
range: true,
range: "number",
search: true,
tel: false,
time: false,
Expand Down Expand Up @@ -141,11 +141,13 @@ $.widget( "mobile.page", $.mobile.widget, {
var o = this.options;
// degrade inputs to avoid poorly implemented native functionality
this.element.find( "input" ).each(function() {
var type = this.getAttribute( "type" );
var type = this.getAttribute( "type" ),
optType = o.degradeInputs[ type ] || "text";

if ( o.degradeInputs[ type ] ) {
$( this ).replaceWith(
$( "<div>" ).html( $(this).clone() ).html()
.replace( /type="([a-zA-Z]+)"/, "data-type='$1'" ) );
.replace( /type="([a-zA-Z]+)"/, "type="+ optType +" data-type='$1'" ) );
}
});

Expand Down
2 changes: 1 addition & 1 deletion themes/default/jquery.mobile.forms.slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Dual licensed under the MIT (MIT-LICENSE.txt) or GPL (GPL-LICENSE.txt) licenses.
*/
label.ui-slider { display: block; }
input.ui-slider-input, .min-width-480px input.ui-slider-input { display: inline-block; width: 40px; }
input.ui-slider-input, .min-width-480px input.ui-slider-input { display: inline-block; width: 50px; }
select.ui-slider-switch { display: none; }
div.ui-slider { position: relative; display: inline-block; overflow: visible; height: 15px; padding: 0; margin: 0 2% 0 20px; top: 4px; width: 66%; }
a.ui-slider-handle { position: absolute; z-index: 10; top: 50%; width: 28px; height: 28px; margin-top: -15px; margin-left: -15px; }
Expand Down

0 comments on commit e89ebc1

Please sign in to comment.