@@ -246,107 +246,28 @@ QUnit.test( "nested resizable", function( assert ) {
246
246
247
247
QUnit . test ( "Resizable with scrollbars and box-sizing: border-box" , function ( assert ) {
248
248
assert . expect ( 4 ) ;
249
-
250
- $ ( "<style> * { box-sizing: border-box; } </style>" ) . appendTo ( "#qunit-fixture" ) ;
251
-
252
- // Both scrollbars
253
- var elementContent = $ ( "<div>" )
254
- . css ( {
255
- width : "200px" ,
256
- height : "200px" ,
257
- padding : "10px" ,
258
- border : "5px" ,
259
- borderStyle : "solid" ,
260
- margin : "20px"
261
- } )
262
- . appendTo ( "#resizable1" ) ,
263
- element = $ ( "#resizable1" ) . css ( "overflow" , "auto" ) . resizable ( ) ,
264
- handle = ".ui-resizable-se" ;
265
-
266
- testHelper . drag ( handle , 10 , 10 ) ;
267
- assert . equal ( element . width ( ) , 110 , "element width (both scrollbars)" ) ;
268
- assert . equal ( element . height ( ) , 110 , "element height (both scrollbars)" ) ;
269
-
270
- // Single (vertical) scrollbar.
271
- elementContent . css ( "width" , "50px" ) ;
272
- testHelper . drag ( handle , 10 , 10 ) ;
273
- assert . equal ( element . width ( ) , 120 , "element width (only vertical scrollbar)" ) ;
274
- assert . equal ( element . height ( ) , 120 , "element height (only vertical scrollbar)" ) ;
249
+ testResizableWithBoxSizing ( assert , true , false ) ;
275
250
} ) ;
276
251
277
252
QUnit . test ( "Resizable with scrollbars and box-sizing: content-box" , function ( assert ) {
278
253
assert . expect ( 4 ) ;
279
-
280
- $ ( "<style> * { box-sizing: content-box; } </style>" ) . appendTo ( "#qunit-fixture" ) ;
281
-
282
- // Both scrollbars
283
- var widthBefore , heightBefore ,
284
- elementContent = $ ( "<div>" )
285
- . css ( {
286
- width : "200px" ,
287
- height : "200px" ,
288
- padding : "10px" ,
289
- border : "5px" ,
290
- borderStyle : "solid" ,
291
- margin : "20px"
292
- } )
293
- . appendTo ( "#resizable1" ) ,
294
- element = $ ( "#resizable1" ) . css ( "overflow" , "auto" ) . resizable ( ) ,
295
- handle = ".ui-resizable-se" ;
296
-
297
- // In some browsers scrollbar may change element size (when "box-sizing: content-box")
298
- widthBefore = element . innerWidth ( ) ;
299
- heightBefore = element . innerHeight ( ) ;
300
-
301
- testHelper . drag ( handle , 10 , 10 ) ;
302
- assert . equal ( parseFloat ( element . innerWidth ( ) ) , widthBefore + 10 , "element width (both scrollbars)" ) ;
303
- assert . equal ( parseFloat ( element . innerHeight ( ) ) , heightBefore + 10 , "element height (both scrollbars)" ) ;
304
-
305
- // Single (vertical) scrollbar.
306
- elementContent . css ( "width" , "50px" ) ;
307
-
308
- testHelper . drag ( handle , 10 , 10 ) ;
309
- assert . equal ( parseFloat ( element . innerWidth ( ) ) , widthBefore + 20 , "element width (only vertical scrollbar)" ) ;
310
- assert . equal ( parseFloat ( element . innerHeight ( ) ) , heightBefore + 20 , "element height (only vertical scrollbar)" ) ;
254
+ testResizableWithBoxSizing ( assert , false , false ) ;
311
255
} ) ;
312
256
313
257
QUnit . test ( "Resizable with scrollbars, a transform and box-sizing: border-box" , function ( assert ) {
314
258
assert . expect ( 4 ) ;
315
-
316
- $ ( "<style> * { box-sizing: border-box; } </style>" ) . appendTo ( "#qunit-fixture" ) ;
317
-
318
- // Both scrollbars
319
- var elementContent = $ ( "<div>" )
320
- . css ( {
321
- width : "200px" ,
322
- height : "200px" ,
323
- padding : "10px" ,
324
- border : "5px" ,
325
- borderStyle : "solid" ,
326
- margin : "20px"
327
- } )
328
- . appendTo ( "#resizable1" ) ,
329
- element = $ ( "#resizable1" ) . css ( { overflow : "auto" , transform : "scale(1.5)" } ) . resizable ( ) ,
330
- handle = ".ui-resizable-se" ;
331
-
332
- testHelper . drag ( handle , 10 , 10 ) ;
333
- assert . equal ( element . width ( ) , 110 , "element width (both scrollbars)" ) ;
334
- assert . equal ( element . height ( ) , 110 , "element height (both scrollbars)" ) ;
335
-
336
- // Single (vertical) scrollbar.
337
- elementContent . css ( "width" , "50px" ) ;
338
- testHelper . drag ( handle , 10 , 10 ) ;
339
- assert . equal ( element . width ( ) , 120 , "element width (only vertical scrollbar)" ) ;
340
- assert . equal ( element . height ( ) , 120 , "element height (only vertical scrollbar)" ) ;
259
+ testResizableWithBoxSizing ( assert , true , true ) ;
341
260
} ) ;
342
261
343
262
QUnit . test ( "Resizable with scrollbars, a transform and box-sizing: content-box" , function ( assert ) {
344
263
assert . expect ( 4 ) ;
264
+ testResizableWithBoxSizing ( assert , false , true ) ;
265
+ } ) ;
345
266
346
- $ ( "<style> * { box-sizing: content-box; } </style>" ) . appendTo ( "#qunit-fixture" ) ;
347
-
348
- // Both scrollbars
267
+ function testResizableWithBoxSizing ( assert , isBorderBox , applyScaleTransform ) {
349
268
var widthBefore , heightBefore ,
269
+ cssBoxSizing = isBorderBox ? "border-box" : "content-box" ,
270
+ cssTrasform = applyScaleTransform ? "scale(1.5)" : "" ,
350
271
elementContent = $ ( "<div>" )
351
272
. css ( {
352
273
width : "200px" ,
@@ -357,13 +278,16 @@ QUnit.test( "Resizable with scrollbars, a transform and box-sizing: content-box"
357
278
margin : "20px"
358
279
} )
359
280
. appendTo ( "#resizable1" ) ,
360
- element = $ ( "#resizable1" ) . css ( { overflow : "auto" , transform : "scale(1.5)" } ) . resizable ( ) ,
281
+ element = $ ( "#resizable1" ) . css ( { overflow : "auto" , transform : cssTrasform } ) . resizable ( ) ,
361
282
handle = ".ui-resizable-se" ;
362
283
284
+ $ ( "<style> * { box-sizing: " + cssBoxSizing + "; } </style>" ) . appendTo ( "#qunit-fixture" ) ;
285
+
363
286
// In some browsers scrollbar may change element size (when "box-sizing: content-box")
364
287
widthBefore = element . innerWidth ( ) ;
365
288
heightBefore = element . innerHeight ( ) ;
366
289
290
+ // Both scrollbars
367
291
testHelper . drag ( handle , 10 , 10 ) ;
368
292
assert . equal ( parseFloat ( element . innerWidth ( ) ) , widthBefore + 10 , "element width (both scrollbars)" ) ;
369
293
assert . equal ( parseFloat ( element . innerHeight ( ) ) , heightBefore + 10 , "element height (both scrollbars)" ) ;
@@ -374,6 +298,6 @@ QUnit.test( "Resizable with scrollbars, a transform and box-sizing: content-box"
374
298
testHelper . drag ( handle , 10 , 10 ) ;
375
299
assert . equal ( parseFloat ( element . innerWidth ( ) ) , widthBefore + 20 , "element width (only vertical scrollbar)" ) ;
376
300
assert . equal ( parseFloat ( element . innerHeight ( ) ) , heightBefore + 20 , "element height (only vertical scrollbar)" ) ;
377
- } ) ;
301
+ }
378
302
379
303
} ) ;
0 commit comments