mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-07-23 19:42:58 +03:00
Merge commit 'd32092c1f0
' as 'jquery-ui'
This commit is contained in:
commit
b23131fdc2
717 changed files with 518330 additions and 0 deletions
26
jquery-ui/tests/unit/resizable/all.html
Normal file
26
jquery-ui/tests/unit/resizable/all.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Resizable Test Suite</title>
|
||||
|
||||
<script src="../../../external/jquery/jquery.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/qunit-composite/qunit-composite.js"></script>
|
||||
<script src="../subsuite.js"></script>
|
||||
|
||||
<script>
|
||||
testAllVersions( "resizable" );
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
40
jquery-ui/tests/unit/resizable/common.js
vendored
Normal file
40
jquery-ui/tests/unit/resizable/common.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
define( [
|
||||
"lib/common",
|
||||
"ui/widgets/resizable"
|
||||
], function( common ) {
|
||||
|
||||
common.testWidget( "resizable", {
|
||||
defaults: {
|
||||
alsoResize: false,
|
||||
animate: false,
|
||||
animateDuration: "slow",
|
||||
animateEasing: "swing",
|
||||
aspectRatio: false,
|
||||
autoHide: false,
|
||||
cancel: "input, textarea, button, select, option",
|
||||
classes: {
|
||||
"ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
|
||||
},
|
||||
containment: false,
|
||||
delay: 0,
|
||||
disabled: false,
|
||||
distance: 1,
|
||||
ghost: false,
|
||||
grid: false,
|
||||
handles: "e,s,se",
|
||||
helper: false,
|
||||
maxHeight: null,
|
||||
maxWidth: null,
|
||||
minHeight: 10,
|
||||
minWidth: 10,
|
||||
zIndex: 90,
|
||||
|
||||
// Callbacks
|
||||
create: null,
|
||||
resize: null,
|
||||
start: null,
|
||||
stop: null
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
245
jquery-ui/tests/unit/resizable/core.js
vendored
Normal file
245
jquery-ui/tests/unit/resizable/core.js
vendored
Normal file
|
@ -0,0 +1,245 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/resizable"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
QUnit.module( "resizable: core" );
|
||||
|
||||
/*
|
||||
Test("element types", function() {
|
||||
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form"
|
||||
+ ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr"
|
||||
+ ",acronym,code,samp,kbd,var,img,object,hr"
|
||||
+ ",input,button,label,select,iframe").split(",");
|
||||
|
||||
$.each(typeNames, function(i) {
|
||||
var typeName = typeNames[i];
|
||||
el = $(document.createElement(typeName)).appendTo("body");
|
||||
(typeName == "table" && el.append("<tr><td>content</td></tr>"));
|
||||
el.resizable();
|
||||
ok(true, "$('<" + typeName + "/>').resizable()");
|
||||
el.resizable("destroy");
|
||||
el.remove();
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
QUnit.test( "n", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, 0, -50 );
|
||||
assert.equal( target.height(), 150, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 0, 50 );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
|
||||
assert.equal( target[ 0 ].style.width, "", "width should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "s", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, 0, 50 );
|
||||
assert.equal( target.height(), 150, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 0, -50 );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
|
||||
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
|
||||
assert.equal( target[ 0 ].style.width, "", "width should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "e", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, 50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
|
||||
testHelper.drag( handle, -50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
|
||||
assert.equal( target[ 0 ].style.height, "", "height should not be modified" );
|
||||
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
|
||||
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "w", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, -50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
|
||||
testHelper.drag( handle, 50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
|
||||
assert.equal( target[ 0 ].style.height, "", "height should not be modified" );
|
||||
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ne", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).css( { overflow: "hidden" } ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, -50, -50 );
|
||||
assert.equal( target.width(), 50, "compare width" );
|
||||
assert.equal( target.height(), 150, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "se", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
assert.equal( target.height(), 150, "compare height" );
|
||||
|
||||
testHelper.drag( handle, -50, -50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
|
||||
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "sw", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, -50, -50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
assert.equal( target.height(), 50, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
|
||||
} );
|
||||
|
||||
QUnit.test( "nw", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, -50, -50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
assert.equal( target.height(), 150, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "handle with complex markup (#8756)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
$( "#resizable1" )
|
||||
.append(
|
||||
$( "<div>" )
|
||||
.addClass( "ui-resizable-handle" )
|
||||
.addClass( "ui-resizable-w" )
|
||||
.append( $( "<div>" ) )
|
||||
);
|
||||
|
||||
var handle = ".ui-resizable-w div", target = $( "#resizable1" ).resizable( { handles: "all" } );
|
||||
|
||||
testHelper.drag( handle, -50 );
|
||||
assert.equal( target.width(), 150, "compare width" );
|
||||
|
||||
testHelper.drag( handle, 50 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
} );
|
||||
|
||||
QUnit.test( "resizable accounts for scroll position correctly (#3815)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var position, top, left,
|
||||
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 ),
|
||||
el = $( "<div style='height:100px;width:100px;position:absolute;top:10px;left:10px;'></div>" ).appendTo( overflowed ).resizable( { handles: "all" } ),
|
||||
handle = ".ui-resizable-e",
|
||||
handlePosition = $( handle ).position().left;
|
||||
|
||||
container.scrollLeft( 100 ).scrollTop( 100 );
|
||||
|
||||
position = el.position();
|
||||
left = el.css( "left" );
|
||||
top = el.css( "top" );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.deepEqual( el.position(), position, "position stays the same when resized" );
|
||||
assert.equal( el.css( "left" ), left, "css('left') stays the same when resized" );
|
||||
assert.equal( el.css( "top" ), top, "css('top') stays the same when resized" );
|
||||
assert.equal( $( handle ).position().left, handlePosition + 50, "handle also moved" );
|
||||
} );
|
||||
|
||||
QUnit.test( "resizable stores correct size when using helper and grid (#9547)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var handle = ".ui-resizable-se",
|
||||
target = $( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
helper: "ui-resizable-helper",
|
||||
grid: [ 10, 10 ]
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 1, 1 );
|
||||
assert.equal( target.width(), 100, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "nested resizable", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var outer = $( "<div id='outer' style='width:50px'></div>" ),
|
||||
inner = $( "<div id='inner' style='width:30px'></div>" ),
|
||||
target = $( "#resizable1" ),
|
||||
innerHandle,
|
||||
outerHandle;
|
||||
|
||||
outer.appendTo( target );
|
||||
inner.appendTo( outer );
|
||||
|
||||
inner.resizable( { handles: "e" } );
|
||||
outer.resizable( { handles: "e" } );
|
||||
target.resizable( { handles: "e" } );
|
||||
|
||||
innerHandle = $( "#inner > .ui-resizable-e" );
|
||||
outerHandle = $( "#outer > .ui-resizable-e" );
|
||||
|
||||
testHelper.drag( innerHandle, 10 );
|
||||
assert.equal( inner.width(), 40, "compare width of inner element" );
|
||||
testHelper.drag( innerHandle, -10 );
|
||||
assert.equal( inner.width(), 30, "compare width of inner element" );
|
||||
|
||||
testHelper.drag( outerHandle, 10 );
|
||||
assert.equal( outer.width(), 60, "compare width of outer element" );
|
||||
testHelper.drag( outerHandle, -10 );
|
||||
assert.equal( outer.width(), 50, "compare width of outer element" );
|
||||
|
||||
inner.remove();
|
||||
outer.remove();
|
||||
} );
|
||||
|
||||
} );
|
243
jquery-ui/tests/unit/resizable/events.js
vendored
Normal file
243
jquery-ui/tests/unit/resizable/events.js
vendored
Normal file
|
@ -0,0 +1,243 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/resizable"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
QUnit.module( "resizable: events" );
|
||||
|
||||
QUnit.test( "start", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se";
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
start: function( event, ui ) {
|
||||
assert.equal( ui.size.width, 100, "compare width" );
|
||||
assert.equal( ui.size.height, 100, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
|
||||
assert.equal( count, 1, "start callback should happen exactly once" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize", function( assert ) {
|
||||
|
||||
assert.expect( 9 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se";
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
resize: function( event, ui ) {
|
||||
if ( count === 0 ) {
|
||||
assert.equal( ui.size.width, 125, "compare width" );
|
||||
assert.equal( ui.size.height, 125, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
} else {
|
||||
assert.equal( ui.size.width, 150, "compare width" );
|
||||
assert.equal( ui.size.height, 150, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
}
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
|
||||
assert.equal( count, 2, "resize callback should happen exactly once per size adjustment" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize (min/max dimensions)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se";
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
minWidth: 60,
|
||||
minHeight: 60,
|
||||
maxWidth: 100,
|
||||
maxHeight: 100,
|
||||
resize: function( event, ui ) {
|
||||
assert.equal( ui.size.width, 60, "compare width" );
|
||||
assert.equal( ui.size.height, 60, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, -200, -200 );
|
||||
|
||||
assert.equal( count, 1, "resize callback should happen exactly once per size adjustment" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize (containment)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se",
|
||||
container = $( "#resizable1" ).wrap( "<div>" ).parent().css( {
|
||||
height: "100px",
|
||||
width: "100px"
|
||||
} );
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
containment: container,
|
||||
resize: function( event, ui ) {
|
||||
assert.equal( ui.size.width, 10, "compare width" );
|
||||
assert.equal( ui.size.height, 10, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
// Prove you can't resize outside containment by dragging southeast corner southeast
|
||||
testHelper.drag( handle, 100, 100 );
|
||||
|
||||
// Prove you can't resize outside containment by dragging southeast corner northwest
|
||||
testHelper.drag( handle, -200, -200 );
|
||||
|
||||
assert.equal( count, 1, "resize callback should happen exactly once per size adjustment" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize (grid)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se";
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
grid: 50,
|
||||
resize: function( event, ui ) {
|
||||
assert.equal( ui.size.width, 150, "compare width" );
|
||||
assert.equal( ui.size.height, 150, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
|
||||
assert.equal( count, 1, "resize callback should happen exactly once per grid-unit size adjustment" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize, custom adjustment", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-se",
|
||||
element = $( "#resizable1" ).resizable( {
|
||||
resize: function( event, ui ) {
|
||||
ui.size.width = 100;
|
||||
ui.size.height = 200;
|
||||
ui.position.left = 300;
|
||||
ui.position.top = 400;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
|
||||
assert.equal( element.width(), 100, "resize event can control width" );
|
||||
assert.equal( element.height(), 200, "resize event can control height" );
|
||||
assert.equal( element.position().left, 300, "resize event can control left" );
|
||||
assert.equal( element.position().top, 400, "resize event can control top" );
|
||||
} );
|
||||
|
||||
QUnit.test( "stop", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
var count = 0,
|
||||
handle = ".ui-resizable-se";
|
||||
|
||||
$( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
stop: function( event, ui ) {
|
||||
assert.equal( ui.size.width, 150, "compare width" );
|
||||
assert.equal( ui.size.height, 150, "compare height" );
|
||||
assert.equal( ui.originalSize.width, 100, "compare original width" );
|
||||
assert.equal( ui.originalSize.height, 100, "compare original height" );
|
||||
count++;
|
||||
}
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
|
||||
assert.equal( count, 1, "stop callback should happen exactly once" );
|
||||
|
||||
} );
|
||||
|
||||
QUnit.test( "resize (containment) works with parent with negative offset", function( assert ) {
|
||||
|
||||
assert.expect( 1 );
|
||||
|
||||
var widthBefore, widthAfter,
|
||||
handle = ".ui-resizable-e",
|
||||
target = $( "#resizable1" ),
|
||||
absoluteContainer = target.wrap( "<div />" ).parent(),
|
||||
fixedContainer = absoluteContainer.wrap( "<div />" ).parent(),
|
||||
increaseWidthBy = 50;
|
||||
|
||||
// Position fixed container in window top left
|
||||
fixedContainer.css( {
|
||||
width: 400,
|
||||
height: 100,
|
||||
position: "fixed",
|
||||
top: 0,
|
||||
left: 0
|
||||
} );
|
||||
|
||||
// Position absolute container within fixed on slightly outside window
|
||||
absoluteContainer.css( {
|
||||
width: 400,
|
||||
height: 100,
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: -50
|
||||
} );
|
||||
|
||||
// Set up resizable to be contained within absolute container
|
||||
target.resizable( {
|
||||
handles: "all",
|
||||
containment: "parent"
|
||||
} ).css( {
|
||||
width: 300
|
||||
} );
|
||||
|
||||
widthBefore = target.width();
|
||||
|
||||
testHelper.drag( handle, increaseWidthBy, 0 );
|
||||
|
||||
widthAfter = target.width();
|
||||
|
||||
assert.equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
20
jquery-ui/tests/unit/resizable/helper.js
vendored
Normal file
20
jquery-ui/tests/unit/resizable/helper.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"lib/helper"
|
||||
], function( QUnit, $, helper ) {
|
||||
|
||||
return $.extend( helper, {
|
||||
drag: function( el, dx, dy ) {
|
||||
|
||||
// This mouseover is to work around a limitation in resizable
|
||||
// TODO: fix resizable so handle doesn't require mouseover in order to be used
|
||||
$( el ).simulate( "mouseover" ).simulate( "drag", {
|
||||
moves: 2,
|
||||
dx: dx,
|
||||
dy: dy
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
BIN
jquery-ui/tests/unit/resizable/images/test.jpg
Normal file
BIN
jquery-ui/tests/unit/resizable/images/test.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 391 B |
22
jquery-ui/tests/unit/resizable/methods.js
vendored
Normal file
22
jquery-ui/tests/unit/resizable/methods.js
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"ui/widgets/resizable"
|
||||
], function( QUnit, $ ) {
|
||||
|
||||
QUnit.module( "resizable: methods" );
|
||||
|
||||
QUnit.test( "disable", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var element = $( "#resizable1" ).resizable( { disabled: false } ),
|
||||
chainable = element.resizable( "disable" );
|
||||
|
||||
assert.lacksClasses( element.resizable( "widget" ), "ui-state-disabled" );
|
||||
assert.ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
assert.hasClasses( element.resizable( "widget" ), "ui-resizable-disabled" );
|
||||
assert.equal( element.resizable( "option", "disabled" ), true, "disabled option setter" );
|
||||
assert.equal( chainable, element, "disable is chainable" );
|
||||
} );
|
||||
|
||||
} );
|
491
jquery-ui/tests/unit/resizable/options.js
vendored
Normal file
491
jquery-ui/tests/unit/resizable/options.js
vendored
Normal file
|
@ -0,0 +1,491 @@
|
|||
define( [
|
||||
"qunit",
|
||||
"jquery",
|
||||
"./helper",
|
||||
"ui/widgets/resizable"
|
||||
], function( QUnit, $, testHelper ) {
|
||||
|
||||
QUnit.module( "resizable: options" );
|
||||
|
||||
QUnit.test( "alsoResize", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var other = $( "<div>" )
|
||||
.css( {
|
||||
width: 50,
|
||||
height: 50
|
||||
} )
|
||||
.appendTo( "body" ),
|
||||
element = $( "#resizable1" ).resizable( {
|
||||
alsoResize: other
|
||||
} ),
|
||||
handle = ".ui-resizable-e";
|
||||
|
||||
testHelper.drag( handle, 80 );
|
||||
assert.equal( element.width(), 180, "resizable width" );
|
||||
assert.equal( other.width(), 130, "alsoResize width" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (e)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
||||
|
||||
testHelper.drag( handle, 80 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, -130 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (w)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } );
|
||||
|
||||
testHelper.drag( handle, -80 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, 130 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (n)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, 0, 80 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (s)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, 0, -80 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (se)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, -80, -80 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (sw)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, 80, -80 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: 'preserve' (ne)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 130, "compare maxWidth" );
|
||||
assert.equal( target.height(), 130, "compare maxHeight" );
|
||||
|
||||
testHelper.drag( handle, -80, 80 );
|
||||
assert.equal( target.width(), 70, "compare minWidth" );
|
||||
assert.equal( target.height(), 70, "compare minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "aspectRatio: Resizing can move objects", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects
|
||||
var handleW = ".ui-resizable-w",
|
||||
handleNW = ".ui-resizable-nw",
|
||||
target = $( "#resizable1" ).resizable( {
|
||||
aspectRatio: true,
|
||||
handles: "all",
|
||||
containment: "parent"
|
||||
} );
|
||||
|
||||
$( "#container" ).css( { width: 200, height: 300 } );
|
||||
$( "#resizable1" ).css( { width: 100, height: 100, left: 75, top: 200 } );
|
||||
|
||||
testHelper.drag( handleW, -20 );
|
||||
assert.equal( target.width(), 100, "compare width - no size change" );
|
||||
assert.equal( target.height(), 100, "compare height - no size change" );
|
||||
assert.equal( target.position().left, 75, "compare left - no movement" );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly
|
||||
$( "#container" ).css( { width: 200, height: 300, position: "absolute", left: 100, top: 100 } );
|
||||
$( "#resizable1" ).css( { width: 100, height: 100, left: 0, top: 0 } );
|
||||
|
||||
testHelper.drag( handleNW, -20, -20 );
|
||||
assert.equal( target.width(), 100, "compare width - no size change" );
|
||||
assert.equal( target.height(), 100, "compare height - no size change" );
|
||||
assert.equal( target.position().left, 0, "compare left - no movement" );
|
||||
assert.equal( target.position().top, 0, "compare top - no movement" );
|
||||
} );
|
||||
|
||||
QUnit.test( "containment", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var element = $( "#resizable1" ).resizable( {
|
||||
containment: "#container"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-se", 20, 30 );
|
||||
assert.equal( element.width(), 120, "unconstrained width within container" );
|
||||
assert.equal( element.height(), 130, "unconstrained height within container" );
|
||||
|
||||
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
||||
assert.equal( element.width(), 300, "constrained width at containment edge" );
|
||||
assert.equal( element.height(), 200, "constrained height at containment edge" );
|
||||
} );
|
||||
|
||||
QUnit.test( "containment - not immediate parent", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
|
||||
// when containment element is not the immediate parent
|
||||
var element = $( "#child" ).resizable( {
|
||||
containment: "#container2",
|
||||
handles: "all"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-e", 300, 0 );
|
||||
assert.equal( element.width(), 400, "Relative, contained within container width" );
|
||||
|
||||
testHelper.drag( ".ui-resizable-s", 0, 300 );
|
||||
assert.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 } );
|
||||
|
||||
element = $( "#child" ).resizable( {
|
||||
containment: "#container2",
|
||||
handles: "all"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
||||
assert.equal( element.width(), 300, "Relative with Left, contained within container width" );
|
||||
|
||||
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
||||
assert.equal( element.height(), 300, "Relative with Top, contained within container height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "containment - immediate parent", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
|
||||
// when containment element is immediate parent
|
||||
var element = $( "#child" ).resizable( {
|
||||
containment: "parent",
|
||||
handles: "all"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
||||
assert.equal( element.width(), 300, "Relative, contained within container width" );
|
||||
|
||||
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
||||
assert.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 } );
|
||||
|
||||
element = $( "#child" ).resizable( {
|
||||
containment: "parent",
|
||||
handles: "all"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-e", 400, 0 );
|
||||
assert.equal( element.width(), 250, "Relative with Left, contained within container width" );
|
||||
|
||||
testHelper.drag( ".ui-resizable-s", 0, 400 );
|
||||
assert.equal( element.height(), 250, "Relative with Top, contained within container height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "grid", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
|
||||
|
||||
testHelper.drag( handle, 3, 9 );
|
||||
assert.equal( target.width(), 103, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 15, 11 );
|
||||
assert.equal( target.width(), 118, "compare width" );
|
||||
assert.equal( target.height(), 120, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "grid (min/max dimensions)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
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 );
|
||||
assert.equal( target.width(), 120, "grid should respect maxWidth" );
|
||||
assert.equal( target.height(), 120, "grid should respect maxHeight" );
|
||||
|
||||
testHelper.drag( handle, -100, -100 );
|
||||
assert.equal( target.width(), 80, "grid should respect minWidth" );
|
||||
assert.equal( target.height(), 80, "grid should respect minHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "grid (wrapped)", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-se", target = $( "#resizable2" ).resizable( { handles: "all", grid: [ 0, 20 ] } );
|
||||
|
||||
testHelper.drag( handle, 3, 9 );
|
||||
assert.equal( target.width(), 103, "compare width" );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 15, 11 );
|
||||
assert.equal( target.width(), 118, "compare width" );
|
||||
assert.equal( target.height(), 120, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "grid - Resizable: can be moved when grid option is set (#9611)", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var oldPosition,
|
||||
handle = ".ui-resizable-nw",
|
||||
target = $( "#resizable1" ).resizable( {
|
||||
handles: "all",
|
||||
grid: 50
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 50, "compare width" );
|
||||
assert.equal( target.height(), 50, "compare height" );
|
||||
|
||||
oldPosition = target.position();
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.width(), 50, "compare width" );
|
||||
assert.equal( target.height(), 50, "compare height" );
|
||||
assert.equal( target.position().top, oldPosition.top, "compare top" );
|
||||
assert.equal( target.position().left, oldPosition.left, "compare left" );
|
||||
} );
|
||||
|
||||
QUnit.test( "grid - maintains grid with padding and border when approaching no dimensions", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
// Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong
|
||||
var handle = ".ui-resizable-nw",
|
||||
target = $( "#resizable1" ).css( {
|
||||
padding: 5,
|
||||
border: "5px solid black",
|
||||
width: 80,
|
||||
height: 80
|
||||
} ).resizable( {
|
||||
handles: "all",
|
||||
grid: [ 50, 12 ]
|
||||
} );
|
||||
|
||||
testHelper.drag( handle, 50, 50 );
|
||||
assert.equal( target.outerWidth(), 50, "compare width" );
|
||||
assert.equal( target.outerHeight(), 52, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
||||
|
||||
testHelper.drag( handle, -50, -50 );
|
||||
assert.equal( target.width(), 60, "compare minWidth" );
|
||||
assert.equal( target.height(), 60, "compare minHeight" );
|
||||
|
||||
testHelper.drag( handle, 70, 70 );
|
||||
assert.equal( target.width(), 100, "compare maxWidth" );
|
||||
assert.equal( target.height(), 100, "compare maxHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
||||
|
||||
testHelper.drag( handle, 50, -50 );
|
||||
assert.equal( target.width(), 60, "compare minWidth" );
|
||||
assert.equal( target.height(), 60, "compare minHeight" );
|
||||
|
||||
testHelper.drag( handle, -70, 70 );
|
||||
assert.equal( target.width(), 100, "compare maxWidth" );
|
||||
assert.equal( target.height(), 100, "compare maxHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
||||
|
||||
testHelper.drag( handle, -50, 50 );
|
||||
assert.equal( target.width(), 60, "compare minWidth" );
|
||||
assert.equal( target.height(), 60, "compare minHeight" );
|
||||
|
||||
testHelper.drag( handle, 70, -70 );
|
||||
assert.equal( target.width(), 100, "compare maxWidth" );
|
||||
assert.equal( target.height(), 100, "compare maxHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } );
|
||||
|
||||
testHelper.drag( handle, 70, 70 );
|
||||
assert.equal( target.width(), 60, "compare minWidth" );
|
||||
assert.equal( target.height(), 60, "compare minHeight" );
|
||||
|
||||
testHelper.drag( handle, -70, -70 );
|
||||
assert.equal( target.width(), 100, "compare maxWidth" );
|
||||
assert.equal( target.height(), 100, "compare maxHeight" );
|
||||
} );
|
||||
|
||||
QUnit.test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var handle = "#resizer1",
|
||||
target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" ) }, containment: "parent" } );
|
||||
|
||||
testHelper.drag( handle, 0, 70 );
|
||||
assert.equal( target.height(), 170, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 0, -70 );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var handle = "#resizer1",
|
||||
target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" } );
|
||||
|
||||
testHelper.drag( handle, 0, 70 );
|
||||
assert.equal( target.height(), 170, "compare height" );
|
||||
|
||||
testHelper.drag( handle, 0, -70 );
|
||||
assert.equal( target.height(), 100, "compare height" );
|
||||
} );
|
||||
|
||||
QUnit.test( "zIndex, applied to all handles", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
|
||||
var target = $( "<div></div>" ).resizable( { handles: "all", zIndex: 100 } );
|
||||
target.children( ".ui-resizable-handle" ).each( function( index, handle ) {
|
||||
assert.equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "setOption handles", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var target = $( "<div></div>" ).resizable();
|
||||
|
||||
function checkHandles( expectedHandles ) {
|
||||
expectedHandles = $.map( expectedHandles, function( value ) {
|
||||
return ".ui-resizable-" + value;
|
||||
} );
|
||||
|
||||
var handles = target.find( ".ui-resizable-handle" );
|
||||
|
||||
assert.equal( handles.length, expectedHandles.length, "Correct number of handles found" );
|
||||
$.each( expectedHandles, function( index, handleClass ) {
|
||||
assert.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" ] );
|
||||
} );
|
||||
|
||||
QUnit.test( "alsoResize + containment", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var other = $( "<div>" )
|
||||
.css( {
|
||||
width: 50,
|
||||
height: 50
|
||||
} )
|
||||
.appendTo( "body" ),
|
||||
element = $( "#resizable1" ).resizable( {
|
||||
alsoResize: other,
|
||||
containment: "#container"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
||||
assert.equal( element.width(), 300, "resizable constrained width at containment edge" );
|
||||
assert.equal( element.height(), 200, "resizable constrained height at containment edge" );
|
||||
assert.equal( other.width(), 250, "alsoResize constrained width at containment edge" );
|
||||
assert.equal( other.height(), 150, "alsoResize constrained height at containment edge" );
|
||||
} );
|
||||
|
||||
QUnit.test( "alsoResize + multiple selection", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
var other1 = $( "<div>" )
|
||||
.addClass( "other" )
|
||||
.css( {
|
||||
width: 50,
|
||||
height: 50
|
||||
} )
|
||||
.appendTo( "body" ),
|
||||
other2 = $( "<div>" )
|
||||
.addClass( "other" )
|
||||
.css( {
|
||||
width: 50,
|
||||
height: 50
|
||||
} )
|
||||
.appendTo( "body" ),
|
||||
element = $( "#resizable1" ).resizable( {
|
||||
alsoResize: other1.add( other2 ),
|
||||
containment: "#container"
|
||||
} );
|
||||
|
||||
testHelper.drag( ".ui-resizable-se", 400, 400 );
|
||||
assert.equal( element.width(), 300, "resizable constrained width at containment edge" );
|
||||
assert.equal( element.height(), 200, "resizable constrained height at containment edge" );
|
||||
assert.equal( other1.width(), 250, "alsoResize o1 constrained width at containment edge" );
|
||||
assert.equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" );
|
||||
assert.equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" );
|
||||
assert.equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" );
|
||||
} );
|
||||
|
||||
} );
|
61
jquery-ui/tests/unit/resizable/resizable.html
Normal file
61
jquery-ui/tests/unit/resizable/resizable.html
Normal file
|
@ -0,0 +1,61 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Resizable Test Suite</title>
|
||||
|
||||
<script src="../../../external/requirejs/require.js"></script>
|
||||
<script src="../../lib/css.js" data-modules="core resizable"></script>
|
||||
<script src="../../lib/bootstrap.js" data-widget="resizable"></script>
|
||||
<style>
|
||||
#container {
|
||||
width: 300px;
|
||||
height: 200px;
|
||||
}
|
||||
#resizable1 {
|
||||
background: green;
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
#resizable2 {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
#container2 {
|
||||
position: relative;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
margin: 30px 0 0 30px;
|
||||
}
|
||||
#parent {
|
||||
position: relative;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
#child {
|
||||
position: relative;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
<div id="container">
|
||||
<div id="resizable1">I'm a resizable.</div>
|
||||
<div id="resizer1" class="ui-resizable-handle ui-resizable-s"></div>
|
||||
</div>
|
||||
|
||||
<div id="container2">
|
||||
<div id="parent">
|
||||
<div id="child">I'm a resizable.</div>
|
||||
</div>
|
||||
</div>
|
||||
<img src="images/test.jpg" id="resizable2" alt="solid gray">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue