Mooeypoo has uploaded a new change for review.

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


Change subject: [WIP] Link surface fix for RTL
......................................................................

[WIP] Link surface fix for RTL

This is NOT ready for merge, I fixed most of the problem and the link
surface appears in RTL, however, I got stuck with the position for the
TextInputMenuWidget, and I need a second (third/fourth/tenth) pair of
eyes. Help is appreciated, and thanks in advance!

Bug: 49416
Change-Id: I312610ca630a8f75f1a0778e97f227f35a003b41
---
M modules/ve/ui/styles/ve.ui.Surface.css
M modules/ve/ui/ve.ui.Context.js
M modules/ve/ui/ve.ui.Surface.js
M modules/ve/ui/widgets/ve.ui.TextInputMenuWidget.js
4 files changed, 40 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/81/69281/1

diff --git a/modules/ve/ui/styles/ve.ui.Surface.css 
b/modules/ve/ui/styles/ve.ui.Surface.css
index 5e45bc0..6a7fcbf 100644
--- a/modules/ve/ui/styles/ve.ui.Surface.css
+++ b/modules/ve/ui/styles/ve.ui.Surface.css
@@ -23,3 +23,14 @@
        left: 0;
        z-index: 1000;
 }
+
+       /* @noflip */
+.ve-ui-surface-overlay-rtl {
+       font-family: sans-serif;
+       line-height: 1.5em;
+       font-size: 1em;
+       position: absolute;
+       top: 0;
+       right: 0;
+       z-index: 1000;
+}
\ No newline at end of file
diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js
index 99ceb77..325a3f8 100644
--- a/modules/ve/ui/ve.ui.Context.js
+++ b/modules/ve/ui/ve.ui.Context.js
@@ -276,7 +276,14 @@
                        $container = inspector ? this.inspectors.$ : this.$menu;
                        this.popup.align = 'center';
                }
-               this.$.css( { 'left': position.x, 'top': position.y } );
+
+               if ( $('html').css( 'direction' ) === 'rtl' ) {
+                       position.x = (window.innerWidth - position.x);
+                       this.$.css( { 'right': position.x, 'top': position.y } 
);
+               } else {
+                       this.$.css( { 'left': position.x, 'top': position.y } );
+               }
+
                this.popup.display(
                        position.x,
                        position.y,
diff --git a/modules/ve/ui/ve.ui.Surface.js b/modules/ve/ui/ve.ui.Surface.js
index d21adfd..494099b 100644
--- a/modules/ve/ui/ve.ui.Surface.js
+++ b/modules/ve/ui/ve.ui.Surface.js
@@ -33,9 +33,16 @@
        this.$
                .addClass( 've-ui-surface' )
                .append( this.view.$ );
-       this.$localOverlay
+       if ( $( 'body' ).hasClass( 'rtl' ) ) {
+               // If the language direction is RTL, switch left/right 
directions:
+               this.$localOverlay
+                       .addClass( 've-ui-surface-overlay-rtl 
ve-ui-surface-overlay-local' )
+                       .append( this.context.$ );
+       } else {
+               this.$localOverlay
                .addClass( 've-ui-surface-overlay ve-ui-surface-overlay-local' )
                .append( this.context.$ );
+       }
        this.$globalOverlay
                .addClass( 've-ui-surface-overlay ve-ui-surface-overlay-global' 
)
                .append( this.dialogs.$ );
diff --git a/modules/ve/ui/widgets/ve.ui.TextInputMenuWidget.js 
b/modules/ve/ui/widgets/ve.ui.TextInputMenuWidget.js
index 8639d1f..a16c517 100644
--- a/modules/ve/ui/widgets/ve.ui.TextInputMenuWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.TextInputMenuWidget.js
@@ -96,6 +96,19 @@
                dimensions.top += frameOffset.top;
        }
 
+       if ( $('html').css( 'direction' ) === 'rtl' ) {
+               frameOffset = this.input.$$.frame.$.offset();
+               // The dimension should change from 'left' to 'right' to 
accommodate the changes
+               // in the link surface definition. *However* the current 
position of this container
+               // is all screwed up.
+
+               // The math here is driving me crazy. I've tried multiple 
calculations over the left/right
+               // and widths so I can have the right position, but I keep 
getting it wrong.
+               //Is there a way to get the 'right' property of the link of the 
ve.ui.Surface 
+               //that is defined for the link popup?
+               dimensions.right = window.innerWidth - frameOffset.left;
+       }
+
        this.$.css( dimensions );
        return this;
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I312610ca630a8f75f1a0778e97f227f35a003b41
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

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

Reply via email to