@@ -155,7 +155,7 @@ test( "aspectRatio: Resizing can move objects", function() {
155
155
} ) ;
156
156
157
157
test ( "containment" , function ( ) {
158
- expect ( 8 ) ;
158
+ expect ( 4 ) ;
159
159
160
160
var element = $ ( "#resizable1" ) . resizable ( {
161
161
containment : "#container"
@@ -168,32 +168,70 @@ test( "containment", function() {
168
168
TestHelpers . resizable . drag ( ".ui-resizable-se" , 400 , 400 ) ;
169
169
equal ( element . width ( ) , 300 , "constrained width at containment edge" ) ;
170
170
equal ( element . height ( ) , 200 , "constrained height at containment edge" ) ;
171
+ } ) ;
172
+
173
+ test ( "containment - not immediate parent" , function ( ) {
174
+ expect ( 4 ) ;
171
175
172
176
// http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
173
177
// when containment element is not the immediate parent
174
- element = $ ( "#child" ) . resizable ( {
178
+ var element = $ ( "#child" ) . resizable ( {
175
179
containment : "#container2" ,
176
180
handles : "all"
177
181
} ) ;
178
182
179
183
TestHelpers . resizable . drag ( ".ui-resizable-e" , 300 , 0 ) ;
180
- equal ( element . width ( ) , 400 , "element able to resize itself to max allowable width within container" ) ;
184
+ equal ( element . width ( ) , 400 , "Relative, contained within container width " ) ;
181
185
182
186
TestHelpers . resizable . drag ( ".ui-resizable-s" , 0 , 300 ) ;
183
- equal ( element . height ( ) , 400 , "element able to resize itself to max allowable height within container" ) ;
187
+ equal ( element . height ( ) , 400 , "Relative, contained within container height" ) ;
188
+
189
+ $ ( "#child" ) . css ( { left : 50 , top : 50 } ) ;
190
+ $ ( "#parent" ) . css ( { left : 50 , top : 50 } ) ;
191
+ $ ( "#container2" ) . css ( { left : 50 , top : 50 } ) ;
184
192
185
- // http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong
186
- // when containment element is "position: relative"
187
193
element = $ ( "#child" ) . resizable ( {
194
+ containment : "#container2" ,
195
+ handles : "all"
196
+ } ) ;
197
+
198
+ TestHelpers . resizable . drag ( ".ui-resizable-e" , 400 , 0 ) ;
199
+ equal ( element . width ( ) , 300 , "Relative with Left, contained within container width" ) ;
200
+
201
+ TestHelpers . resizable . drag ( ".ui-resizable-s" , 0 , 400 ) ;
202
+ equal ( element . height ( ) , 300 , "Relative with Top, contained within container height" ) ;
203
+ } ) ;
204
+
205
+ test ( "containment - immediate parent" , function ( ) {
206
+ expect ( 4 ) ;
207
+
208
+ // http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative"
209
+ // when containment element is immediate parent
210
+ var element = $ ( "#child" ) . resizable ( {
188
211
containment : "parent" ,
189
212
handles : "all"
190
213
} ) ;
191
214
192
- TestHelpers . resizable . drag ( ".ui-resizable-e" , 300 , 0 ) ;
193
- equal ( element . width ( ) , 300 , "element able to resize itself to max allowable width within container" ) ;
215
+ TestHelpers . resizable . drag ( ".ui-resizable-e" , 400 , 0 ) ;
216
+ equal ( element . width ( ) , 300 , "Relative, contained within container width " ) ;
194
217
195
- TestHelpers . resizable . drag ( ".ui-resizable-s" , 0 , 300 ) ;
196
- equal ( element . height ( ) , 300 , "element able to resize itself to max allowable height within container" ) ;
218
+ TestHelpers . resizable . drag ( ".ui-resizable-s" , 0 , 400 ) ;
219
+ equal ( element . height ( ) , 300 , "Relative, contained within container height" ) ;
220
+
221
+ $ ( "#child" ) . css ( { left : 50 , top : 50 } ) ;
222
+ $ ( "#parent" ) . css ( { left : 50 , top : 50 } ) ;
223
+ $ ( "#container2" ) . css ( { left : 50 , top : 50 } ) ;
224
+
225
+ element = $ ( "#child" ) . resizable ( {
226
+ containment : "parent" ,
227
+ handles : "all"
228
+ } ) ;
229
+
230
+ TestHelpers . resizable . drag ( ".ui-resizable-e" , 400 , 0 ) ;
231
+ equal ( element . width ( ) , 250 , "Relative with Left, contained within container width" ) ;
232
+
233
+ TestHelpers . resizable . drag ( ".ui-resizable-s" , 0 , 400 ) ;
234
+ equal ( element . height ( ) , 250 , "Relative with Top, contained within container height" ) ;
197
235
} ) ;
198
236
199
237
test ( "grid" , function ( ) {
0 commit comments