Skip to content
Browse files

Slider: drag should start only for left mouse button

(cherry picked from commit 93f0caa)
  • Loading branch information...
1 parent 92b813f commit 9dc7fc55e9bb6389c7b95c4dae4c648cbf53d51b @stforek stforek committed with gabrielschulhof
Showing with 26 additions and 1 deletion.
  1. +1 −1 js/widgets/forms/slider.js
  2. +5 −0 tests/unit/slider/index.html
  3. +20 −0 tests/unit/slider/slider_events.js
View
2 js/widgets/forms/slider.js
@@ -261,7 +261,7 @@ $.widget( "mobile.slider", $.mobile.widget, $.extend( {
_sliderVMouseDown: function( event ) {
// NOTE: we don't do this in refresh because we still want to
// support programmatic alteration of disabled inputs
- if ( this.options.disabled ) {
+ if ( this.options.disabled || event.which != 1 ) {
return false;
}
if ( this._trigger( "beforestart", event ) === false ) {
View
5 tests/unit/slider/index.html
@@ -99,6 +99,11 @@ <h2 id="qunit-userAgent"></h2>
<div data-role="fieldcontain">
<label for="start-stop-events">Input slider:</label>
+ <input type="range" name="slider" id="mousedown-which-events" value="25" min="0" max="100"/>
+ </div>
+
+ <div data-role="fieldcontain">
+ <label for="start-stop-events">Input slider:</label>
<input type="range" name="slider" id="start-stop-events" value="25" min="0" max="100"/>
</div>
View
20 tests/unit/slider/slider_events.js
@@ -374,6 +374,26 @@
], 500);
});
+ test( "drag should start only when clicked with left button", function(){
+ expect(1);
+ var control = $( "#mousedown-which-events" ),
+ widget = control.data( "mobile-slider" ),
+ slider = widget.slider,
+ handle = widget.handle,
+ startFunc = function() {
+ ok( true, "drag started" );
+ },
+ event = $.Event( "mousedown", { target: handle[ 0 ] } );
+ control.bind( 'slidestart', startFunc);
+ event.which = 1; //left button
+ slider.trigger(event);
+ event.which = 2; //middle button
+ slider.trigger(event);
+ event.which = 3; //right button
+ slider.trigger(event);
+ control.unbind( 'start', startFunc);
+ });
+
asyncTest( "moving the slider triggers 'slidestart' and 'slidestop' events", function() {
var control = $( "#start-stop-events" ),
widget = control.data( "mobile-slider" ),

0 comments on commit 9dc7fc5

Please sign in to comment.
Something went wrong with that request. Please try again.