Resizable: Style updates

Ref #14246
This commit is contained in:
Alexander Schmitz 2015-08-24 08:58:35 -04:00
parent 9a015df3a3
commit 5850a5c755
7 changed files with 619 additions and 619 deletions

View File

@ -35,6 +35,6 @@ common.testWidget( "resizable", {
start: null, start: null,
stop: null stop: null
} }
}); } );
} ); } );

View File

@ -4,7 +4,7 @@ define( [
"ui/widgets/resizable" "ui/widgets/resizable"
], function( $, testHelper ) { ], function( $, testHelper ) {
module("resizable: core"); module( "resizable: core" );
/* /*
test("element types", function() { test("element types", function() {
@ -25,188 +25,188 @@ test("element types", function() {
}); });
*/ */
test("n", function() { test( "n", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, 0, -50); testHelper.drag( handle, 0, -50 );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
testHelper.drag(handle, 0, 50); testHelper.drag( handle, 0, 50 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.left, "", "left should not be modified" ); equal( target[ 0 ].style.left, "", "left should not be modified" );
equal( target[0].style.width, "", "width should not be modified" ); equal( target[ 0 ].style.width, "", "width should not be modified" );
}); } );
test("s", function() { test( "s", function() {
expect(5); expect( 5 );
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, 0, 50); testHelper.drag( handle, 0, 50 );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
testHelper.drag(handle, 0, -50); testHelper.drag( handle, 0, -50 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.top, "", "top should not be modified" ); equal( target[ 0 ].style.top, "", "top should not be modified" );
equal( target[0].style.left, "", "left should not be modified" ); equal( target[ 0 ].style.left, "", "left should not be modified" );
equal( target[0].style.width, "", "width should not be modified" ); equal( target[ 0 ].style.width, "", "width should not be modified" );
}); } );
test("e", function() { test( "e", function() {
expect(5); expect( 5 );
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, 50); testHelper.drag( handle, 50 );
equal( target.width(), 150, "compare width");
testHelper.drag(handle, -50);
equal( target.width(), 100, "compare width" );
equal( target[0].style.height, "", "height should not be modified" );
equal( target[0].style.top, "", "top should not be modified" );
equal( target[0].style.left, "", "left should not be modified" );
});
test("w", function() {
expect(4);
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" });
testHelper.drag(handle, -50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
testHelper.drag(handle, 50); testHelper.drag( handle, -50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target[0].style.height, "", "height should not be modified" ); equal( target[ 0 ].style.height, "", "height should not be modified" );
equal( target[0].style.top, "", "top should not be modified" ); equal( target[ 0 ].style.top, "", "top should not be modified" );
}); equal( target[ 0 ].style.left, "", "left should not be modified" );
} );
test("ne", function() { test( "w", function() {
expect(5); expect( 4 );
var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" }); var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, -50, -50); testHelper.drag( handle, -50 );
equal( target.width(), 150, "compare width" );
testHelper.drag( handle, 50 );
equal( target.width(), 100, "compare width" );
equal( target[ 0 ].style.height, "", "height should not be modified" );
equal( target[ 0 ].style.top, "", "top should not be modified" );
} );
test( "ne", function() {
expect( 5 );
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).css( { overflow: "hidden" } ).resizable( { handles: "all" } );
testHelper.drag( handle, -50, -50 );
equal( target.width(), 50, "compare width" ); equal( target.width(), 50, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.left, "", "left should not be modified" ); equal( target[ 0 ].style.left, "", "left should not be modified" );
}); } );
test("se", function() { test( "se", function() {
expect(6); expect( 6 );
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
testHelper.drag(handle, -50, -50); testHelper.drag( handle, -50, -50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.top, "", "top should not be modified" ); equal( target[ 0 ].style.top, "", "top should not be modified" );
equal( target[0].style.left, "", "left should not be modified" ); equal( target[ 0 ].style.left, "", "left should not be modified" );
}); } );
test("sw", function() { test( "sw", function() {
expect(5); expect( 5 );
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, -50, -50); testHelper.drag( handle, -50, -50 );
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 50, "compare height" ); equal( target.height(), 50, "compare height" );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.top, "", "top should not be modified" ); equal( target[ 0 ].style.top, "", "top should not be modified" );
}); } );
test("nw", function() { test( "nw", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, -50, -50); testHelper.drag( handle, -50, -50 );
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); } );
test("handle with complex markup (#8756)", function() { test( "handle with complex markup (#8756)", function() {
expect(2); expect( 2 );
$("#resizable1") $( "#resizable1" )
.append( .append(
$("<div>") $( "<div>" )
.addClass("ui-resizable-handle") .addClass( "ui-resizable-handle" )
.addClass("ui-resizable-w") .addClass( "ui-resizable-w" )
.append($("<div>")) .append( $( "<div>" ) )
); );
var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-w div", target = $( "#resizable1" ).resizable( { handles: "all" } );
testHelper.drag(handle, -50); testHelper.drag( handle, -50 );
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
testHelper.drag(handle, 50); testHelper.drag( handle, 50 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
}); } );
test("resizable accounts for scroll position correctly (#3815)", function() { test( "resizable accounts for scroll position correctly (#3815)", function() {
expect( 4 ); expect( 4 );
var position, top, left, var position, top, left,
container = $("<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>").appendTo("#qunit-fixture"), container = $( "<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>" ).appendTo( "#qunit-fixture" ),
overflowed = $("<div style='width: 1000px; height: 1000px;'></div>").appendTo( container ), overflowed = $( "<div style='width: 1000px; height: 1000px;'></div>" ).appendTo( container ),
el = $("<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>").appendTo( overflowed ).resizable({ handles: "all" }), el = $( "<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>" ).appendTo( overflowed ).resizable( { handles: "all" } ),
handle = ".ui-resizable-e", handle = ".ui-resizable-e",
handlePosition = $(handle).position().left; handlePosition = $( handle ).position().left;
container.scrollLeft( 100 ).scrollTop( 100 ); container.scrollLeft( 100 ).scrollTop( 100 );
position = el.position(); position = el.position();
left = el.css("left"); left = el.css( "left" );
top = el.css("top"); top = el.css( "top" );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
deepEqual( el.position(), position, "position stays the same when resized" ); deepEqual( el.position(), position, "position stays the same when resized" );
equal( el.css("left"), left, "css('left') stays the same when resized" ); equal( el.css( "left" ), left, "css('left') stays the same when resized" );
equal( el.css("top"), top, "css('top') stays the same when resized" ); equal( el.css( "top" ), top, "css('top') stays the same when resized" );
equal( $(handle).position().left, handlePosition + 50, "handle also moved" ); equal( $( handle ).position().left, handlePosition + 50, "handle also moved" );
}); } );
test( "resizable stores correct size when using helper and grid (#9547)", function() { test( "resizable stores correct size when using helper and grid (#9547)", function() {
expect( 2 ); expect( 2 );
var handle = ".ui-resizable-se", var handle = ".ui-resizable-se",
target = $( "#resizable1" ).resizable({ target = $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
helper: "ui-resizable-helper", helper: "ui-resizable-helper",
grid: [ 10, 10 ] grid: [ 10, 10 ]
}); } );
testHelper.drag( handle, 1, 1 ); testHelper.drag( handle, 1, 1 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); } );
test( "nested resizable", function() { test( "nested resizable", function() {
expect( 4 ); expect( 4 );
@ -220,9 +220,9 @@ test( "nested resizable", function() {
outer.appendTo( target ); outer.appendTo( target );
inner.appendTo( outer ); inner.appendTo( outer );
inner.resizable( { handles : "e" } ); inner.resizable( { handles: "e" } );
outer.resizable( { handles : "e" } ); outer.resizable( { handles: "e" } );
target.resizable( { handles : "e" } ); target.resizable( { handles: "e" } );
innerHandle = $( "#inner > .ui-resizable-e" ); innerHandle = $( "#inner > .ui-resizable-e" );
outerHandle = $( "#outer > .ui-resizable-e" ); outerHandle = $( "#outer > .ui-resizable-e" );
@ -239,6 +239,6 @@ test( "nested resizable", function() {
inner.remove(); inner.remove();
outer.remove(); outer.remove();
}); } );
} ); } );

View File

@ -4,31 +4,31 @@ define( [
"ui/widgets/resizable" "ui/widgets/resizable"
], function( $, testHelper ) { ], function( $, testHelper ) {
module("resizable: events"); module( "resizable: events" );
test("start", function() { test( "start", function() {
expect(5); expect( 5 );
var count = 0, var count = 0,
handle = ".ui-resizable-se"; handle = ".ui-resizable-se";
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
start: function(event, ui) { start: function( event, ui ) {
equal( ui.size.width, 100, "compare width" ); equal( ui.size.width, 100, "compare width" );
equal( ui.size.height, 100, "compare height" ); equal( ui.size.height, 100, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" ); equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" ); equal( ui.originalSize.height, 100, "compare original height" );
count++; count++;
} }
}); } );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal(count, 1, "start callback should happen exactly once"); equal( count, 1, "start callback should happen exactly once" );
}); } );
test( "resize", function() { test( "resize", function() {
@ -37,7 +37,7 @@ test( "resize", function() {
var count = 0, var count = 0,
handle = ".ui-resizable-se"; handle = ".ui-resizable-se";
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
resize: function( event, ui ) { resize: function( event, ui ) {
if ( count === 0 ) { if ( count === 0 ) {
@ -53,13 +53,13 @@ test( "resize", function() {
} }
count++; count++;
} }
}); } );
testHelper.drag( handle, 50, 50 ); testHelper.drag( handle, 50, 50 );
equal( count, 2, "resize callback should happen exactly once per size adjustment" ); equal( count, 2, "resize callback should happen exactly once per size adjustment" );
}); } );
test( "resize (min/max dimensions)", function() { test( "resize (min/max dimensions)", function() {
@ -68,7 +68,7 @@ test( "resize (min/max dimensions)", function() {
var count = 0, var count = 0,
handle = ".ui-resizable-se"; handle = ".ui-resizable-se";
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
minWidth: 60, minWidth: 60,
minHeight: 60, minHeight: 60,
@ -81,13 +81,13 @@ test( "resize (min/max dimensions)", function() {
equal( ui.originalSize.height, 100, "compare original height" ); equal( ui.originalSize.height, 100, "compare original height" );
count++; count++;
} }
}); } );
testHelper.drag( handle, -200, -200 ); testHelper.drag( handle, -200, -200 );
equal( count, 1, "resize callback should happen exactly once per size adjustment" ); equal( count, 1, "resize callback should happen exactly once per size adjustment" );
}); } );
test( "resize (containment)", function() { test( "resize (containment)", function() {
@ -95,12 +95,12 @@ test( "resize (containment)", function() {
var count = 0, var count = 0,
handle = ".ui-resizable-se", handle = ".ui-resizable-se",
container = $("#resizable1").wrap("<div>").parent().css({ container = $( "#resizable1" ).wrap( "<div>" ).parent().css( {
height: "100px", height: "100px",
width: "100px" width: "100px"
}); } );
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
containment: container, containment: container,
resize: function( event, ui ) { resize: function( event, ui ) {
@ -110,7 +110,7 @@ test( "resize (containment)", function() {
equal( ui.originalSize.height, 100, "compare original height" ); equal( ui.originalSize.height, 100, "compare original height" );
count++; count++;
} }
}); } );
// Prove you can't resize outside containment by dragging southeast corner southeast // Prove you can't resize outside containment by dragging southeast corner southeast
testHelper.drag( handle, 100, 100 ); testHelper.drag( handle, 100, 100 );
@ -120,45 +120,45 @@ test( "resize (containment)", function() {
equal( count, 1, "resize callback should happen exactly once per size adjustment" ); equal( count, 1, "resize callback should happen exactly once per size adjustment" );
}); } );
test("resize (grid)", function() { test( "resize (grid)", function() {
expect(5); expect( 5 );
var count = 0, var count = 0,
handle = ".ui-resizable-se"; handle = ".ui-resizable-se";
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
grid: 50, grid: 50,
resize: function(event, ui) { resize: function( event, ui ) {
equal( ui.size.width, 150, "compare width" ); equal( ui.size.width, 150, "compare width" );
equal( ui.size.height, 150, "compare height" ); equal( ui.size.height, 150, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" ); equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" ); equal( ui.originalSize.height, 100, "compare original height" );
count++; count++;
} }
}); } );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment"); equal( count, 1, "resize callback should happen exactly once per grid-unit size adjustment" );
}); } );
test( "resize, custom adjustment", function() { test( "resize, custom adjustment", function() {
expect( 4 ); expect( 4 );
var handle = ".ui-resizable-se", var handle = ".ui-resizable-se",
element = $( "#resizable1" ).resizable({ element = $( "#resizable1" ).resizable( {
resize: function( event, ui ) { resize: function( event, ui ) {
ui.size.width = 100; ui.size.width = 100;
ui.size.height = 200; ui.size.height = 200;
ui.position.left = 300; ui.position.left = 300;
ui.position.top = 400; ui.position.top = 400;
} }
}); } );
testHelper.drag( handle, 50, 50 ); testHelper.drag( handle, 50, 50 );
@ -166,31 +166,31 @@ test( "resize, custom adjustment", function() {
equal( element.height(), 200, "resize event can control height" ); equal( element.height(), 200, "resize event can control height" );
equal( element.position().left, 300, "resize event can control left" ); equal( element.position().left, 300, "resize event can control left" );
equal( element.position().top, 400, "resize event can control top" ); equal( element.position().top, 400, "resize event can control top" );
}); } );
test("stop", function() { test( "stop", function() {
expect(5); expect( 5 );
var count = 0, var count = 0,
handle = ".ui-resizable-se"; handle = ".ui-resizable-se";
$("#resizable1").resizable({ $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
stop: function(event, ui) { stop: function( event, ui ) {
equal( ui.size.width, 150, "compare width" ); equal( ui.size.width, 150, "compare width" );
equal( ui.size.height, 150, "compare height" ); equal( ui.size.height, 150, "compare height" );
equal( ui.originalSize.width, 100, "compare original width" ); equal( ui.originalSize.width, 100, "compare original width" );
equal( ui.originalSize.height, 100, "compare original height" ); equal( ui.originalSize.height, 100, "compare original height" );
count++; count++;
} }
}); } );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal(count, 1, "stop callback should happen exactly once"); equal( count, 1, "stop callback should happen exactly once" );
}); } );
test( "resize (containment) works with parent with negative offset", function() { test( "resize (containment) works with parent with negative offset", function() {
@ -204,30 +204,30 @@ test( "resize (containment) works with parent with negative offset", function()
increaseWidthBy = 50; increaseWidthBy = 50;
// Position fixed container in window top left // Position fixed container in window top left
fixedContainer.css({ fixedContainer.css( {
width: 400, width: 400,
height: 100, height: 100,
position: "fixed", position: "fixed",
top: 0, top: 0,
left: 0 left: 0
}); } );
// Position absolute container within fixed on slightly outside window // Position absolute container within fixed on slightly outside window
absoluteContainer.css({ absoluteContainer.css( {
width: 400, width: 400,
height: 100, height: 100,
position: "absolute", position: "absolute",
top: 0, top: 0,
left: -50 left: -50
}); } );
// Set up resizable to be contained within absolute container // Set up resizable to be contained within absolute container
target.resizable({ target.resizable( {
handles: "all", handles: "all",
containment: "parent" containment: "parent"
}).css({ } ).css( {
width: 300 width: 300
}); } );
widthBefore = target.width(); widthBefore = target.width();
@ -237,6 +237,6 @@ test( "resize (containment) works with parent with negative offset", function()
equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" ); equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );
}); } );
} ); } );

