jenkins-bot has submitted this change and it was merged.

Change subject: Element: Expand variable names in scrollIntoView
......................................................................


Element: Expand variable names in scrollIntoView

Because humans.

Change-Id: Ic2fc9a678c1e56e36cfb5058cfa7e1ccdfb9407c
---
M src/Element.js
1 file changed, 32 insertions(+), 32 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/Element.js b/src/Element.js
index 659bb56..c8abc33 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -592,62 +592,62 @@
  * @static
  * @param {HTMLElement} el Element to scroll into view
  * @param {Object} [config] Configuration options
- * @param {string} [config.duration] jQuery animation duration value
+ * @param {string} [config.duration='fast'] jQuery animation duration value
  * @param {string} [config.direction] Scroll in only one direction, e.g. 'x' 
or 'y', omit
  *  to scroll in both directions
  * @param {Function} [config.complete] Function to call when scrolling 
completes
  */
 OO.ui.Element.static.scrollIntoView = function ( el, config ) {
-       var rel, anim, callback, sc, $sc, eld, scd, $win;
+       var position, animations, callback, container, $container, 
elementDimensions, containerDimensions, $window;
 
        // Configuration initialization
        config = config || {};
 
-       anim = {};
+       animations = {};
        callback = typeof config.complete === 'function' && config.complete;
-       sc = this.getClosestScrollableContainer( el, config.direction );
-       $sc = $( sc );
-       eld = this.getDimensions( el );
-       scd = this.getDimensions( sc );
-       $win = $( this.getWindow( el ) );
+       container = this.getClosestScrollableContainer( el, config.direction );
+       $container = $( container );
+       elementDimensions = this.getDimensions( el );
+       containerDimensions = this.getDimensions( container );
+       $window = $( this.getWindow( el ) );
 
-       // Compute the distances between the edges of el and the edges of the 
scroll viewport
-       if ( $sc.is( 'html, body' ) ) {
+       // Compute the element's position relative to the container
+       if ( $container.is( 'html, body' ) ) {
                // If the scrollable container is the root, this is easy
-               rel = {
-                       top: eld.rect.top,
-                       bottom: $win.innerHeight() - eld.rect.bottom,
-                       left: eld.rect.left,
-                       right: $win.innerWidth() - eld.rect.right
+               position = {
+                       top: elementDimensions.rect.top,
+                       bottom: $window.innerHeight() - 
elementDimensions.rect.bottom,
+                       left: elementDimensions.rect.left,
+                       right: $window.innerWidth() - 
elementDimensions.rect.right
                };
        } else {
-               // Otherwise, we have to subtract el's coordinates from sc's 
coordinates
-               rel = {
-                       top: eld.rect.top - ( scd.rect.top + scd.borders.top ),
-                       bottom: scd.rect.bottom - scd.borders.bottom - 
scd.scrollbar.bottom - eld.rect.bottom,
-                       left: eld.rect.left - ( scd.rect.left + 
scd.borders.left ),
-                       right: scd.rect.right - scd.borders.right - 
scd.scrollbar.right - eld.rect.right
+               // Otherwise, we have to subtract el's coordinates from 
container's coordinates
+               position = {
+                       top: elementDimensions.rect.top - ( 
containerDimensions.rect.top + containerDimensions.borders.top ),
+                       bottom: containerDimensions.rect.bottom - 
containerDimensions.borders.bottom - containerDimensions.scrollbar.bottom - 
elementDimensions.rect.bottom,
+                       left: elementDimensions.rect.left - ( 
containerDimensions.rect.left + containerDimensions.borders.left ),
+                       right: containerDimensions.rect.right - 
containerDimensions.borders.right - containerDimensions.scrollbar.right - 
elementDimensions.rect.right
                };
        }
 
        if ( !config.direction || config.direction === 'y' ) {
-               if ( rel.top < 0 ) {
-                       anim.scrollTop = scd.scroll.top + rel.top;
-               } else if ( rel.top > 0 && rel.bottom < 0 ) {
-                       anim.scrollTop = scd.scroll.top + Math.min( rel.top, 
-rel.bottom );
+               if ( position.top < 0 ) {
+                       animations.scrollTop = containerDimensions.scroll.top + 
position.top;
+               } else if ( position.top > 0 && position.bottom < 0 ) {
+                       animations.scrollTop = containerDimensions.scroll.top + 
Math.min( position.top, -position.bottom );
                }
        }
        if ( !config.direction || config.direction === 'x' ) {
-               if ( rel.left < 0 ) {
-                       anim.scrollLeft = scd.scroll.left + rel.left;
-               } else if ( rel.left > 0 && rel.right < 0 ) {
-                       anim.scrollLeft = scd.scroll.left + Math.min( rel.left, 
-rel.right );
+               if ( position.left < 0 ) {
+                       animations.scrollLeft = containerDimensions.scroll.left 
+ position.left;
+               } else if ( position.left > 0 && position.right < 0 ) {
+                       animations.scrollLeft = containerDimensions.scroll.left 
+ Math.min( position.left, -position.right );
                }
        }
-       if ( !$.isEmptyObject( anim ) ) {
-               $sc.stop( true ).animate( anim, config.duration === undefined ? 
'fast' : config.duration );
+       if ( !$.isEmptyObject( animations ) ) {
+               $container.stop( true ).animate( animations, config.duration 
=== undefined ? 'fast' : config.duration );
                if ( callback ) {
-                       $sc.queue( function ( next ) {
+                       $container.queue( function ( next ) {
                                callback();
                                next();
                        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/270261
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2fc9a678c1e56e36cfb5058cfa7e1ccdfb9407c
Gerrit-PatchSet: 3
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to