mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Changed the way handle
and exclude
is detected
This commit is contained in:
parent
78500111da
commit
04a50ff49f
@ -219,6 +219,32 @@ test( "{ cancel: ? }, unexpected", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("{ cancel: Selectors }, matching parent selector", function() {
|
||||||
|
|
||||||
|
expect( 5 );
|
||||||
|
|
||||||
|
var el = $("#draggable2").draggable({ cancel: "span a" });
|
||||||
|
|
||||||
|
$("#qunit-fixture").append( "<span id='wrapping'><a></a></span>" );
|
||||||
|
|
||||||
|
el.find( "span" ).append( "<a>" );
|
||||||
|
|
||||||
|
$("#wrapping a").append( el );
|
||||||
|
|
||||||
|
TestHelpers.draggable.testDrag(el, "#draggable2 span", 50, 50, 50, 50, "drag span child");
|
||||||
|
TestHelpers.draggable.shouldNotMove( $("#draggable2 span a") );
|
||||||
|
TestHelpers.draggable.shouldNotMove( $("#wrapping a") );
|
||||||
|
|
||||||
|
$("#draggable2").draggable( "option", "cancel", "span > a" );
|
||||||
|
$("#draggable2").find( "a" ).append( "<a>" );
|
||||||
|
|
||||||
|
|
||||||
|
TestHelpers.draggable.testDrag(el, $("#draggable2 span a").last(), 50, 50, 50, 50, "drag span child");
|
||||||
|
TestHelpers.draggable.shouldNotMove( $("#draggable2 span a").first() );
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
test("cancel, default, switching after initialization", function() {
|
test("cancel, default, switching after initialization", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
|
|
||||||
@ -556,6 +582,30 @@ test("{ handle: 'span' }", function() {
|
|||||||
TestHelpers.draggable.shouldNotMove(el, "drag element");
|
TestHelpers.draggable.shouldNotMove(el, "drag element");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("{ handle: Selectors }, matching parent selector", function() {
|
||||||
|
|
||||||
|
expect( 4 );
|
||||||
|
|
||||||
|
var el = $("#draggable2").draggable({ handle: "span a" });
|
||||||
|
|
||||||
|
$("#qunit-fixture").append( "<span id='wrapping'><a></a></span>" );
|
||||||
|
|
||||||
|
el.find( "span" ).append( "<a>" );
|
||||||
|
|
||||||
|
$("#wrapping a").append( el );
|
||||||
|
|
||||||
|
TestHelpers.draggable.testDrag(el, "#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(el, $("#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() {
|
test("handle, default, switching after initialization", function() {
|
||||||
expect( 6 );
|
expect( 6 );
|
||||||
|
|
||||||
|
6
ui/jquery.ui.draggable.js
vendored
6
ui/jquery.ui.draggable.js
vendored
@ -74,8 +74,10 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
/** interaction interface **/
|
/** interaction interface **/
|
||||||
|
|
||||||
_isValidTarget: function( element ) {
|
_isValidTarget: function( element ) {
|
||||||
var handle = this.options.handle ? element.closest( this.options.handle ).length : true,
|
|
||||||
exclude = this.options.exclude ? element.closest( this.options.exclude ).length : false;
|
var handle = this.options.handle ? element.is( this.element.find( this.options.handle ) ) : true,
|
||||||
|
exclude = this.options.exclude ? element.is( this.element.find( this.options.exclude ) ) : false;
|
||||||
|
|
||||||
|
|
||||||
// Enforce boolean
|
// Enforce boolean
|
||||||
return !!( handle && !exclude );
|
return !!( handle && !exclude );
|
||||||
|
Loading…
Reference in New Issue
Block a user