@@ -159,7 +159,7 @@ $.fn.position = function( options ) {
159159 return _position . apply ( this , arguments ) ;
160160 }
161161
162- // make a copy, we don't want to modify arguments
162+ // Make a copy, we don't want to modify arguments
163163 options = $ . extend ( { } , options ) ;
164164
165165 var atOffset , targetWidth , targetHeight , targetOffset , basePosition , dimensions ,
@@ -171,16 +171,18 @@ $.fn.position = function( options ) {
171171
172172 dimensions = getDimensions ( target ) ;
173173 if ( target [ 0 ] . preventDefault ) {
174- // force left top to allow flipping
174+
175+ // Force left top to allow flipping
175176 options . at = "left top" ;
176177 }
177178 targetWidth = dimensions . width ;
178179 targetHeight = dimensions . height ;
179180 targetOffset = dimensions . offset ;
180- // clone to reuse original targetOffset later
181+
182+ // Clone to reuse original targetOffset later
181183 basePosition = $ . extend ( { } , targetOffset ) ;
182184
183- // force my and at to have valid horizontal and vertical positions
185+ // Force my and at to have valid horizontal and vertical positions
184186 // if a value is missing or invalid, it will be converted to center
185187 $ . each ( [ "my" , "at" ] , function ( ) {
186188 var pos = ( options [ this ] || "" ) . split ( " " ) ,
@@ -197,22 +199,22 @@ $.fn.position = function( options ) {
197199 pos [ 0 ] = rhorizontal . test ( pos [ 0 ] ) ? pos [ 0 ] : "center" ;
198200 pos [ 1 ] = rvertical . test ( pos [ 1 ] ) ? pos [ 1 ] : "center" ;
199201
200- // calculate offsets
202+ // Calculate offsets
201203 horizontalOffset = roffset . exec ( pos [ 0 ] ) ;
202204 verticalOffset = roffset . exec ( pos [ 1 ] ) ;
203205 offsets [ this ] = [
204206 horizontalOffset ? horizontalOffset [ 0 ] : 0 ,
205207 verticalOffset ? verticalOffset [ 0 ] : 0
206208 ] ;
207209
208- // reduce to just the positions without the offsets
210+ // Reduce to just the positions without the offsets
209211 options [ this ] = [
210212 rposition . exec ( pos [ 0 ] ) [ 0 ] ,
211213 rposition . exec ( pos [ 1 ] ) [ 0 ]
212214 ] ;
213215 } ) ;
214216
215- // normalize collision option
217+ // Normalize collision option
216218 if ( collision . length === 1 ) {
217219 collision [ 1 ] = collision [ 0 ] ;
218220 }
@@ -260,7 +262,7 @@ $.fn.position = function( options ) {
260262 position . left += myOffset [ 0 ] ;
261263 position . top += myOffset [ 1 ] ;
262264
263- // if the browser doesn't support fractions, then round for consistent results
265+ // If the browser doesn't support fractions, then round for consistent results
264266 if ( ! supportsOffsetFractions ( ) ) {
265267 position . left = round ( position . left ) ;
266268 position . top = round ( position . top ) ;
@@ -291,7 +293,8 @@ $.fn.position = function( options ) {
291293 } ) ;
292294
293295 if ( options . using ) {
294- // adds feedback as second argument to using callback, if present
296+
297+ // Adds feedback as second argument to using callback, if present
295298 using = function ( props ) {
296299 var left = targetOffset . left - position . left ,
297300 right = left + targetWidth - elemWidth ,
@@ -345,30 +348,36 @@ $.ui.position = {
345348 overRight = collisionPosLeft + data . collisionWidth - outerWidth - withinOffset ,
346349 newOverRight ;
347350
348- // element is wider than within
351+ // Element is wider than within
349352 if ( data . collisionWidth > outerWidth ) {
350- // element is initially over the left side of within
353+
354+ // Element is initially over the left side of within
351355 if ( overLeft > 0 && overRight <= 0 ) {
352356 newOverRight = position . left + overLeft + data . collisionWidth - outerWidth - withinOffset ;
353357 position . left += overLeft - newOverRight ;
354- // element is initially over right side of within
358+
359+ // Element is initially over right side of within
355360 } else if ( overRight > 0 && overLeft <= 0 ) {
356361 position . left = withinOffset ;
357- // element is initially over both left and right sides of within
362+
363+ // Element is initially over both left and right sides of within
358364 } else {
359365 if ( overLeft > overRight ) {
360366 position . left = withinOffset + outerWidth - data . collisionWidth ;
361367 } else {
362368 position . left = withinOffset ;
363369 }
364370 }
365- // too far left -> align with left edge
371+
372+ // Too far left -> align with left edge
366373 } else if ( overLeft > 0 ) {
367374 position . left += overLeft ;
368- // too far right -> align with right edge
375+
376+ // Too far right -> align with right edge
369377 } else if ( overRight > 0 ) {
370378 position . left -= overRight ;
371- // adjust based on position and margin
379+
380+ // Adjust based on position and margin
372381 } else {
373382 position . left = max ( position . left - collisionPosLeft , position . left ) ;
374383 }
@@ -382,30 +391,36 @@ $.ui.position = {
382391 overBottom = collisionPosTop + data . collisionHeight - outerHeight - withinOffset ,
383392 newOverBottom ;
384393
385- // element is taller than within
394+ // Element is taller than within
386395 if ( data . collisionHeight > outerHeight ) {
387- // element is initially over the top of within
396+
397+ // Element is initially over the top of within
388398 if ( overTop > 0 && overBottom <= 0 ) {
389399 newOverBottom = position . top + overTop + data . collisionHeight - outerHeight - withinOffset ;
390400 position . top += overTop - newOverBottom ;
391- // element is initially over bottom of within
401+
402+ // Element is initially over bottom of within
392403 } else if ( overBottom > 0 && overTop <= 0 ) {
393404 position . top = withinOffset ;
394- // element is initially over both top and bottom of within
405+
406+ // Element is initially over both top and bottom of within
395407 } else {
396408 if ( overTop > overBottom ) {
397409 position . top = withinOffset + outerHeight - data . collisionHeight ;
398410 } else {
399411 position . top = withinOffset ;
400412 }
401413 }
402- // too far up -> align with top
414+
415+ // Too far up -> align with top
403416 } else if ( overTop > 0 ) {
404417 position . top += overTop ;
405- // too far down -> align with bottom edge
418+
419+ // Too far down -> align with bottom edge
406420 } else if ( overBottom > 0 ) {
407421 position . top -= overBottom ;
408- // adjust based on position and margin
422+
423+ // Adjust based on position and margin
409424 } else {
410425 position . top = max ( position . top - collisionPosTop , position . top ) ;
411426 }
0 commit comments