@@ -155,7 +155,7 @@ test( "aspectRatio: Resizing can move objects", function() {
155155} ) ;
156156
157157test ( "containment" , function ( ) {
158- expect ( 8 ) ;
158+ expect ( 4 ) ;
159159
160160 var element = $ ( "#resizable1" ) . resizable ( {
161161 containment : "#container"
@@ -168,32 +168,70 @@ test( "containment", function() {
168168 TestHelpers . resizable . drag ( ".ui-resizable-se" , 400 , 400 ) ;
169169 equal ( element . width ( ) , 300 , "constrained width at containment edge" ) ;
170170 equal ( element . height ( ) , 200 , "constrained height at containment edge" ) ;
171+ } ) ;
172+
173+ test ( "containment - not immediate parent" , function ( ) {
174+ expect ( 4 ) ;
171175
172176 // http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong
173177 // when containment element is not the immediate parent
174- element = $ ( "#child" ) . resizable ( {
178+ var element = $ ( "#child" ) . resizable ( {
175179 containment : "#container2" ,
176180 handles : "all"
177181 } ) ;
178182
179183 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 " ) ;
181185
182186 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 } ) ;
184192
185- // http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong
186- // when containment element is "position: relative"
187193 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 ( {
188211 containment : "parent" ,
189212 handles : "all"
190213 } ) ;
191214
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 " ) ;
194217
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" ) ;
197235} ) ;
198236
199237test ( "grid" , function ( ) {
0 commit comments