View File

@ -5,13 +5,14 @@ define( [
return $.extend( helper, { return $.extend( helper, {
drag: function( el, dx, dy ) { drag: function( el, dx, dy ) {
// this mouseover is to work around a limitation in resizable // this mouseover is to work around a limitation in resizable
// TODO: fix resizable so handle doesn't require mouseover in order to be used // TODO: fix resizable so handle doesn't require mouseover in order to be used
$( el ).simulate("mouseover").simulate( "drag", { $( el ).simulate( "mouseover" ).simulate( "drag", {
moves: 2, moves: 2,
dx: dx, dx: dx,
dy: dy dy: dy
}); } );
} }
} ); } );

View File

@ -8,7 +8,7 @@ module( "resizable: methods" );
test( "disable", function( assert ) { test( "disable", function( assert ) {
expect( 5 ); expect( 5 );
var element = $( "#resizable1" ).resizable({ disabled: false }), var element = $( "#resizable1" ).resizable( { disabled: false } ),
chainable = element.resizable( "disable" ); chainable = element.resizable( "disable" );
assert.lacksClasses( element.resizable( "widget" ), "ui-state-disabled" ); assert.lacksClasses( element.resizable( "widget" ), "ui-state-disabled" );
@ -16,6 +16,6 @@ test( "disable", function( assert ) {
assert.hasClasses( element.resizable( "widget" ), "ui-resizable-disabled" ); assert.hasClasses( element.resizable( "widget" ), "ui-resizable-disabled" );
equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); equal( element.resizable( "option", "disabled" ), true, "disabled option setter" );
equal( chainable, element, "disable is chainable" ); equal( chainable, element, "disable is chainable" );
}); } );
} ); } );

