From 5bb15c43320409b75d8e73b165b45ce9d76d6fca Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Mon, 22 Jul 2013 16:55:32 -0400 Subject: [PATCH] Quickfix for Transclusion icon in RTL wikis Added GUI-level and Page-level "getDir()" methods to get the direction of the GUI and Page respectively in the ve.ui.Surface and ve.ce.Surface respectively. The correction to the direction-test condition in ve.ui.Context reflects the new method of getting these directions, and fixes the problem with the transclusion icon. The icon position depends on the wiki/page-level directionality, regardless of the GUI-level direction. Bug: 51819 Change-Id: I36cef115017542c461e6d757f1c8bfda92074607 --- modules/ve/ce/ve.ce.Surface.js | 8 ++++++++ modules/ve/ui/ve.ui.Context.js | 11 ++++++++--- modules/ve/ui/ve.ui.Surface.js | 8 ++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 68519f3ea0..fb46695a62 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -1566,3 +1566,11 @@ ve.ce.Surface.prototype.enableRendering = function () { ve.ce.Surface.prototype.disableRendering = function () { this.renderingEnabled = false; }; + +/** + * Surface 'dir' property (Content-Level Direction) + * @returns {string} 'ltr' or 'rtl' + */ +ve.ce.Surface.prototype.getDir = function () { + return this.$.css( 'direction' ); +}; diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js index 7df3676daa..694af141eb 100644 --- a/modules/ve/ui/ve.ui.Context.js +++ b/modules/ve/ui/ve.ui.Context.js @@ -266,8 +266,8 @@ ve.ui.Context.prototype.updateDimensions = function ( transition ) { focusableWidth = focusedNode.$focusable.outerWidth(); $container = this.$menu; position = { 'y': focusableOffset.top }; - // HACK: Proper RTL detection plz! - if ( $( 'body' ).is( '.rtl,.ve-rtl' ) ) { + // RTL check for Page-level (CE) + if ( this.surface.view.getDir() === 'rtl' ) { position.x = focusableOffset.left; this.popup.align = 'left'; } else { @@ -278,7 +278,12 @@ ve.ui.Context.prototype.updateDimensions = function ( transition ) { $container = inspector ? this.inspectors.$ : this.$menu; this.popup.align = 'center'; } - this.$.css( { 'left': position.x, 'top': position.y } ); + // Flip left with right if CE is RTL + if ( this.surface.view.getDir() === 'rtl' ) { + 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 dcbade470b..200dd5ec28 100644 --- a/modules/ve/ui/ve.ui.Surface.js +++ b/modules/ve/ui/ve.ui.Surface.js @@ -250,3 +250,11 @@ ve.ui.Surface.prototype.addTriggers = function ( triggers, command ) { this.commands[trigger] = command.action; } }; + +/** + * Surface 'dir' property (GUI/User-Level Direction) + * @returns {string} 'ltr' or 'rtl' + */ +ve.ui.Surface.prototype.getDir = function () { + return this.$.css( 'direction' ); +};