Prtksxna has uploaded a new change for review.

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

Change subject: [wip] flip popups on y-axis
......................................................................

[wip] flip popups on y-axis

Change-Id: I893e239889874be83cfbf202095f617ee6091d6f
---
M resources/ext.popups.core.less
M resources/ext.popups.renderer.article.js
2 files changed, 29 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/85/130585/1

diff --git a/resources/ext.popups.core.less b/resources/ext.popups.core.less
index c95f736..c6c8bdb 100644
--- a/resources/ext.popups.core.less
+++ b/resources/ext.popups.core.less
@@ -129,7 +129,7 @@
                }
        }
 
-       &.flipped.mwe-popups-no-image-tri {
+       &.flipped_x.mwe-popups-no-image-tri {
                &:after {
                        /* @noflip */
                        left: initial;
@@ -156,7 +156,7 @@
                        z-index: 91;
                }
 
-               &.flipped {
+               &.flipped_x {
                        &:before {
                                z-index: 90;
                                .mwe-popups-border-triangle(9px, 273px, #bbb);
@@ -181,7 +181,7 @@
                }
        }
 
-       &.flipped.mwe-popups-is-tall {
+       &.flipped_x.mwe-popups-is-tall {
                min-height: 242px;
 
                &:before {
diff --git a/resources/ext.popups.renderer.article.js 
b/resources/ext.popups.renderer.article.js
index 3c34057..fd70b68 100644
--- a/resources/ext.popups.renderer.article.js
+++ b/resources/ext.popups.renderer.article.js
@@ -262,7 +262,9 @@
        article.getOffset = function ( link, event ) {
                var
                        href = link.attr( 'href' ),
-                       flipped = false,
+                       flipped_x = false,
+                       flipped_y = false,
+                       element = mw.popups.render.cache[ href ].popup,
                        settings = mw.popups.render.cache[ href ].settings,
                        offsetTop = ( event.pageY ) ?
                                event.pageY + 20 :
@@ -271,19 +273,27 @@
                                event.pageX :
                                link.offset().left;
 
+               // X Flip
                if ( offsetLeft > ( $( window ).width() / 2 ) ) {
                        offsetLeft += ( !event.pageX ) ? link.width() : 0;
                        offsetLeft -= ( !settings.tall ) ?
                                article.SIZES.portraitPopupWidth :
                                article.SIZES.landscapePopupWidth;
-                       flipped = true;
+                       flipped_x = true;
                }
 
                if ( event.pageX ) {
-                       offsetLeft += ( flipped ) ? 20 : -20;
+                       offsetLeft += ( flipped_x ) ? 20 : -20;
                }
 
-               mw.popups.render.cache[ href ].settings.flipped = flipped;
+               mw.popups.render.cache[ href ].settings.flipped_x = flipped_x;
+
+               // Y Flip
+               if ( offsetTop > ( $( window ).width() / 2 ) ) {
+                       flipped_y = true;
+               }
+
+               mw.popups.render.cache[ href ].settings.flipped_y = flipped_y;
 
                return {
                        top: offsetTop + 'px',
@@ -304,10 +314,10 @@
                        cache = mw.popups.render.cache [ link.attr( 'href' ) ],
                        tall = cache.settings.tall,
                        thumbnail = cache.settings.thumbnail,
-                       flipped = cache.settings.flipped;
+                       flipped_x = cache.settings.flipped_x;
 
-               if ( flipped ) {
-                       classes.push( 'flipped' );
+               if ( flipped_x ) {
+                       classes.push( 'flipped_x' );
                }
 
                if ( !thumbnail || tall ) {
@@ -337,11 +347,18 @@
        article.processPopup = function ( link ) {
                var
                        cache = mw.popups.render.cache [ link.attr( 'href' ) ],
+                       popup = mw.popups.$popup,
                        tall = cache.settings.tall,
                        thumbnail = cache.settings.thumbnail,
-                       flipped = cache.settings.flipped;
+                       flipped_y = cache.settings.flipped_y,
+                       flipped_x = cache.settings.flipped_x;
 
-               if ( flipped && thumbnail ) {
+               if ( flipped_y ) {
+                       var top = popup.offset().top - popup.height();
+                       popup.css( { top: top } );
+               }
+
+               if ( flipped_x && thumbnail ) {
                        if ( !tall ) {
                                mw.popups.$popup
                                        .find( 'image' )[ 0 ]

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I893e239889874be83cfbf202095f617ee6091d6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <psax...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to