mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-12-07 06:14:24 +00:00
e1230997aa
Squashed commit of the following: commit7f19f92c64
Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 10:34:28 2012 -0400 put back in fake args for signatures that we want to keep commit257505a9e6
Author: Mike Sherov <mike.sherov@gmail.com> Date: Tue Oct 23 08:10:20 2012 -0400 changes per @scott_gonzalez commit12725480cb
Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:54:05 2012 -0400 clean up unused vars in ui directory commit563595e7ae
Author: Mike Sherov <mike.sherov@gmail.com> Date: Mon Oct 22 22:37:42 2012 -0400 clean up unused vars in grunt and tests
108 lines
2.6 KiB
JavaScript
108 lines
2.6 KiB
JavaScript
/*
|
|
* slider_events.js
|
|
*/
|
|
(function($) {
|
|
|
|
module( "slider: events" );
|
|
|
|
//Specs from http://wiki.jqueryui.com/Slider#specs
|
|
//"change callback: triggers when the slider has stopped moving and has a new
|
|
// value (even if same as previous value), via mouse(mouseup) or keyboard(keyup)
|
|
// or value method/option"
|
|
test( "mouse based interaction", function() {
|
|
expect(4);
|
|
|
|
var el = $( "#slider1" )
|
|
.slider({
|
|
start: function( event ) {
|
|
equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
|
|
},
|
|
slide: function( event) {
|
|
equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
|
|
},
|
|
stop: function( event ) {
|
|
equal( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
|
|
},
|
|
change: function( event ) {
|
|
equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
|
|
}
|
|
});
|
|
|
|
el.find( ".ui-slider-handle" ).eq( 0 )
|
|
.simulate( "drag", { dx: 10, dy: 10 } );
|
|
|
|
});
|
|
test( "keyboard based interaction", function() {
|
|
expect(3);
|
|
|
|
// Test keyup at end of handle slide (keyboard)
|
|
var el = $( "#slider1" )
|
|
.slider({
|
|
start: function( event ) {
|
|
equal( event.originalEvent.type, "keydown", "start triggered by keydown" );
|
|
},
|
|
slide: function() {
|
|
ok( false, "Slider never triggered by keys" );
|
|
},
|
|
stop: function( event ) {
|
|
equal( event.originalEvent.type, "keyup", "stop triggered by keyup" );
|
|
},
|
|
change: function( event ) {
|
|
equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
|
|
}
|
|
});
|
|
|
|
el.find( ".ui-slider-handle" ).eq( 0 )
|
|
.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } )
|
|
.simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
|
|
.simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
|
|
|
|
});
|
|
test( "programmatic event triggers", function() {
|
|
expect(6);
|
|
|
|
// Test value method
|
|
var el = $( "<div></div>" )
|
|
.slider({
|
|
change: function() {
|
|
ok( true, "change triggered by value method" );
|
|
}
|
|
})
|
|
.slider( "value", 0 );
|
|
|
|
QUnit.reset();
|
|
// Test values method
|
|
el = $( "<div></div>" )
|
|
.slider({
|
|
values: [ 10, 20 ],
|
|
change: function() {
|
|
ok( true, "change triggered by values method" );
|
|
}
|
|
})
|
|
.slider( "values", [80, 90] );
|
|
|
|
QUnit.reset();
|
|
// Test value option
|
|
el = $( "<div></div>" )
|
|
.slider({
|
|
change: function() {
|
|
ok( true, "change triggered by value option" );
|
|
}
|
|
})
|
|
.slider( "option", "value", 0 );
|
|
|
|
QUnit.reset();
|
|
// Test values option
|
|
el = $( "<div></div>" )
|
|
.slider({
|
|
values: [ 10, 20 ],
|
|
change: function() {
|
|
ok( true, "change triggered by values option" );
|
|
}
|
|
})
|
|
.slider( "option", "values", [80, 90] );
|
|
|
|
});
|
|
|
|
}( jQuery ) );
|