diff options
author | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2013-07-04 00:24:43 +0300 |
---|---|---|
committer | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2013-07-04 00:24:43 +0300 |
commit | 93430ec17e60cac7b8e1e0064554c00bffd52cb3 (patch) | |
tree | cb59ceaf211fbf593e85df90715986b2a0eb7a05 /core | |
parent | d6f2fe6a6b0133b2ef308c170a4bed00fd1099ca (diff) | |
download | nextcloud-server-93430ec17e60cac7b8e1e0064554c00bffd52cb3.tar.gz nextcloud-server-93430ec17e60cac7b8e1e0064554c00bffd52cb3.zip |
Add selectRange function
Diffstat (limited to 'core')
-rw-r--r-- | core/js/js.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js index bfc9396ff2d..a4665b927f2 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -829,6 +829,26 @@ OC.set=function(name, value) { context[tail]=value; }; +/** + * select a range in an input field + * @link http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area + * @param {type} start + * @param {type} end + */ +$.fn.selectRange = function(start, end) { + return this.each(function() { + if (this.setSelectionRange) { + this.focus(); + this.setSelectionRange(start, end); + } else if (this.createTextRange) { + var range = this.createTextRange(); + range.collapse(true); + range.moveEnd('character', end); + range.moveStart('character', start); + range.select(); + } + }); +}; /** * Calls the server periodically every 15 mins to ensure that session doesnt |