From c08b621fdb95be635f6b657948878439ef9d5964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 2 Sep 2016 10:21:25 -0400 Subject: [PATCH 1/2] Slider: Add demo for custom handle Fixes #15023 --- demos/slider/custom-handle.html | 42 +++++++++++++++++++++++++++++++++ demos/slider/index.html | 1 + 2 files changed, 43 insertions(+) create mode 100644 demos/slider/custom-handle.html diff --git a/demos/slider/custom-handle.html b/demos/slider/custom-handle.html new file mode 100644 index 00000000000..11192f3189e --- /dev/null +++ b/demos/slider/custom-handle.html @@ -0,0 +1,42 @@ + + + + + + jQuery UI Slider - Custom handle + + + + + + + + +
+
+
+ +
+

The basic slider is horizontal and has a single handle that can be moved with the mouse or by using the arrow keys.

+
+ + diff --git a/demos/slider/index.html b/demos/slider/index.html index 1bc1198c41d..f853a79aa18 100644 --- a/demos/slider/index.html +++ b/demos/slider/index.html @@ -18,6 +18,7 @@
  • Vertical range slider
  • Multiple sliders
  • Simple colorpicker
  • +
  • Custom handle
  • From 21bf01acda2185922e9d5c05c51574e50409878a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 6 Sep 2016 14:24:36 -0400 Subject: [PATCH 2/2] Slider: Apply `tabIndex` to custom handles --- tests/unit/slider/core.js | 12 ++++++++++++ tests/unit/slider/slider.html | 4 ++-- ui/widgets/slider.js | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/unit/slider/core.js b/tests/unit/slider/core.js index 57affb0d1c7..8031367f0ba 100644 --- a/tests/unit/slider/core.js +++ b/tests/unit/slider/core.js @@ -25,6 +25,18 @@ QUnit.test( "markup structure", function( assert ) { assert.hasClasses( handle[ 1 ], "ui-slider-handle" ); } ); +QUnit.test( "custom handle", function( assert ) { + assert.expect( 3 ); + + var element = $( "#slider-custom-handle" ).slider(); + var customHandle = $( ".custom-handle" ); + var sliderHandles = element.find( ".ui-slider-handle" ); + + assert.equal( sliderHandles.length, 1, "Only one handle" ); + assert.strictEqual( sliderHandles[ 0 ], customHandle[ 0 ], "Correct handle" ); + assert.equal( customHandle.attr( "tabIndex" ), 0, "tabIndex" ); +} ); + QUnit.test( "keydown HOME on handle sets value to min", function( assert ) { assert.expect( 2 ); element = $( "
    " ); diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index 39bcd05c3fe..2afbeafdefd 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -25,8 +25,8 @@
    -
    -
    +
    +
    diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 4c1bdc05e30..8b0f907f577 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -117,7 +117,9 @@ return $.widget( "ui.slider", $.ui.mouse, { this.handle = this.handles.eq( 0 ); this.handles.each( function( i ) { - $( this ).data( "ui-slider-handle-index", i ); + $( this ) + .data( "ui-slider-handle-index", i ) + .attr( "tabIndex", 0 ); } ); },