mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 07:44:56 +01:00
Minor fix to position cursor.
This commit is contained in:
parent
0e21aad802
commit
12221ab0af
@ -43,7 +43,7 @@ mindplot.MultilineTextEditor = new Class({
|
||||
|
||||
textareaElem.setStyles({
|
||||
border: "1px gray dashed",
|
||||
background:"transparent",
|
||||
background:"rgba(98, 135, 167, .3)",
|
||||
outline: '0 none',
|
||||
resize: 'none',
|
||||
overflow:"hidden"
|
||||
@ -181,8 +181,7 @@ mindplot.MultilineTextEditor = new Class({
|
||||
|
||||
// Set the element focus and select the current text ...
|
||||
var inputElem = this._getTextareaElem();
|
||||
inputElem.focus();
|
||||
this._changeCursor(inputElem, $defined(defaultText));
|
||||
this._positionCursor(inputElem, !$defined(defaultText));
|
||||
|
||||
}.bind(this);
|
||||
|
||||
@ -228,24 +227,29 @@ mindplot.MultilineTextEditor = new Class({
|
||||
return this._containerElem.getElement('textarea');
|
||||
},
|
||||
|
||||
_changeCursor : function(textareaElem, selectText) {
|
||||
// Select text if it's required ...
|
||||
if (textareaElem.createTextRange) //ie
|
||||
{
|
||||
var range = textareaElem.createTextRange();
|
||||
var pos = textareaElem.value.length;
|
||||
if (!selectText) {
|
||||
range.select();
|
||||
range.move("character", pos);
|
||||
_positionCursor : function(textareaElem, selectText) {
|
||||
textareaElem.focus();
|
||||
if (selectText) {
|
||||
// Mark text as selected ...
|
||||
if (textareaElem.createTextRange) {
|
||||
var rang = textareaElem.createTextRange();
|
||||
rang.select();
|
||||
rang.move("character", textareaElem.value.length);
|
||||
}
|
||||
else {
|
||||
range.move("character", pos);
|
||||
range.select();
|
||||
textareaElem.setSelectionRange(0, textareaElem.value.length);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Move the cursor to the last character ..
|
||||
if (textareaElem.createTextRange) {
|
||||
var range = textareaElem.createTextRange();
|
||||
range.move("character", textareaElem.value.length);
|
||||
} else {
|
||||
textareaElem.selectionStart = textareaElem.value.length;
|
||||
}
|
||||
}
|
||||
else if (!selectText) {
|
||||
textareaElem.setSelectionRange(0, textareaElem.value.length);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
close : function(update) {
|
||||
|
@ -161,9 +161,9 @@ mindplot.TextEditor = new Class({
|
||||
var elemSize = topic.getSize();
|
||||
this._setEditorSize(elemSize.width, elemSize.height);
|
||||
|
||||
var inputElem = this._getTextareaElem();
|
||||
inputElem.focus();
|
||||
this._changeCursor(inputElem, $defined(defaultText));
|
||||
var textareaElem = this._getTextareaElem();
|
||||
textareaElem.focus();
|
||||
this._positionCursor(textareaElem, !$defined(defaultText));
|
||||
|
||||
}.bind(this);
|
||||
|
||||
@ -225,7 +225,7 @@ mindplot.TextEditor = new Class({
|
||||
this._containerElem.style.height = this._size.height + "px";
|
||||
},
|
||||
|
||||
_changeCursor : function(inputElem, selectText) {
|
||||
_positionCursor : function(inputElem, selectText) {
|
||||
// Select text if it's required ...
|
||||
if (inputElem.createTextRange) //ie
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user