Revised selection code

SVN revision: 2160
This commit is contained in:
2009-01-16 13:42:07 +00:00
parent 6a4e2fd222
commit 761b5a0e0e
+4 -6
View File
@@ -7,14 +7,13 @@ function getSelection(text)
rng = sel.createRange();
rng.colapse;
return rng.text;
} else if (browser == 'Mozilla' || browser == 'Safari')
} else {
if (text.selectionEnd > 0 && text.selectionEnd != text.selectionStart &&
text.value.charAt(text.selectionEnd-1) == ' ')
return text.value.substring(text.selectionStart, text.selectionEnd-1);
else
return text.value.substring(text.selectionStart, text.selectionEnd);
else
return "";
}
}
function replaceSelection(doc, text, newSelection, cursorPos)
@@ -31,7 +30,7 @@ function replaceSelection(doc, text, newSelection, cursorPos)
rng.moveEnd('character', -(newSelection.length-cursorPos));
rng.select();
}
} else if (browser == 'Mozilla' || browser == 'Safari') {
} else {
start = text.selectionStart;
stop = text.selectionEnd;
if (text.selectionEnd > 0 && text.selectionStart != text.selectionEnd &&
@@ -48,8 +47,7 @@ function replaceSelection(doc, text, newSelection, cursorPos)
text.selectionStart = start + cursorPos;
text.selectionEnd = text.selectionStart;
}
} else
text.value += newSelection;
}
}
function elcode(text, tag, value)