mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-23 13:45:49 +00:00
added step tests for keypress, removed data-step attribute check in favor of html5 range step attribute
This commit is contained in:
parent
3a24aa4de6
commit
a79799e3b3
3 changed files with 22 additions and 2 deletions
|
|
@ -34,7 +34,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
},
|
||||
min = (cType == 'input') ? parseFloat(control.attr('min')) : 0,
|
||||
max = (cType == 'input') ? parseFloat(control.attr('max')) : control.find('option').length-1,
|
||||
step = window.parseFloat(control.attr('data-step') || 1),
|
||||
step = window.parseFloat(control.attr('step') || 1),
|
||||
slider = $('<div class="ui-slider '+ selectClass +' ui-btn-down-'+ trackTheme+' ui-btn-corner-all" role="application"></div>'),
|
||||
handle = $('<a href="#" class="ui-slider-handle"></a>')
|
||||
.appendTo(slider)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@
|
|||
<input type="range" name="slider-1" id="range-slider-end" value="15" min="0" max="100" data-theme="b" data-track-theme="a" />
|
||||
</div>
|
||||
|
||||
<div data-role="fieldcontain">
|
||||
<input type="range" name="stepped" id="stepped" value="15" min="0" max="100" step="10" data-theme="b" data-track-theme="a" />
|
||||
</div>
|
||||
|
||||
<div data-role="fieldcontain">
|
||||
<select name="slider" id="slider-switch" data-role="slider">
|
||||
<option value="off">Off</option>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
handle.trigger('keydown');
|
||||
|
||||
val += opts.increment;
|
||||
same(val, window.parseFloat(slider.val(), 10), "new value is one larger");
|
||||
same(val, window.parseFloat(slider.val(), 10), "new value is " + opts.increment + " different");
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -62,6 +62,22 @@
|
|||
});
|
||||
});
|
||||
|
||||
test( "slider should move positive by steps on keypress", function(){
|
||||
keypressTest({
|
||||
selector: "#stepped",
|
||||
keyCodes: ['RIGHT'],
|
||||
increment: 10
|
||||
});
|
||||
});
|
||||
|
||||
test( "slider should move negative by steps on keypress", function(){
|
||||
keypressTest({
|
||||
selector: "#stepped",
|
||||
keyCodes: ['LEFT'],
|
||||
increment: -10
|
||||
});
|
||||
});
|
||||
|
||||
test( "slider should validate input value on blur", function(){
|
||||
var slider = $("#range-slider-up");
|
||||
slider.focus();
|
||||
|
|
|
|||
Loading…
Reference in a new issue