[MediaWiki-commits] [Gerrit] RTL fix for VE's link widget - change (mediawiki...VisualEditor)

2013-05-02 Thread Mooeypoo (Code Review)
Mooeypoo has uploaded a new change for review.

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


Change subject: RTL fix for VE's link widget
..

RTL fix for VE's link widget

The purpose is to flip the direction of the input inside
the link widget for RTL wikis, but flip it again to LTR
if the user inserts an external URL. This is my first VE
fix, I tried to follow conventions and avoid touching the
parent objects that are unrelated to URLs.

Bug: 47717
Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
---
M modules/ve/ui/styles/ve.ui.Widget.css
M modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
2 files changed, 39 insertions(+), 1 deletion(-)


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

diff --git a/modules/ve/ui/styles/ve.ui.Widget.css 
b/modules/ve/ui/styles/ve.ui.Widget.css
index f066780..f31d7fe 100644
--- a/modules/ve/ui/styles/ve.ui.Widget.css
+++ b/modules/ve/ui/styles/ve.ui.Widget.css
@@ -481,3 +481,12 @@
 .ve-ui-mwCategorySortkeyForm .ve-ui-inputLabelWidget {
padding: 0 0.125em 0.5em 0.125em;
 }
+
+/* RTL Definitions */
+
+.ve-ui-rtl {
+   direction: rtl;
+}
+.ve-ui-ltr {
+   direction: ltr;
+}
\ No newline at end of file
diff --git a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
index 2545ba6..615e4d1 100644
--- a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
@@ -23,6 +23,11 @@
 
// Initialization
this.$.addClass( 've-ui-linkTargetInputWidget' );
+
+   // Default RTL/LTR check 
+   if ( $( 'body' ).hasClass( 'rtl' ) ) {
+   this.$input.addClass( 've-ui-rtl' );
+   }
 };
 
 /* Inheritance */
@@ -30,7 +35,32 @@
 ve.inheritClass( ve.ui.LinkTargetInputWidget, ve.ui.TextInputWidget );
 
 /* Methods */
+ve.ui.LinkTargetInputWidget.prototype.onEdit = function () {
+   if ( !this.disabled ) {
 
+   // RTL/LTR check:
+   if ( $( 'body' ).hasClass( 'rtl' ) ) {
+   if ( 
ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( this.$input.val() ) 
) {
+   // External link
+   if ( this.$input.hasClass( 've-ui-rtl' ) ) {
+this.$input.removeClass( 've-ui-rtl' );
+this.$input.addClass( 've-ui-ltr' );
+   }
+   } else {
+   // Internal link
+   if ( this.$input.hasClass( 've-ui-ltr' ) ) {
+this.$input.removeClass( 've-ui-ltr');
+this.$input.addClass( 've-ui-rtl' );
+   }
+   }
+   }   
+   // Allow the stack to clear so the value will be updated
+   setTimeout( ve.bind( function () {
+   this.setValue( this.$input.val() );
+   }, this ) );
+   }
+   
+};
 /**
  * Set the value of the input.
  *
@@ -70,7 +100,6 @@
this.annotation = annotation;
 
// Call parent method
-
ve.ui.TextInputWidget.prototype.setValue.call(
this, this.getTargetFromAnnotation( annotation )
);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
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


[MediaWiki-commits] [Gerrit] RTL fix for VE's link widget - change (mediawiki...VisualEditor)

2013-05-02 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: RTL fix for VE's link widget
..


RTL fix for VE's link widget

The purpose is to flip the direction of the input inside
the link widget for RTL wikis, but flip it again to LTR
if the user inserts an external URL. This is my first VE
fix, I tried to follow conventions and avoid touching the
parent objects that are unrelated to URLs.

Bug: 47717
Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
---
M modules/ve/ui/styles/ve.ui.Widget.css
M modules/ve/ui/widgets/ve.ui.InputWidget.js
M modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
3 files changed, 54 insertions(+), 1 deletion(-)

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



diff --git a/modules/ve/ui/styles/ve.ui.Widget.css 
b/modules/ve/ui/styles/ve.ui.Widget.css
index f066780..7eeef79 100644
--- a/modules/ve/ui/styles/ve.ui.Widget.css
+++ b/modules/ve/ui/styles/ve.ui.Widget.css
@@ -481,3 +481,14 @@
 .ve-ui-mwCategorySortkeyForm .ve-ui-inputLabelWidget {
padding: 0 0.125em 0.5em 0.125em;
 }
+
+/* RTL Definitions */
+
+/* @noflip */
+.ve-ui-rtl {
+   direction: rtl;
+}
+/* @noflip */
+.ve-ui-ltr {
+   direction: ltr;
+}
\ No newline at end of file
diff --git a/modules/ve/ui/widgets/ve.ui.InputWidget.js 
b/modules/ve/ui/widgets/ve.ui.InputWidget.js
index e6ca910..725b05b 100644
--- a/modules/ve/ui/widgets/ve.ui.InputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.InputWidget.js
@@ -89,6 +89,21 @@
 ve.ui.InputWidget.prototype.getValue = function () {
return this.value;
 };
