mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable + Sortable: Fixed blockFrames. Added unit tests specifically for draggable since it should be moving up to "core" file shortly
This commit is contained in:
parent
d438973983
commit
894d4c157a
@ -47,6 +47,87 @@ test("No options, absolute", function() {
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
});
|
||||
|
||||
test("_blockFrames, absolute parent", function() {
|
||||
expect( 3 );
|
||||
var el = $("#draggable1").draggable(),
|
||||
parent = $("<div style='width: 600px; height: 600px; position: absolute; top: 300px; left; 400px;'>"),
|
||||
iframe = $("<iframe src='about:blank' width='500' height='500' style='position: absolute; top: 25px; left: 30px;'>"),
|
||||
left, top;
|
||||
|
||||
parent.append( iframe );
|
||||
|
||||
$("#qunit-fixture").prepend( parent );
|
||||
|
||||
el.on( "drag", function() {
|
||||
|
||||
var block = iframe.next();
|
||||
|
||||
left = block.css("left");
|
||||
top = block.css("top");
|
||||
|
||||
});
|
||||
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
|
||||
equal( left, "30px" );
|
||||
equal( top, "25px" );
|
||||
|
||||
});
|
||||
|
||||
test("_blockFrames, relative parent", function() {
|
||||
expect( 3 );
|
||||
var el = $("#draggable1").draggable(),
|
||||
parent = $("<div style='width: 600px; height: 600px; position: relative; top: 300px; left; 400px;'>"),
|
||||
iframe = $("<iframe src='about:blank' width='500' height='500' style='position: absolute; top: 25px; left: 30px;'>"),
|
||||
left, top;
|
||||
|
||||
parent.append( iframe );
|
||||
|
||||
$("#qunit-fixture").prepend( parent );
|
||||
|
||||
el.on( "drag", function() {
|
||||
|
||||
var block = iframe.next();
|
||||
|
||||
left = block.css("left");
|
||||
top = block.css("top");
|
||||
|
||||
});
|
||||
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
|
||||
equal( left, "30px" );
|
||||
equal( top, "25px" );
|
||||
|
||||
});
|
||||
|
||||
test("_blockFrames, static parent", function() {
|
||||
expect( 3 );
|
||||
var el = $("#draggable1").draggable(),
|
||||
parent = $("<div style='width: 600px; height: 600px; margin-top: 300px; margin-left: 400px;'>"),
|
||||
iframe = $("<iframe src='about:blank' width='500' height='500' style='position: relative; top: 25px; left: 30px;'>"),
|
||||
left, top;
|
||||
|
||||
parent.append( iframe );
|
||||
|
||||
$("#qunit-fixture").prepend( parent );
|
||||
|
||||
el.on( "drag", function() {
|
||||
|
||||
var block = iframe.next();
|
||||
|
||||
left = block.css("left");
|
||||
top = block.css("top");
|
||||
|
||||
});
|
||||
|
||||
TestHelpers.draggable.shouldMove(el);
|
||||
|
||||
equal( left, "430px" );
|
||||
equal( top, "325px" );
|
||||
|
||||
});
|
||||
|
||||
test("resizable handle with complex markup (#8756 / #8757)", function() {
|
||||
expect( 2 );
|
||||
|
||||
|
10
ui/jquery.ui.draggable.js
vendored
10
ui/jquery.ui.draggable.js
vendored
@ -447,18 +447,16 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
||||
_blockFrames: function() {
|
||||
|
||||
this.iframeBlocks = this.document.find( "iframe" ).map(function() {
|
||||
var iframe = $( this ),
|
||||
iframeOffset = iframe.offset();
|
||||
var iframe = $( this );
|
||||
|
||||
return $( "<div>" )
|
||||
.css({
|
||||
position: "absolute",
|
||||
width: iframe.outerWidth(),
|
||||
height: iframe.outerHeight(),
|
||||
top: iframeOffset.top,
|
||||
left: iframeOffset.left
|
||||
height: iframe.outerHeight()
|
||||
})
|
||||
.appendTo( iframe.parent() )[0];
|
||||
.appendTo( iframe.parent() )
|
||||
.offset( iframe.offset() )[0];
|
||||
});
|
||||
},
|
||||
|
||||
|
10
ui/jquery.ui.sortable.js
vendored
10
ui/jquery.ui.sortable.js
vendored
@ -447,18 +447,16 @@ $.widget( "ui.sortable", $.ui.interaction, {
|
||||
_blockFrames: function() {
|
||||
|
||||
this.iframeBlocks = this.document.find( "iframe" ).map(function() {
|
||||
var iframe = $( this ),
|
||||
iframeOffset = iframe.offset();
|
||||
var iframe = $( this );
|
||||
|
||||
return $( "<div>" )
|
||||
.css({
|
||||
position: "absolute",
|
||||
width: iframe.outerWidth(),
|
||||
height: iframe.outerHeight(),
|
||||
top: iframeOffset.top,
|
||||
left: iframeOffset.left
|
||||
height: iframe.outerHeight()
|
||||
})
|
||||
.appendTo( iframe.parent() )[0];
|
||||
.appendTo( iframe.parent() )
|
||||
.offset( iframe.offset() )[0];
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user