diff options
author | Ablay Keldibek <atomio.ak@gmail.com> | 2015-03-12 14:30:06 +0600 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2015-03-12 07:29:50 -0400 |
commit | 6111b17710ab4e14bb119e735de9cfa9285badab (patch) | |
tree | 3a4cfca75adc937405c356d1d21b59775a1d52ae /tests/unit/slider | |
parent | 21831f5036bd695cc2734ec3f44e97549d2f7660 (diff) | |
download | jquery-ui-6111b17710ab4e14bb119e735de9cfa9285badab.tar.gz jquery-ui-6111b17710ab4e14bb119e735de9cfa9285badab.zip |
Slider: Pass handle index to events
Added a `handleIndex` property to the event data which indicates the index of
the handle being changed.
Fixes #7630
Closes gh-1486
Diffstat (limited to 'tests/unit/slider')
-rw-r--r-- | tests/unit/slider/slider_events.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js index ec93a0565..d020d8ac6 100644 --- a/tests/unit/slider/slider_events.js +++ b/tests/unit/slider/slider_events.js @@ -149,4 +149,41 @@ test( "mouse based interaction part two: when handles overlap", function() { }); +test( "event data", function() { + expect( 4 ); + + var slideHandleIndex = 3, + values = [ 8, 9, 7, 4 ], + newValues = [ 8, 9, 7, 5 ], + element = $( "#slider1" ) + .slider({ + values: values, + start: function( event, ui ) { + deepEqual( ui, expectedUiHash, "passing ui to start event" ); + }, + slide: function( event, ui ) { + deepEqual( ui, expectedChangedUiHash, "passing ui to slide event" ); + }, + stop: function( event, ui ) { + deepEqual( ui, expectedChangedUiHash, "passing ui to stop event" ); + }, + change: function( event, ui ) { + deepEqual( ui, expectedChangedUiHash, "passing ui to change event" ); + } + }), + handles = element.find( ".ui-slider-handle" ), + expectedUiHash = { + handle: handles.eq( slideHandleIndex )[ 0 ], + handleIndex: slideHandleIndex, + values: values, + value: values[ slideHandleIndex ] + }, + expectedChangedUiHash = $.extend( {}, expectedUiHash, { + values: newValues, + value: newValues[ slideHandleIndex ] + }); + + handles.eq( slideHandleIndex ).simulate( "drag", { dx: 10 } ); +}); + })( jQuery ); |