Catrope has uploaded a new change for review.

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

Change subject: TextInputWidget: Add moveCursorToEnd()
......................................................................

TextInputWidget: Add moveCursorToEnd()

Upstreamed from ve.selectEnd() in VisualEditor.

Change-Id: Ia63e6c6a043f9d82ae7e29502ab399ed73ab17fa
---
M src/widgets/TextInputWidget.js
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/75/232775/1

diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 38baa48..4e0993b 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -463,6 +463,23 @@
 };
 
 /**
+ * Focus the input and move the cursor to the end.
+ */
+OO.ui.TextInputWidget.prototype.moveCursorToEnd = function () {
+       var textRange,
+               element = this.$input[0];
+       this.focus();
+       if ( element.selectionStart !== undefined ) {
+               element.selectionStart = element.selectionEnd = 
element.value.length;
+       } else if ( element.createTextRange ) {
+               // IE 8 and below
+               textRange = element.createTextRange();
+               textRange.collapse( false );
+               textRange.select();
+       }
+};
+
+/**
  * Set the validation pattern.
  *
  * The validation pattern is either a regular expression, a function, or the 
symbolic name of a

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia63e6c6a043f9d82ae7e29502ab399ed73ab17fa
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to