[MediaWiki-commits] [Gerrit] AnnotationInspector insertion over blank selection - change (mediawiki...VisualEditor)

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

Change subject: AnnotationInspector insertion over blank selection
..


AnnotationInspector insertion over blank selection

This commit fixes two issues with insertion of annotations in blank space:
* LanguageInspector issue with inserting an language annotation inside any
  whitespace (selection of space between words or collapsed selection in
  blank line)
* AnnotationInspector issue with collapsed selection inside slugs. If
  the marker was in a slug collapsed selection, activating
  AnnotationInspector would expand the range to the closest word (on the
  next paragraph). This commit makes sure the expansion for the next word
  only happens if the selection is outside a slug.

Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
---
M modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
M modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
M modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
3 files changed, 14 insertions(+), 10 deletions(-)

Approvals:
  Catrope: Looks good to me, but someone else must approve
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js 
b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
index 6d5c59e..1afb2b9 100644
--- a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -60,10 +60,9 @@
 
// Parent method
ve.ui.Inspector.prototype.onSetup.call( this );
-
// Initialize range
if ( !annotation ) {
-   if ( fragment.getRange().isCollapsed() ) {
+   if ( fragment.getRange().isCollapsed()  
!this.surface.view.hasSlugAtOffset( fragment.getRange().start ) ) {
// Expand to nearest word
expandedFragment = fragment.expandRange( 'word' );
fragment = expandedFragment;
diff --git a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js 
b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
index 0d4774e..3f2503d 100644
--- a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
@@ -149,14 +149,19 @@
var langCode, langDir, annData;
 
// Validate the given annotation:
+   if ( annotation ) {
+   // Give precedence to dir value if it already exists
+   // in the annotation:
+   langDir = annotation.getAttribute( 'dir' );
 
-   // Give precedence to dir value if it already exists
-   // in the annotation:
-   langDir = annotation.getAttribute( 'dir' );
-
-   // Set language according to the one in the given annotation
-   // or leave blank if element has no language set
-   langCode = annotation.getAttribute( 'lang' );
+   // Set language according to the one in the given annotation
+   // or leave blank if element has no language set
+   langCode = annotation.getAttribute( 'lang' );
+   } else {
+   // No annotation (empty text or collapsed fragment on empty 
line)
+   langCode = this.initLang;
+   langDir = this.initDir;
+   }
 
// If language exists, but dir is undefined/null,
// fix the dir in terms of language:
diff --git a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
index 5605c77..21f08c9 100644
--- a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
@@ -133,7 +133,7 @@
  */
 ve.ui.LanguageInputWidget.prototype.getValue = function () {
// Specifically to be displayed
-   return this.lang;
+   return this.$langNameDisp.text();
 };
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
Gerrit-PatchSet: 2
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: Inez i...@wikia-inc.com
Gerrit-Reviewer: Krinkle krinklem...@gmail.com
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


[MediaWiki-commits] [Gerrit] AnnotationInspector insertion over blank selection - change (mediawiki...VisualEditor)

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

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


Change subject: AnnotationInspector insertion over blank selection
..

AnnotationInspector insertion over blank selection

This commit fixes two issues with insertion of annotations in blank space:
* LanguageInspector issue with inserting an language annotation inside any
  whitespace (selection of space between words or collapsed selection in
  blank line)
* AnnotationInspector issue with collapsed selection on the first line. If
  the marker was on the first blank line with collapsed selection, activating
  AnnotationInspector would expand the range to the closest word (on the next
  paragraph), probably because of the slug. This commit fixes that, and
  instead inserts a new annotation like in any other blank line.

Change-Id: I144eccefba16131a3d2ec6a3181adf47a15d6cc0
---
M modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
M modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
M modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
3 files changed, 14 insertions(+), 9 deletions(-)


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

diff --git a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js 
b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
index 6d5c59e..7448b7b 100644
--- a/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.AnnotationInspector.js
@@ -63,7 +63,7 @@
 
// Initialize range
if ( !annotation ) {
-   if ( fragment.getRange().isCollapsed() ) {
+   if ( fragment.getRange().isCollapsed()  
fragment.getRange().start  0 ) {
// Expand to nearest word
expandedFragment = fragment.expandRange( 'word' );
fragment = expandedFragment;
diff --git a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js 
b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
index 0d4774e..3f2503d 100644
--- a/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
+++ b/modules/ve/ui/inspectors/ve.ui.LanguageInspector.js
@@ -149,14 +149,19 @@
var langCode, langDir, annData;
 
// Validate the given annotation:
+   if ( annotation ) {
+   // Give precedence to dir value if it already exists
+   // in the annotation:
+   langDir = annotation.getAttribute( 'dir' );
 
-   // Give precedence to dir value if it already exists
-   // in the annotation:
-   langDir = annotation.getAttribute( 'dir' );
-
-   // Set language according to the one in the given annotation
-   // or leave blank if element has no language set
-   langCode = annotation.getAttribute( 'lang' );
+   // Set language according to the one in the given annotation
+   // or leave blank if element has no language set
+   langCode = annotation.getAttribute( 'lang' );
+   } else {
+   // No annotation (empty text or collapsed fragment on empty 
line)
+   langCode = this.initLang;
+   langDir = this.initDir;
+   }
 
// If language exists, but dir is undefined/null,
// fix the dir in terms of language:
diff --git a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
index 5605c77..21f08c9 100644
--- a/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.LanguageInputWidget.js
@@ -133,7 +133,7 @@
  */
 ve.ui.LanguageInputWidget.prototype.getValue = function () {
// Specifically to be displayed
-   return this.lang;
+   return this.$langNameDisp.text();
 };
 
 /**

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

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