From 4a99effeb025e6ed6f1a2667a533894aa1fe2f46 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 25 Apr 2018 17:06:45 +0200 Subject: focusing on mail --- public/assets/js/vendor/util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'public/assets/js/vendor/util.js') diff --git a/public/assets/js/vendor/util.js b/public/assets/js/vendor/util.js index bcaa2d2..43ca81b 100644 --- a/public/assets/js/vendor/util.js +++ b/public/assets/js/vendor/util.js @@ -140,6 +140,26 @@ function range(m,n,s){ return a } +// manipulate text selection in an element +function setSelectionRange(input, selectionStart, selectionEnd) { + if (input.setSelectionRange) { + input.focus(); + input.setSelectionRange(selectionStart, selectionEnd); + } + else if (input.createTextRange) { + var range = input.createTextRange(); + range.collapse(true); + range.moveEnd('character', selectionEnd); + range.moveStart('character', selectionStart); + range.select(); + } +} + +// place cursor at a specific point (usually the beginning) +function setCaretToPos (input, pos) { + setSelectionRange(input, pos, pos); +} + var guid_syllables = "iz az ez or iv ex baz el lo lum ot un no".split(" ") var guid_n = 0 function guid(n){ -- cgit v1.2.3-70-g09d2