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:
Dave Stein 2013-02-18 17:13:29 -05:00
parent d438973983
commit 894d4c157a
3 changed files with 89 additions and 12 deletions

View File

@ -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 );

View File

@ -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];
});
},

View File

@ -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];
});
},