Skip to content

Commit daee00b

Browse files
committed
Fix comment and variable styles.
1 parent 80b2c3a commit daee00b

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

tests/unit/resizable/core.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ QUnit.test( "Resizable with scrollbars and box-sizing: border-box", function( as
249249

250250
$( "<style> * { box-sizing: border-box; } </style>" ).appendTo( "#qunit-fixture" );
251251

252-
//Both scrollbars
252+
// Both scrollbars
253253
var elementContent = $( "<div>" )
254254
.css( {
255255
width: "200px",
@@ -260,14 +260,14 @@ QUnit.test( "Resizable with scrollbars and box-sizing: border-box", function( as
260260
margin: "20px"
261261
} )
262262
.appendTo( "#resizable1" ),
263-
element = $( "#resizable1" ).css( "overflow", "auto" ).resizable(),
264-
handle = ".ui-resizable-se";
263+
element = $( "#resizable1" ).css( "overflow", "auto" ).resizable(),
264+
handle = ".ui-resizable-se";
265265

266266
testHelper.drag( handle, 10, 10 );
267267
assert.equal( element.width(), 110, "element width (both scrollbars)" );
268268
assert.equal( element.height(), 110, "element height (both scrollbars)" );
269269

270-
//Single (vertical) scrollbar.
270+
// Single (vertical) scrollbar.
271271
elementContent.css( "width", "50px" );
272272
testHelper.drag( handle, 10, 10 );
273273
assert.equal( element.width(), 120, "element width (only vertical scrollbar)" );
@@ -279,8 +279,9 @@ QUnit.test( "Resizable with scrollbars and box-sizing: content-box", function( a
279279

280280
$( "<style> * { box-sizing: content-box; } </style>" ).appendTo( "#qunit-fixture" );
281281

282-
//Both scrollbars
283-
var elementContent = $( "<div>" )
282+
// Both scrollbars
283+
var widthBefore, heightBefore,
284+
elementContent = $( "<div>" )
284285
.css( {
285286
width: "200px",
286287
height: "200px",
@@ -290,18 +291,18 @@ QUnit.test( "Resizable with scrollbars and box-sizing: content-box", function( a
290291
margin: "20px"
291292
} )
292293
.appendTo( "#resizable1" ),
293-
element = $( "#resizable1" ).css( "overflow", "auto" ).resizable(),
294-
handle = ".ui-resizable-se";
294+
element = $( "#resizable1" ).css( "overflow", "auto" ).resizable(),
295+
handle = ".ui-resizable-se";
295296

296297
// In some browsers scrollbar may change element size (when "box-sizing: content-box")
297-
var widthBefore = element.innerWidth();
298-
var heightBefore = element.innerHeight();
298+
widthBefore = element.innerWidth();
299+
heightBefore = element.innerHeight();
299300

300301
testHelper.drag( handle, 10, 10 );
301302
assert.equal( parseFloat( element.innerWidth() ), widthBefore + 10, "element width (both scrollbars)" );
302303
assert.equal( parseFloat( element.innerHeight() ), heightBefore + 10, "element height (both scrollbars)" );
303304

304-
//Single (vertical) scrollbar.
305+
// Single (vertical) scrollbar.
305306
elementContent.css( "width", "50px" );
306307

307308
testHelper.drag( handle, 10, 10 );
@@ -314,7 +315,7 @@ QUnit.test( "Resizable with scrollbars, a transform and box-sizing: border-box",
314315

315316
$( "<style> * { box-sizing: border-box; } </style>" ).appendTo( "#qunit-fixture" );
316317

317-
//Both scrollbars
318+
// Both scrollbars
318319
var elementContent = $( "<div>" )
319320
.css( {
320321
width: "200px",
@@ -325,14 +326,14 @@ QUnit.test( "Resizable with scrollbars, a transform and box-sizing: border-box",
325326
margin: "20px"
326327
} )
327328
.appendTo( "#resizable1" ),
328-
element = $( "#resizable1" ).css( { overflow: "auto", transform: "scale(1.5)" } ).resizable(),
329-
handle = ".ui-resizable-se";
329+
element = $( "#resizable1" ).css( { overflow: "auto", transform: "scale(1.5)" } ).resizable(),
330+
handle = ".ui-resizable-se";
330331

331332
testHelper.drag( handle, 10, 10 );
332333
assert.equal( element.width(), 110, "element width (both scrollbars)" );
333334
assert.equal( element.height(), 110, "element height (both scrollbars)" );
334335

335-
//Single (vertical) scrollbar.
336+
// Single (vertical) scrollbar.
336337
elementContent.css( "width", "50px" );
337338
testHelper.drag( handle, 10, 10 );
338339
assert.equal( element.width(), 120, "element width (only vertical scrollbar)" );
@@ -344,29 +345,30 @@ QUnit.test( "Resizable with scrollbars, a transform and box-sizing: content-box"
344345

345346
$( "<style> * { box-sizing: content-box; } </style>" ).appendTo( "#qunit-fixture" );
346347

347-
//Both scrollbars
348-
var elementContent = $( "<div>" )
349-
.css( {
350-
width: "200px",
351-
height: "200px",
352-
padding: "10px",
353-
border: "5px",
354-
borderStyle: "solid",
355-
margin: "20px"
356-
} )
357-
.appendTo( "#resizable1" ),
358-
element = $( "#resizable1" ).css( { overflow: "auto", transform: "scale(1.5)" } ).resizable(),
359-
handle = ".ui-resizable-se";
348+
// Both scrollbars
349+
var widthBefore, heightBefore,
350+
elementContent = $( "<div>" )
351+
.css( {
352+
width: "200px",
353+
height: "200px",
354+
padding: "10px",
355+
border: "5px",
356+
borderStyle: "solid",
357+
margin: "20px"
358+
} )
359+
.appendTo( "#resizable1" ),
360+
element = $( "#resizable1" ).css( { overflow: "auto", transform: "scale(1.5)" } ).resizable(),
361+
handle = ".ui-resizable-se";
360362

361363
// In some browsers scrollbar may change element size (when "box-sizing: content-box")
362-
var widthBefore = element.innerWidth();
363-
var heightBefore = element.innerHeight();
364+
widthBefore = element.innerWidth();
365+
heightBefore = element.innerHeight();
364366

365367
testHelper.drag( handle, 10, 10 );
366368
assert.equal( parseFloat( element.innerWidth() ), widthBefore + 10, "element width (both scrollbars)" );
367369
assert.equal( parseFloat( element.innerHeight() ), heightBefore + 10, "element height (both scrollbars)" );
368370

369-
//Single (vertical) scrollbar.
371+
// Single (vertical) scrollbar.
370372
elementContent.css( "width", "50px" );
371373

372374
testHelper.drag( handle, 10, 10 );

ui/widgets/resizable.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,18 @@ $.widget( "ui.resizable", $.ui.mouse, {
8080

8181
_hasScroll: function( el, a ) {
8282

83-
var overflow = $( el ).css( "overflow" );
83+
var scroll,
84+
has = false,
85+
overflow = $( el ).css( "overflow" );
86+
8487
if ( overflow === "hidden" ) {
8588
return false;
8689
}
8790
if ( overflow === "scroll" ) {
8891
return true;
8992
}
9093

91-
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
92-
has = false;
94+
scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop";
9395

9496
if ( el[ scroll ] > 0 ) {
9597
return true;
@@ -366,7 +368,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
366368

367369
_mouseStart: function( event ) {
368370

369-
var curleft, curtop, cursor,
371+
var curleft, curtop, cursor, calculatedSize,
370372
o = this.options,
371373
el = this.element;
372374

@@ -385,7 +387,6 @@ $.widget( "ui.resizable", $.ui.mouse, {
385387
this.offset = this.helper.offset();
386388
this.position = { left: curleft, top: curtop };
387389

388-
var calculatedSize = undefined;
389390
if ( !this._helper ) {
390391
calculatedSize = this._calculateAdjustedElementDimensions( el );
391392
}
@@ -700,7 +701,8 @@ $.widget( "ui.resizable", $.ui.mouse, {
700701
},
701702

702703
_calculateAdjustedElementDimensions: function( element ) {
703-
var ce = element.get( 0 );
704+
var elWidth, elHeight, paddingBorder,
705+
ce = element.get( 0 );
704706

705707
if ( element.css( "box-sizing" ) !== "content-box" ||
706708
( !this._hasScroll( ce ) && !this._hasScroll( ce, "left" ) ) ) {
@@ -711,10 +713,10 @@ $.widget( "ui.resizable", $.ui.mouse, {
711713
}
712714

713715
// Check if CSS inline styles are set and use those (usually from previous resizes)
714-
var elWidth = parseFloat( ce.style.width );
715-
var elHeight = parseFloat( ce.style.height );
716+
elWidth = parseFloat( ce.style.width );
717+
elHeight = parseFloat( ce.style.height );
716718

717-
var paddingBorder = this._getPaddingPlusBorderDimensions( element );
719+
paddingBorder = this._getPaddingPlusBorderDimensions( element );
718720
elWidth = isNaN( elWidth ) ?
719721
this._getElementTheoreticalSize( element, paddingBorder, "width" ) :
720722
elWidth;
@@ -737,7 +739,8 @@ $.widget( "ui.resizable", $.ui.mouse, {
737739
0.5
738740

739741
// If offsetWidth/offsetHeight is unknown, then we can't determine theoretical size.
740-
// Use an explicit zero to avoid NaN (gh-3964)
742+
// Use an explicit zero to avoid NaN.
743+
// See https://github.com/jquery/jquery/issues/3964
741744
) ) || 0;
742745

743746
return size;
@@ -1097,9 +1100,8 @@ $.ui.plugin.add( "resizable", "alsoResize", {
10971100
o = that.options;
10981101

10991102
$( o.alsoResize ).each( function() {
1100-
var el = $( this );
1101-
1102-
var elSize = that._calculateAdjustedElementDimensions( el );
1103+
var el = $( this ),
1104+
elSize = that._calculateAdjustedElementDimensions( el );
11031105

11041106
el.data( "ui-resizable-alsoresize", {
11051107
width: elSize.width, height: elSize.height,

0 commit comments

Comments
 (0)