diff options
Diffstat (limited to 'public/assets/js/vendor/util.js')
| -rw-r--r-- | public/assets/js/vendor/util.js | 20 |
1 files changed, 20 insertions, 0 deletions
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){ |
