Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231731

Change subject: Stylist changes to make JS more readable
......................................................................

Stylist changes to make JS more readable

Feel free to apply these to your own patch!

Change-Id: I4f872500f439425d4cbf7552220c8bf292aaae23
---
M 
resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js
1 file changed, 18 insertions(+), 18 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner 
refs/changes/31/231731/1

diff --git 
a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js
 
b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js
index 61a247c..3b76f79 100644
--- 
a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js
+++ 
b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js
@@ -3,10 +3,13 @@
         * Javascript to fine tune position of banner according to position 
coordinates.
         */
        // extract position parameters
-       var centerX = $( '.wpb-banner-image' ).data( 'pos-x' ),
-               centerY = $( '.wpb-banner-image' ).data( 'pos-y' ),
-               $wpbTopbanner = $( '.wpb-topbanner' ),
+       var maxOffsetTop, offsetTop, maxOffsetLeft, offsetLeft,
+               minOffsetTop = 0,
+               minOffsetLeft = 0,
+               $wpbBannerImageContainer = $( '.wpb-topbanner' ),
                $wpbBannerImage = $( '.wpb-banner-image' ),
+               centerX = $wpbBannerImage.data( 'pos-x' ),
+               centerY = $wpbBannerImage.data( 'pos-y' ),
                totalOffsetX = 0,
                totalOffsetY = 0;
        // reset translations applied by css
@@ -16,16 +19,15 @@
                WebkitTransform: 'translate(0)',
                msTransform: 'translate(0)'
        } );
-       if ( $wpbBannerImage.height() > $wpbTopbanner.height() ) {
+       if ( $wpbBannerImage.height() > $wpbBannerImageContainer.height() ) {
                // first reset margin
                $wpbBannerImage.css( 'margin-top', 0 );
                // do not shift below to leave blank space
-               var minOffsetTop = 0;
                // this is the max shift up that can be achieved without 
leaving blank space below
-               var maxOffsetTop = $wpbBannerImage.height() -
-                       $wpbTopbanner.height();
+               maxOffsetTop = $wpbBannerImage.height() -
+                       $wpbBannerImageContainer.height();
                // offset beyond center 0
-               var offsetTop = centerY * $wpbBannerImage.height() / 2;
+               offsetTop = centerY * $wpbBannerImage.height() / 2;
                // offset for default center is maxOffsetTop/2
                // total offset = offset for center + manual offset
                totalOffsetY = maxOffsetTop / 2 + offsetTop;
@@ -36,16 +38,12 @@
                        totalOffsetY = minOffsetTop;
                }
        }
-       if ( $wpbBannerImage.width() > $wpbTopbanner.width() ) {
-               // first reset margin
-               $wpbBannerImage.css( 'margin-left', 0 );
-               // do not shift left to leave blank space
-               var minOffsetLeft = 0;
+       if ( $wpbBannerImage.width() > $wpbBannerImageContainer.width() ) {
                // this is the max shift that can be achieved without leaving 
blank space
-               var maxOffsetLeft = $wpbBannerImage.width() -
-                       $wpbTopbanner.width();
+               maxOffsetLeft = $wpbBannerImage.width() -
+                       $wpbBannerImageContainer.width();
                // offset beyond center 0
-               var offsetLeft = centerX * $wpbBannerImage.width() / 2;
+               offsetLeft = centerX * $wpbBannerImage.width() / 2;
                // offset for default center is maxOffsetLeft/2
                // total offset = offset for center + manual offset
                totalOffsetX = maxOffsetLeft / 2 + offsetLeft;
@@ -58,6 +56,8 @@
        }
 
        // shift the banner horizontally and vertically by the offsets 
calculated above
-       $wpbBannerImage.css( 'margin-top', -totalOffsetY );
-       $wpbBannerImage.css( 'margin-left', -totalOffsetX );
+       $wpbBannerImage.css( {
+               'margin-top': -totalOffsetY,
+               'margin-left': -totalOffsetX
+       } );
 } ( mediaWiki, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f872500f439425d4cbf7552220c8bf292aaae23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataPageBanner
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to