]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Account for descendants in handle.
authorScott González <scott.gonzalez@gmail.com>
Fri, 8 Mar 2013 15:08:46 +0000 (10:08 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 8 Mar 2013 15:08:58 +0000 (10:08 -0500)
tests/unit/draggable/draggable.html
tests/unit/draggable/draggable_options.js
ui/jquery.ui.draggable.js

index 6380f3e85bd0c6a630a135ec04dcf8559d9e716b..3d1d3326e02d7bc0de0ca8ff3619dcbd91318304 100644 (file)
@@ -48,7 +48,7 @@
 <div id="qunit-fixture">
        <div id="main"></div>
        <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
-       <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
+       <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
        <div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
        <div style="width: 1px; height: 1000px;"></div>
        <div style="position: absolute; width: 1px; height: 2000px;"></div>
index 2e9f85c242790a2488e9911f0ec6537522990900..a71bf57cbd93844b89f8d7655aed763a8b597877 100644 (file)
@@ -603,39 +603,15 @@ test( "grid, switching after initialization", function() {
 });
 
 test( "{ handle: 'span' }", function() {
-       expect( 2 );
+       expect( 3 );
 
        var element = $( "#draggable2" ).draggable({ handle: "span" });
 
        TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" );
+       TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" );
        TestHelpers.draggable.shouldNotMove( element, "drag element" );
 });
 
-/*
-test( "{ handle: Selectors }, matching parent selector", function() {
-
-       expect( 4 );
-
-       var element = $( "#draggable2" ).draggable({ handle: "span a" });
-
-       $( "#qunit-fixture" ).append( "<span id='wrapping'><a></a></span>" );
-
-       element.find( "span" ).append( "<a>" );
-
-       $( "#wrapping a" ).append( element );
-
-       TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" );
-       TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) );
-
-       $( "#draggable2" ).draggable( "option", "handle", "span > a" );
-       $( "#draggable2" ).find( "a" ).append( "<a>" );
-
-       TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" );
-       TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() );
-
-});
-*/
-
 test( "handle, default, switching after initialization", function() {
        expect( 6 );
 
index 56b8fc77d84ff271e9a2a41051809fd5ec7fe597..5762d31717b0a493521dee4e237cec3cd1de3b77 100644 (file)
@@ -281,17 +281,9 @@ $.widget("ui.draggable", $.ui.mouse, {
        },
 
        _getHandle: function(event) {
-
-               var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
-
-               this.element.find( this.options.handle ).each(function() {
-                       if(this === event.target) {
-                               handle = true;
-                       }
-               });
-
-               return handle;
-
+               return this.options.handle ?
+                       !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
+                       true;
        },
 
        _createHelper: function(event) {