+/**
+ * Sets the direction of the current input, either RTL or LTR
+ *
+ * @method
+ * @param {boolean} isRTL
+ */
+ve.ui.InputWidget.prototype.setRTL = function( isRTL ) {
+   if ( isRTL ) {
+   this.$input.removeClass( 've-ui-ltr' );
+   this.$input.addClass( 've-ui-rtl' );
+   } else {
+   this.$input.removeClass( 've-ui-rtl' );
+   this.$input.addClass( 've-ui-ltr' );
+   }
+};
 
 /**
  * Set the value of the input.
diff --git a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
index 2545ba6..b1f0ea0 100644
--- a/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LinkTargetInputWidget.js
@@ -23,6 +23,11 @@
 
// Initialization
this.$.addClass( 've-ui-linkTargetInputWidget' );
+
+   // Default RTL/LTR check
+   if ( $( 'body' ).hasClass( 'rtl' ) ) {
+   this.$input.addClass( 've-ui-rtl' );
+   }
 };
 
 /* Inheritance */
@@ -31,6 +36,29 @@
 
 /* Methods */
 
+/**
+ * Handle value-changing events
+ *
+ * Overrides onEdit to perform RTL test based on the typed URL
+ *
+ * @method
+ */
+ve.ui.LinkTargetInputWidget.prototype.onEdit = function () {
+   if ( !this.disabled ) {
+
+   // Allow the stack to clear so the value will be updated
+   setTimeout( ve.bind( function () {
+   // RTL/LTR check
+   if ( $( 'body' ).hasClass( 'rtl' ) ) {
+   var isExt = 
ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( this.$input.val() );
+   // If URL is external, flip to LTR. Otherwise, 
set back to RTL
+   this.setRTL( !isExt );
+   }
+   this.setValue( this.$input.val() );
+   }, this ) );
+   }
+
+};
 /**
  * Set the value of the input.
  *
@@ -70,7 +98,6 @@
this.annotation = annotation;
 
// Call parent method
-
ve.ui.TextInputWidget.prototype.setValue.call(
this, this.getTargetFromAnnotation( annotation )
);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic13b9c3b155ce2979298cac9518c7419b9d45bac
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo mor...@gmail.com
Gerrit-Reviewer: Amire80 amir.ahar...@mail.huji.ac.il
Gerrit-Reviewer: Catrope roan.katt...@gmail.com
Gerrit-Reviewer: Christian christ...@wikia-inc.com
Gerrit-Reviewer: Inez i...@wikia-inc.com
Gerrit-Reviewer: Jforrester jforres...@wikimedia.org
Gerrit-Reviewer: Matmarex matma@gmail.com
Gerrit-Reviewer: Mooeypoo mor...@gmail.com
Gerrit-Reviewer: Robmoen rm...@wikimedia.org
Gerrit-Reviewer: Trevor Parscal tpars...@wikimedia.org
Gerrit-Reviewer: jenkins-bot

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