2015-04-06 18:33:25 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-07-15 02:05:00 +00:00
|
|
|
"ui/widgets/resizable"
|
2015-04-07 14:30:07 +00:00
|
|
|
], function( $, testHelper ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
module( "resizable: options" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-12-03 15:36:55 +00:00
|
|
|
test( "alsoResize", function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var other = $( "<div>" )
|
2015-08-24 12:58:35 +00:00
|
|
|
.css( {
|
2012-12-03 15:36:55 +00:00
|
|
|
width: 50,
|
|
|
|
height: 50
|
2015-08-24 12:58:35 +00:00
|
|
|
} )
|
2012-12-03 15:36:55 +00:00
|
|
|
.appendTo( "body" ),
|
2015-08-24 12:58:35 +00:00
|
|
|
element = $( "#resizable1" ).resizable( {
|
2012-12-03 15:36:55 +00:00
|
|
|
alsoResize: other
|
2015-08-24 12:58:35 +00:00
|
|
|
} ),
|
2012-12-03 15:36:55 +00:00
|
|
|
handle = ".ui-resizable-e";
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 80 );
|
2012-12-03 15:36:55 +00:00
|
|
|
equal( element.width(), 180, "resizable width" );
|
|
|
|
equal( other.width(), 130, "alsoResize width" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2012-12-03 15:36:55 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (e)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -130 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (w)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 130 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (n)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 0, -80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 0, 80 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (s)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 0, 80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 0, -80 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (se)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 80, 80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -80, -80 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (sw)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -80, 80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 80, -80 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "aspectRatio: 'preserve' (ne)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 80, -80 );
|
|
|
|
equal( target.width(), 130, "compare maxWidth" );
|
|
|
|
equal( target.height(), 130, "compare maxHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -80, 80 );
|
|
|
|
equal( target.width(), 70, "compare minWidth" );
|
|
|
|
equal( target.height(), 70, "compare minHeight" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2013-11-01 11:06:47 +00:00
|
|
|
test( "aspectRatio: Resizing can move objects", function() {
|
|
|
|
expect( 7 );
|
|
|
|
|
2015-08-21 04:07:28 +00:00
|
|
|
// Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects
|
2013-11-01 11:06:47 +00:00
|
|
|
var handleW = ".ui-resizable-w",
|
|
|
|
handleNW = ".ui-resizable-nw",
|
2015-08-24 12:58:35 +00:00
|
|
|
target = $( "#resizable1" ).resizable( {
|
2013-11-01 11:06:47 +00:00
|
|
|
aspectRatio: true,
|
|
|
|
handles: "all",
|
|
|
|
containment: "parent"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-01 11:06:47 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
$( "#container" ).css( { width: 200, height: 300 } );
|
|
|
|
$( "#resizable1" ).css( { width: 100, height: 100, left: 75, top: 200 } );
|
2013-11-01 11:06:47 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handleW, -20 );
|
2013-11-01 11:06:47 +00:00
|
|
|
equal( target.width(), 100, "compare width - no size change" );
|
|
|
|
equal( target.height(), 100, "compare height - no size change" );
|
|
|
|
equal( target.position().left, 75, "compare left - no movement" );
|
|
|
|
|
2015-08-21 04:07:28 +00:00
|
|
|
// Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly
|
2015-08-24 12:58:35 +00:00
|
|
|
$( "#container" ).css( { width: 200, height: 300, position: "absolute", left: 100, top: 100 } );
|
|
|
|
$( "#resizable1" ).css( { width: 100, height: 100, left: 0, top: 0 } );
|
2013-11-01 11:06:47 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handleNW, -20, -20 );
|
2013-11-01 11:06:47 +00:00
|
|
|
equal( target.width(), 100, "compare width - no size change" );
|
|
|
|
equal( target.height(), 100, "compare height - no size change" );
|
|
|
|
equal( target.position().left, 0, "compare left - no movement" );
|
|
|
|
equal( target.position().top, 0, "compare top - no movement" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-01 11:06:47 +00:00
|
|
|
|
2012-12-03 15:36:55 +00:00
|
|
|
test( "containment", function() {
|
2014-08-04 11:29:11 +00:00
|
|
|
expect( 4 );
|
2014-08-04 12:18:35 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var element = $( "#resizable1" ).resizable( {
|
2012-12-03 15:36:55 +00:00
|
|
|
containment: "#container"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2012-12-03 15:36:55 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-se", 20, 30 );
|
2012-12-03 15:36:55 +00:00
|
|
|
equal( element.width(), 120, "unconstrained width within container" );
|
|
|
|
equal( element.height(), 130, "unconstrained height within container" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
2012-12-03 15:36:55 +00:00
|
|
|
equal( element.width(), 300, "constrained width at containment edge" );
|
|
|
|
equal( element.height(), 200, "constrained height at containment edge" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-04 11:29:11 +00:00
|
|
|
|
|
|
|
test( "containment - not immediate parent", function() {
|
|
|
|
expect( 4 );
|
2013-11-07 14:39:51 +00:00
|
|
|
|
2015-08-21 04:07:28 +00:00
|
|
|
// Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
|
2013-11-07 14:39:51 +00:00
|
|
|
// when containment element is not the immediate parent
|
2015-08-24 12:58:35 +00:00
|
|
|
var element = $( "#child" ).resizable( {
|
2013-11-07 14:39:51 +00:00
|
|
|
containment: "#container2",
|
|
|
|
handles: "all"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-07 14:39:51 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-e", 300, 0 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.width(), 400, "Relative, contained within container width" );
|
2013-11-07 14:39:51 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-s", 0, 300 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.height(), 400, "Relative, contained within container height" );
|
|
|
|
|
|
|
|
$( "#child" ).css( { left: 50, top: 50 } );
|
|
|
|
$( "#parent" ).css( { left: 50, top: 50 } );
|
|
|
|
$( "#container2" ).css( { left: 50, top: 50 } );
|
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
element = $( "#child" ).resizable( {
|
2014-08-04 11:29:11 +00:00
|
|
|
containment: "#container2",
|
|
|
|
handles: "all"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-04 11:29:11 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.width(), 300, "Relative with Left, contained within container width" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.height(), 300, "Relative with Top, contained within container height" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-04 11:29:11 +00:00
|
|
|
|
|
|
|
test( "containment - immediate parent", function() {
|
|
|
|
expect( 4 );
|
|
|
|
|
2015-08-21 04:07:28 +00:00
|
|
|
// Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
|
2014-08-04 11:29:11 +00:00
|
|
|
// when containment element is immediate parent
|
2015-08-24 12:58:35 +00:00
|
|
|
var element = $( "#child" ).resizable( {
|
2014-08-04 11:29:11 +00:00
|
|
|
containment: "parent",
|
|
|
|
handles: "all"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-04 11:29:11 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.width(), 300, "Relative, contained within container width" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.height(), 300, "Relative, contained within container height" );
|
|
|
|
|
|
|
|
$( "#child" ).css( { left: 50, top: 50 } );
|
|
|
|
$( "#parent" ).css( { left: 50, top: 50 } );
|
|
|
|
$( "#container2" ).css( { left: 50, top: 50 } );
|
2014-08-04 12:18:35 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
element = $( "#child" ).resizable( {
|
2014-08-04 12:18:35 +00:00
|
|
|
containment: "parent",
|
|
|
|
handles: "all"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-04 12:18:35 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.width(), 250, "Relative with Left, contained within container width" );
|
2014-08-04 12:18:35 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
2014-08-04 11:29:11 +00:00
|
|
|
equal( element.height(), 250, "Relative with Top, contained within container height" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2012-12-03 15:36:55 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "grid", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 3, 9 );
|
|
|
|
equal( target.width(), 103, "compare width" );
|
|
|
|
equal( target.height(), 100, "compare height" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 15, 11 );
|
|
|
|
equal( target.width(), 118, "compare width" );
|
|
|
|
equal( target.height(), 120, "compare height" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "grid (min/max dimensions)", function() {
|
|
|
|
expect( 4 );
|
2012-07-10 17:21:56 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 } );
|
2012-07-10 17:21:56 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 50, 50 );
|
|
|
|
equal( target.width(), 120, "grid should respect maxWidth" );
|
|
|
|
equal( target.height(), 120, "grid should respect maxHeight" );
|
2012-07-10 17:21:56 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -100, -100 );
|
|
|
|
equal( target.width(), 80, "grid should respect minWidth" );
|
|
|
|
equal( target.height(), 80, "grid should respect minHeight" );
|
|
|
|
} );
|
2012-07-10 17:21:56 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "grid (wrapped)", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-se", target = $( "#resizable2" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 3, 9 );
|
|
|
|
equal( target.width(), 103, "compare width" );
|
|
|
|
equal( target.height(), 100, "compare height" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 15, 11 );
|
|
|
|
equal( target.width(), 118, "compare width" );
|
|
|
|
equal( target.height(), 120, "compare height" );
|
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2013-11-09 04:45:36 +00:00
|
|
|
test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
|
|
|
|
expect( 6 );
|
|
|
|
|
|
|
|
var oldPosition,
|
|
|
|
handle = ".ui-resizable-nw",
|
2015-08-24 12:58:35 +00:00
|
|
|
target = $( "#resizable1" ).resizable( {
|
2013-11-09 04:45:36 +00:00
|
|
|
handles: "all",
|
|
|
|
grid: 50
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-09 04:45:36 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 50, 50 );
|
2013-11-09 04:45:36 +00:00
|
|
|
equal( target.width(), 50, "compare width" );
|
|
|
|
equal( target.height(), 50, "compare height" );
|
|
|
|
|
|
|
|
oldPosition = target.position();
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 50, 50 );
|
2013-11-09 04:45:36 +00:00
|
|
|
equal( target.width(), 50, "compare width" );
|
|
|
|
equal( target.height(), 50, "compare height" );
|
|
|
|
equal( target.position().top, oldPosition.top, "compare top" );
|
|
|
|
equal( target.position().left, oldPosition.left, "compare left" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-09 04:45:36 +00:00
|
|
|
|
2014-08-05 17:58:11 +00:00
|
|
|
test( "grid - maintains grid with padding and border when approaching no dimensions", function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
2015-08-21 04:07:28 +00:00
|
|
|
// Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
|
2014-08-05 17:58:11 +00:00
|
|
|
var handle = ".ui-resizable-nw",
|
2015-08-24 12:58:35 +00:00
|
|
|
target = $( "#resizable1" ).css( {
|
2014-08-05 17:58:11 +00:00
|
|
|
padding: 5,
|
2014-08-14 03:06:21 +00:00
|
|
|
border: "5px solid black",
|
2014-08-05 17:58:11 +00:00
|
|
|
width: 80,
|
|
|
|
height: 80
|
2015-08-24 12:58:35 +00:00
|
|
|
} ).resizable( {
|
2014-08-05 17:58:11 +00:00
|
|
|
handles: "all",
|
2015-01-28 03:08:05 +00:00
|
|
|
grid: [ 50, 12 ]
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-05 17:58:11 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 50, 50 );
|
2014-08-05 17:58:11 +00:00
|
|
|
equal( target.outerWidth(), 50, "compare width" );
|
2015-01-28 03:08:05 +00:00
|
|
|
equal( target.outerHeight(), 52, "compare height" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-05 17:58:11 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -50, -50 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 60, "compare minWidth" );
|
|
|
|
equal( target.height(), 60, "compare minHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 70, 70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 100, "compare maxWidth" );
|
|
|
|
equal( target.height(), 100, "compare maxHeight" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 50, -50 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 60, "compare minWidth" );
|
|
|
|
equal( target.height(), 60, "compare minHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -70, 70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 100, "compare maxWidth" );
|
|
|
|
equal( target.height(), 100, "compare maxHeight" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -50, 50 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 60, "compare minWidth" );
|
|
|
|
equal( target.height(), 60, "compare minHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 70, -70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 100, "compare maxWidth" );
|
|
|
|
equal( target.height(), 100, "compare maxHeight" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
|
|
|
|
expect( 4 );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, 70, 70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 60, "compare minWidth" );
|
|
|
|
equal( target.height(), 60, "compare minHeight" );
|
2009-02-04 04:47:39 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
testHelper.drag( handle, -70, -70 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( target.width(), 100, "compare maxWidth" );
|
|
|
|
equal( target.height(), 100, "compare maxHeight" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-14 12:40:57 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function() {
|
2013-11-14 12:40:57 +00:00
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var handle = "#resizer1",
|
2015-08-24 12:58:35 +00:00
|
|
|
target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" ) }, containment: "parent" } );
|
2013-11-14 12:40:57 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 0, 70 );
|
2013-11-14 12:40:57 +00:00
|
|
|
equal( target.height(), 170, "compare height" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 0, -70 );
|
2013-11-14 12:40:57 +00:00
|
|
|
equal( target.height(), 100, "compare height" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-14 12:40:57 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function() {
|
2013-11-14 12:40:57 +00:00
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var handle = "#resizer1",
|
2015-08-24 12:58:35 +00:00
|
|
|
target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" } );
|
2013-11-14 12:40:57 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 0, 70 );
|
2013-11-14 12:40:57 +00:00
|
|
|
equal( target.height(), 170, "compare height" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( handle, 0, -70 );
|
2013-11-14 12:40:57 +00:00
|
|
|
equal( target.height(), 100, "compare height" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2013-11-14 12:40:57 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
test( "zIndex, applied to all handles", function() {
|
|
|
|
expect( 8 );
|
2012-04-20 15:20:50 +00:00
|
|
|
|
2015-08-24 12:58:35 +00:00
|
|
|
var target = $( "<div></div>" ).resizable( { handles: "all", zIndex: 100 } );
|
2012-12-26 13:08:48 +00:00
|
|
|
target.children( ".ui-resizable-handle" ).each( function( index, handle ) {
|
|
|
|
equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
|
|
|
} );
|
2012-01-10 02:42:56 +00:00
|
|
|
|
2016-01-21 14:40:23 +00:00
|
|
|
test( "setOption handles", function() {
|
|
|
|
expect( 11 );
|
|
|
|
|
|
|
|
var target = $( "<div></div>" ).resizable();
|
|
|
|
|
|
|
|
function checkHandles( expectedHandles ) {
|
|
|
|
expectedHandles = expectedHandles.map( function( value ) {
|
|
|
|
return ".ui-resizable-" + value;
|
|
|
|
} );
|
|
|
|
|
|
|
|
var handles = target.find( ".ui-resizable-handle" );
|
|
|
|
|
|
|
|
equal( handles.length, expectedHandles.length, "Correct number of handles found" );
|
|
|
|
$.each( expectedHandles, function( index, handleClass ) {
|
|
|
|
equal( handles.filter( handleClass ).length, 1, "Found " + handleClass );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
checkHandles( [ "e", "s", "se" ] );
|
|
|
|
|
|
|
|
target.resizable( "option", "handles", "n, w, nw" );
|
|
|
|
checkHandles( [ "n", "w", "nw" ] );
|
|
|
|
|
|
|
|
target.resizable( "option", "handles", "s, w" );
|
|
|
|
checkHandles( [ "s", "w" ] );
|
|
|
|
} );
|
|
|
|
|
2012-12-03 15:36:55 +00:00
|
|
|
test( "alsoResize + containment", function() {
|
|
|
|
expect( 4 );
|
|
|
|
var other = $( "<div>" )
|
2015-08-24 12:58:35 +00:00
|
|
|
.css( {
|
2012-12-03 15:36:55 +00:00
|
|
|
width: 50,
|
|
|
|
height: 50
|
2015-08-24 12:58:35 +00:00
|
|
|
} )
|
2012-12-03 15:36:55 +00:00
|
|
|
.appendTo( "body" ),
|
2015-08-24 12:58:35 +00:00
|
|
|
element = $( "#resizable1" ).resizable( {
|
2012-12-03 15:36:55 +00:00
|
|
|
alsoResize: other,
|
|
|
|
containment: "#container"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2012-12-03 15:36:55 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
2012-12-03 15:36:55 +00:00
|
|
|
equal( element.width(), 300, "resizable constrained width 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.height(), 150, "alsoResize constrained height at containment edge" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2012-12-03 15:36:55 +00:00
|
|
|
|
2014-08-25 18:07:25 +00:00
|
|
|
test( "alsoResize + multiple selection", function() {
|
|
|
|
expect( 6 );
|
|
|
|
var other1 = $( "<div>" )
|
|
|
|
.addClass( "other" )
|
2015-08-24 12:58:35 +00:00
|
|
|
.css( {
|
2014-08-25 18:07:25 +00:00
|
|
|
width: 50,
|
|
|
|
height: 50
|
2015-08-24 12:58:35 +00:00
|
|
|
} )
|
2014-08-25 18:07:25 +00:00
|
|
|
.appendTo( "body" ),
|
|
|
|
other2 = $( "<div>" )
|
|
|
|
.addClass( "other" )
|
2015-08-24 12:58:35 +00:00
|
|
|
.css( {
|
2014-08-25 18:07:25 +00:00
|
|
|
width: 50,
|
|
|
|
height: 50
|
2015-08-24 12:58:35 +00:00
|
|
|
} )
|
|
|
|
.appendTo( "body" ),
|
|
|
|
element = $( "#resizable1" ).resizable( {
|
2014-08-25 18:07:25 +00:00
|
|
|
alsoResize: other1.add( other2 ),
|
|
|
|
containment: "#container"
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-25 18:07:25 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
2014-08-25 18:07:25 +00:00
|
|
|
equal( element.width(), 300, "resizable constrained width at containment edge" );
|
|
|
|
equal( element.height(), 200, "resizable constrained height at containment edge" );
|
|
|
|
equal( other1.width(), 250, "alsoResize o1 constrained width 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.height(), 150, "alsoResize o2 constrained height at containment edge" );
|
2015-08-24 12:58:35 +00:00
|
|
|
} );
|
2014-08-25 18:07:25 +00:00
|
|
|
|
2015-04-06 18:33:25 +00:00
|
|
|
} );
|