View File

@ -4,124 +4,124 @@ define( [
"ui/widgets/resizable" "ui/widgets/resizable"
], function( $, testHelper ) { ], function( $, testHelper ) {
module("resizable: options"); module( "resizable: options" );
test( "alsoResize", function() { test( "alsoResize", function() {
expect( 2 ); expect( 2 );
var other = $( "<div>" ) var other = $( "<div>" )
.css({ .css( {
width: 50, width: 50,
height: 50 height: 50
}) } )
.appendTo( "body" ), .appendTo( "body" ),
element = $( "#resizable1" ).resizable({ element = $( "#resizable1" ).resizable( {
alsoResize: other alsoResize: other
}), } ),
handle = ".ui-resizable-e"; handle = ".ui-resizable-e";
testHelper.drag( handle, 80 ); testHelper.drag( handle, 80 );
equal( element.width(), 180, "resizable width" ); equal( element.width(), 180, "resizable width" );
equal( other.width(), 130, "alsoResize width" ); equal( other.width(), 130, "alsoResize width" );
}); } );
test("aspectRatio: 'preserve' (e)", function() { test( "aspectRatio: 'preserve' (e)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, 80); testHelper.drag( handle, 80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, -130); testHelper.drag( handle, -130 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (w)", function() { test( "aspectRatio: 'preserve' (w)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, -80); testHelper.drag( handle, -80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, 130); testHelper.drag( handle, 130 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (n)", function() { test( "aspectRatio: 'preserve' (n)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, 0, -80); testHelper.drag( handle, 0, -80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, 0, 80); testHelper.drag( handle, 0, 80 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (s)", function() { test( "aspectRatio: 'preserve' (s)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, 0, 80); testHelper.drag( handle, 0, 80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, 0, -80); testHelper.drag( handle, 0, -80 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (se)", function() { test( "aspectRatio: 'preserve' (se)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, 80, 80); testHelper.drag( handle, 80, 80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, -80, -80); testHelper.drag( handle, -80, -80 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (sw)", function() { test( "aspectRatio: 'preserve' (sw)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, -80, 80); testHelper.drag( handle, -80, 80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, 80, -80); testHelper.drag( handle, 80, -80 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test("aspectRatio: 'preserve' (ne)", function() { test( "aspectRatio: 'preserve' (ne)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
testHelper.drag(handle, 80, -80); testHelper.drag( handle, 80, -80 );
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth" );
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight" );
testHelper.drag(handle, -80, 80); testHelper.drag( handle, -80, 80 );
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth" );
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight" );
}); } );
test( "aspectRatio: Resizing can move objects", function() { test( "aspectRatio: Resizing can move objects", function() {
expect( 7 ); expect( 7 );
@ -129,14 +129,14 @@ test( "aspectRatio: Resizing can move objects", function() {
// Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects // Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects
var handleW = ".ui-resizable-w", var handleW = ".ui-resizable-w",
handleNW = ".ui-resizable-nw", handleNW = ".ui-resizable-nw",
target = $( "#resizable1" ).resizable({ target = $( "#resizable1" ).resizable( {
aspectRatio: true, aspectRatio: true,
handles: "all", handles: "all",
containment: "parent" containment: "parent"
}); } );
$( "#container" ).css({ width: 200, height: 300 }); $( "#container" ).css( { width: 200, height: 300 } );
$( "#resizable1" ).css({ width: 100, height: 100, left: 75, top: 200 }); $( "#resizable1" ).css( { width: 100, height: 100, left: 75, top: 200 } );
testHelper.drag( handleW, -20 ); testHelper.drag( handleW, -20 );
equal( target.width(), 100, "compare width - no size change" ); equal( target.width(), 100, "compare width - no size change" );
@ -144,22 +144,22 @@ test( "aspectRatio: Resizing can move objects", function() {
equal( target.position().left, 75, "compare left - no movement" ); equal( target.position().left, 75, "compare left - no movement" );
// Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly // Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly
$( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 }); $( "#container" ).css( { width: 200, height: 300, position: "absolute", left: 100, top: 100 } );
$( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 }); $( "#resizable1" ).css( { width: 100, height: 100, left: 0, top: 0 } );
testHelper.drag( handleNW, -20, -20 ); testHelper.drag( handleNW, -20, -20 );
equal( target.width(), 100, "compare width - no size change" ); equal( target.width(), 100, "compare width - no size change" );
equal( target.height(), 100, "compare height - no size change" ); equal( target.height(), 100, "compare height - no size change" );
equal( target.position().left, 0, "compare left - no movement" ); equal( target.position().left, 0, "compare left - no movement" );
equal( target.position().top, 0, "compare top - no movement" ); equal( target.position().top, 0, "compare top - no movement" );
}); } );
test( "containment", function() { test( "containment", function() {
expect( 4 ); expect( 4 );
var element = $( "#resizable1" ).resizable({ var element = $( "#resizable1" ).resizable( {
containment: "#container" containment: "#container"
}); } );
testHelper.drag( ".ui-resizable-se", 20, 30 ); testHelper.drag( ".ui-resizable-se", 20, 30 );
equal( element.width(), 120, "unconstrained width within container" ); equal( element.width(), 120, "unconstrained width within container" );
@ -168,17 +168,17 @@ test( "containment", function() {
testHelper.drag( ".ui-resizable-se", 400, 400 ); testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "constrained width at containment edge" ); equal( element.width(), 300, "constrained width at containment edge" );
equal( element.height(), 200, "constrained height at containment edge" ); equal( element.height(), 200, "constrained height at containment edge" );
}); } );
test( "containment - not immediate parent", function() { test( "containment - not immediate parent", function() {
expect( 4 ); expect( 4 );
// Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong // Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
// when containment element is not the immediate parent // when containment element is not the immediate parent
var element = $( "#child" ).resizable({ var element = $( "#child" ).resizable( {
containment: "#container2", containment: "#container2",
handles: "all" handles: "all"
}); } );
testHelper.drag( ".ui-resizable-e", 300, 0 ); testHelper.drag( ".ui-resizable-e", 300, 0 );
equal( element.width(), 400, "Relative, contained within container width" ); equal( element.width(), 400, "Relative, contained within container width" );
@ -190,27 +190,27 @@ test( "containment - not immediate parent", function() {
$( "#parent" ).css( { left: 50, top: 50 } ); $( "#parent" ).css( { left: 50, top: 50 } );
$( "#container2" ).css( { left: 50, top: 50 } ); $( "#container2" ).css( { left: 50, top: 50 } );
element = $( "#child" ).resizable({ element = $( "#child" ).resizable( {
containment: "#container2", containment: "#container2",
handles: "all" handles: "all"
}); } );
testHelper.drag( ".ui-resizable-e", 400, 0 ); testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative with Left, contained within container width" ); equal( element.width(), 300, "Relative with Left, contained within container width" );
testHelper.drag( ".ui-resizable-s", 0, 400 ); testHelper.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 300, "Relative with Top, contained within container height" ); equal( element.height(), 300, "Relative with Top, contained within container height" );
}); } );
test( "containment - immediate parent", function() { test( "containment - immediate parent", function() {
expect( 4 ); expect( 4 );
// Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative" // Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
// when containment element is immediate parent // when containment element is immediate parent
var element = $( "#child" ).resizable({ var element = $( "#child" ).resizable( {
containment: "parent", containment: "parent",
handles: "all" handles: "all"
}); } );
testHelper.drag( ".ui-resizable-e", 400, 0 ); testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative, contained within container width" ); equal( element.width(), 300, "Relative, contained within container width" );
@ -222,69 +222,69 @@ test( "containment - immediate parent", function() {
$( "#parent" ).css( { left: 50, top: 50 } ); $( "#parent" ).css( { left: 50, top: 50 } );
$( "#container2" ).css( { left: 50, top: 50 } ); $( "#container2" ).css( { left: 50, top: 50 } );
element = $( "#child" ).resizable({ element = $( "#child" ).resizable( {
containment: "parent", containment: "parent",
handles: "all" handles: "all"
}); } );
testHelper.drag( ".ui-resizable-e", 400, 0 ); testHelper.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 250, "Relative with Left, contained within container width" ); equal( element.width(), 250, "Relative with Left, contained within container width" );
testHelper.drag( ".ui-resizable-s", 0, 400 ); testHelper.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 250, "Relative with Top, contained within container height" ); equal( element.height(), 250, "Relative with Top, contained within container height" );
}); } );
test("grid", function() { test( "grid", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [ 0, 20 ] }); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
testHelper.drag(handle, 3, 9); testHelper.drag( handle, 3, 9 );
equal( target.width(), 103, "compare width"); equal( target.width(), 103, "compare width" );
equal( target.height(), 100, "compare height"); equal( target.height(), 100, "compare height" );
testHelper.drag(handle, 15, 11); testHelper.drag( handle, 15, 11 );
equal( target.width(), 118, "compare width"); equal( target.width(), 118, "compare width" );
equal( target.height(), 120, "compare height"); equal( target.height(), 120, "compare height" );
}); } );
test("grid (min/max dimensions)", function() { test( "grid (min/max dimensions)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 }); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 } );
testHelper.drag(handle, 50, 50); testHelper.drag( handle, 50, 50 );
equal( target.width(), 120, "grid should respect maxWidth"); equal( target.width(), 120, "grid should respect maxWidth" );
equal( target.height(), 120, "grid should respect maxHeight"); equal( target.height(), 120, "grid should respect maxHeight" );
testHelper.drag(handle, -100, -100); testHelper.drag( handle, -100, -100 );
equal( target.width(), 80, "grid should respect minWidth"); equal( target.width(), 80, "grid should respect minWidth" );
equal( target.height(), 80, "grid should respect minHeight"); equal( target.height(), 80, "grid should respect minHeight" );
}); } );
test("grid (wrapped)", function() { test( "grid (wrapped)", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [ 0, 20 ] }); var handle = ".ui-resizable-se", target = $( "#resizable2" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
testHelper.drag(handle, 3, 9); testHelper.drag( handle, 3, 9 );
equal( target.width(), 103, "compare width"); equal( target.width(), 103, "compare width" );
equal( target.height(), 100, "compare height"); equal( target.height(), 100, "compare height" );
testHelper.drag(handle, 15, 11); testHelper.drag( handle, 15, 11 );
equal( target.width(), 118, "compare width"); equal( target.width(), 118, "compare width" );
equal( target.height(), 120, "compare height"); equal( target.height(), 120, "compare height" );
}); } );
test( "grid - Resizable: can be moved when grid option is set (#9611)", function() { test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
expect( 6 ); expect( 6 );
var oldPosition, var oldPosition,
handle = ".ui-resizable-nw", handle = ".ui-resizable-nw",
target = $( "#resizable1" ).resizable({ target = $( "#resizable1" ).resizable( {
handles: "all", handles: "all",
grid: 50 grid: 50
}); } );
testHelper.drag( handle, 50, 50 ); testHelper.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" ); equal( target.width(), 50, "compare width" );
@ -297,162 +297,159 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function
equal( target.height(), 50, "compare height" ); equal( target.height(), 50, "compare height" );
equal( target.position().top, oldPosition.top, "compare top" ); equal( target.position().top, oldPosition.top, "compare top" );
equal( target.position().left, oldPosition.left, "compare left" ); equal( target.position().left, oldPosition.left, "compare left" );
}); } );
test( "grid - maintains grid with padding and border when approaching no dimensions", function() { test( "grid - maintains grid with padding and border when approaching no dimensions", function() {
expect( 2 ); expect( 2 );
// Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong // Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
var handle = ".ui-resizable-nw", var handle = ".ui-resizable-nw",
target = $( "#resizable1" ).css({ target = $( "#resizable1" ).css( {
padding: 5, padding: 5,
border: "5px solid black", border: "5px solid black",
width: 80, width: 80,
height: 80 height: 80
}).resizable({ } ).resizable( {
handles: "all", handles: "all",
grid: [ 50, 12 ] grid: [ 50, 12 ]
}); } );
testHelper.drag( handle, 50, 50 ); testHelper.drag( handle, 50, 50 );
equal( target.outerWidth(), 50, "compare width" ); equal( target.outerWidth(), 50, "compare width" );
equal( target.outerHeight(), 52, "compare height" ); equal( target.outerHeight(), 52, "compare height" );
}); } );
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
testHelper.drag(handle, -50, -50); testHelper.drag( handle, -50, -50 );
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
testHelper.drag(handle, 70, 70); testHelper.drag( handle, 70, 70 );
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); } );
test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
testHelper.drag(handle, 50, -50); testHelper.drag( handle, 50, -50 );
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
testHelper.drag(handle, -70, 70); testHelper.drag( handle, -70, 70 );
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); } );
test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
testHelper.drag(handle, -50, 50); testHelper.drag( handle, -50, 50 );
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
testHelper.drag(handle, 70, -70); testHelper.drag( handle, 70, -70 );
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); } );
test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4); expect( 4 );
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
testHelper.drag(handle, 70, 70); testHelper.drag( handle, 70, 70 );
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
testHelper.drag(handle, -70, -70); testHelper.drag( handle, -70, -70 );
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); } );
test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function() {
test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function () {
expect( 2 ); expect( 2 );
var handle = "#resizer1", var handle = "#resizer1",
target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" ) }, containment: "parent" }); target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" ) }, containment: "parent" } );
testHelper.drag( handle, 0, 70 ); testHelper.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" ); equal( target.height(), 170, "compare height" );
testHelper.drag( handle, 0, -70 ); testHelper.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); } );
test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function() {
test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function () {
expect( 2 ); expect( 2 );
var handle = "#resizer1", var handle = "#resizer1",
target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" }); target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" } );
testHelper.drag( handle, 0, 70 ); testHelper.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" ); equal( target.height(), 170, "compare height" );
testHelper.drag( handle, 0, -70 ); testHelper.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); } );
test( "zIndex, applied to all handles", function() {
expect( 8 );
test("zIndex, applied to all handles", function() { var target = $( "<div></div>" ).resizable( { handles: "all", zIndex: 100 } );
expect(8);
var target = $("<div></div>").resizable({ handles: "all", zIndex: 100 });
target.children( ".ui-resizable-handle" ).each( function( index, handle ) { target.children( ".ui-resizable-handle" ).each( function( index, handle ) {
equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" ); equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" );
}); } );
}); } );
test( "alsoResize + containment", function() { test( "alsoResize + containment", function() {
expect( 4 ); expect( 4 );
var other = $( "<div>" ) var other = $( "<div>" )
.css({ .css( {
width: 50, width: 50,
height: 50 height: 50
}) } )
.appendTo( "body" ), .appendTo( "body" ),
element = $( "#resizable1" ).resizable({ element = $( "#resizable1" ).resizable( {
alsoResize: other, alsoResize: other,
containment: "#container" containment: "#container"
}); } );
testHelper.drag( ".ui-resizable-se", 400, 400 ); testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" ); equal( element.width(), 300, "resizable constrained width at containment edge" );
equal( element.height(), 200, "resizable constrained height at containment edge" ); equal( element.height(), 200, "resizable constrained height at containment edge" );
equal( other.width(), 250, "alsoResize constrained width at containment edge" ); equal( other.width(), 250, "alsoResize constrained width at containment edge" );
equal( other.height(), 150, "alsoResize constrained height at containment edge" ); equal( other.height(), 150, "alsoResize constrained height at containment edge" );
}); } );
test( "alsoResize + multiple selection", function() { test( "alsoResize + multiple selection", function() {
expect( 6 ); expect( 6 );
var other1 = $( "<div>" ) var other1 = $( "<div>" )
.addClass( "other" ) .addClass( "other" )
.css({ .css( {
width: 50, width: 50,
height: 50 height: 50
}) } )
.appendTo( "body" ), .appendTo( "body" ),
other2 = $( "<div>" ) other2 = $( "<div>" )
.addClass( "other" ) .addClass( "other" )
.css({ .css( {
width: 50, width: 50,
height: 50 height: 50
}) } )
.appendTo( "body"), .appendTo( "body" ),
element = $( "#resizable1" ).resizable({ element = $( "#resizable1" ).resizable( {
alsoResize: other1.add( other2 ), alsoResize: other1.add( other2 ),
containment: "#container" containment: "#container"
}); } );
testHelper.drag( ".ui-resizable-se", 400, 400 ); testHelper.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" ); equal( element.width(), 300, "resizable constrained width at containment edge" );
@ -461,6 +458,6 @@ test( "alsoResize + multiple selection", function() {
equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" ); equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" );
equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" ); equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" );
equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" ); equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" );
}); } );
} ); } );

File diff suppressed because it is too large Load Diff