6 module("resizable: options");
8 test( "alsoResize", function() {
11 var other = $( "<div>" )
17 element = $( "#resizable1" ).resizable({
20 handle = ".ui-resizable-e";
22 TestHelpers.resizable.drag( handle, 80 );
23 equal( element.width(), 180, "resizable width" );
24 equal( other.width(), 130, "alsoResize width" );
28 test("aspectRatio: 'preserve' (e)", function() {
31 var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
33 TestHelpers.resizable.drag(handle, 80);
34 equal( target.width(), 130, "compare maxWidth");
35 equal( target.height(), 130, "compare maxHeight");
37 TestHelpers.resizable.drag(handle, -130);
38 equal( target.width(), 70, "compare minWidth");
39 equal( target.height(), 70, "compare minHeight");
42 test("aspectRatio: 'preserve' (w)", function() {
45 var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
47 TestHelpers.resizable.drag(handle, -80);
48 equal( target.width(), 130, "compare maxWidth");
49 equal( target.height(), 130, "compare maxHeight");
51 TestHelpers.resizable.drag(handle, 130);
52 equal( target.width(), 70, "compare minWidth");
53 equal( target.height(), 70, "compare minHeight");
56 test("aspectRatio: 'preserve' (n)", function() {
59 var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
61 TestHelpers.resizable.drag(handle, 0, -80);
62 equal( target.width(), 130, "compare maxWidth");
63 equal( target.height(), 130, "compare maxHeight");
65 TestHelpers.resizable.drag(handle, 0, 80);
66 equal( target.width(), 70, "compare minWidth");
67 equal( target.height(), 70, "compare minHeight");
70 test("aspectRatio: 'preserve' (s)", function() {
73 var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
75 TestHelpers.resizable.drag(handle, 0, 80);
76 equal( target.width(), 130, "compare maxWidth");
77 equal( target.height(), 130, "compare maxHeight");
79 TestHelpers.resizable.drag(handle, 0, -80);
80 equal( target.width(), 70, "compare minWidth");
81 equal( target.height(), 70, "compare minHeight");
84 test("aspectRatio: 'preserve' (se)", function() {
87 var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
89 TestHelpers.resizable.drag(handle, 80, 80);
90 equal( target.width(), 130, "compare maxWidth");
91 equal( target.height(), 130, "compare maxHeight");
93 TestHelpers.resizable.drag(handle, -80, -80);
94 equal( target.width(), 70, "compare minWidth");
95 equal( target.height(), 70, "compare minHeight");
98 test("aspectRatio: 'preserve' (sw)", function() {
101 var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
103 TestHelpers.resizable.drag(handle, -80, 80);
104 equal( target.width(), 130, "compare maxWidth");
105 equal( target.height(), 130, "compare maxHeight");
107 TestHelpers.resizable.drag(handle, 80, -80);
108 equal( target.width(), 70, "compare minWidth");
109 equal( target.height(), 70, "compare minHeight");
112 test("aspectRatio: 'preserve' (ne)", function() {
115 var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
117 TestHelpers.resizable.drag(handle, 80, -80);
118 equal( target.width(), 130, "compare maxWidth");
119 equal( target.height(), 130, "compare maxHeight");
121 TestHelpers.resizable.drag(handle, -80, 80);
122 equal( target.width(), 70, "compare minWidth");
123 equal( target.height(), 70, "compare minHeight");
126 test( "containment", function() {
128 var element = $( "#resizable1" ).resizable({
129 containment: "#container"
132 TestHelpers.resizable.drag( ".ui-resizable-se", 20, 30 );
133 equal( element.width(), 120, "unconstrained width within container" );
134 equal( element.height(), 130, "unconstrained height within container" );
136 TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 );
137 equal( element.width(), 300, "constrained width at containment edge" );
138 equal( element.height(), 200, "constrained height at containment edge" );
141 test("grid", function() {
144 var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [0, 20] });
146 TestHelpers.resizable.drag(handle, 3, 9);
147 equal( target.width(), 103, "compare width");
148 equal( target.height(), 100, "compare height");
150 TestHelpers.resizable.drag(handle, 15, 11);
151 equal( target.width(), 118, "compare width");
152 equal( target.height(), 120, "compare height");
155 test("grid (min/max dimensions)", function() {
158 var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 });
160 TestHelpers.resizable.drag(handle, 50, 50);
161 equal( target.width(), 120, "grid should respect maxWidth");
162 equal( target.height(), 120, "grid should respect maxHeight");
164 TestHelpers.resizable.drag(handle, -100, -100);
165 equal( target.width(), 80, "grid should respect minWidth");
166 equal( target.height(), 80, "grid should respect minHeight");
169 test("grid (wrapped)", function() {
172 var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [0, 20] });
174 TestHelpers.resizable.drag(handle, 3, 9);
175 equal( target.width(), 103, "compare width");
176 equal( target.height(), 100, "compare height");
178 TestHelpers.resizable.drag(handle, 15, 11);
179 equal( target.width(), 118, "compare width");
180 equal( target.height(), 120, "compare height");
183 test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
186 var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
188 TestHelpers.resizable.drag(handle, -50, -50);
189 equal( target.width(), 60, "compare minWidth" );
190 equal( target.height(), 60, "compare minHeight" );
192 TestHelpers.resizable.drag(handle, 70, 70);
193 equal( target.width(), 100, "compare maxWidth" );
194 equal( target.height(), 100, "compare maxHeight" );
197 test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
200 var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
202 TestHelpers.resizable.drag(handle, 50, -50);
203 equal( target.width(), 60, "compare minWidth" );
204 equal( target.height(), 60, "compare minHeight" );
206 TestHelpers.resizable.drag(handle, -70, 70);
207 equal( target.width(), 100, "compare maxWidth" );
208 equal( target.height(), 100, "compare maxHeight" );
211 test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
214 var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
216 TestHelpers.resizable.drag(handle, -50, 50);
217 equal( target.width(), 60, "compare minWidth" );
218 equal( target.height(), 60, "compare minHeight" );
220 TestHelpers.resizable.drag(handle, 70, -70);
221 equal( target.width(), 100, "compare maxWidth" );
222 equal( target.height(), 100, "compare maxHeight" );
225 test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
228 var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
230 TestHelpers.resizable.drag(handle, 70, 70);
231 equal( target.width(), 60, "compare minWidth" );
232 equal( target.height(), 60, "compare minHeight" );
234 TestHelpers.resizable.drag(handle, -70, -70);
235 equal( target.width(), 100, "compare maxWidth" );
236 equal( target.height(), 100, "compare maxHeight" );
239 test("zIndex, applied to all handles", function() {
242 var target = $("<div></div>").resizable({ handles: "all", zIndex: 100 });
243 target.children( ".ui-resizable-handle" ).each( function( index, handle ) {
244 equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" );
248 test( "alsoResize + containment", function() {
250 var other = $( "<div>" )
256 element = $( "#resizable1" ).resizable({
258 containment: "#container"
261 TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 );
262 equal( element.width(), 300, "resizable constrained width at containment edge" );
263 equal( element.height(), 200, "resizable constrained height at containment edge" );
264 equal( other.width(), 250, "alsoResize constrained width at containment edge" );
265 equal( other.height(), 150, "alsoResize constrained height at containment edge" );