The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/ui/client/lib/textarea-cursor.js

19 lines
465 B

// http://stackoverflow.com/a/499158
$.fn.setCursorPosition = function(pos) {
this.each((index, element) => {
const p = pos < 0 ? element.value.length - pos : pos;
if (element.setSelectionRange) {
element.setSelectionRange(p, p);
} else if (element.createTextRange) {
const range = element.createTextRange();
range.collapse(true);
range.moveEnd('character', p);
range.moveStart('character', p);
range.select();
}
});
return this;
};