Node.js based forum software built for the modern web
move cursor to end in share input
Baris Soner Usakli4c6fb72db0fa
diff --git a/public/src/forum/topic.js b/public/src/forum/topic.jsindex bc3cb9cd9d..2502412e01 100644--- a/public/src/forum/topic.js+++ b/public/src/forum/topic.js@@ -506,7 +506,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {$('#post_' + pid + '_link').val(window.location.href + "#" + pid);// without the setTimeout can't select the text in the inputsetTimeout(function() {- $('#post_' + pid + '_link').select();+ $('#post_' + pid + '_link').putCursorAtEnd().select();++}, 50);});diff --git a/public/src/utils.js b/public/src/utils.jsindex 3ecee02ee7..2e4064d1f8 100644--- a/public/src/utils.js+++ b/public/src/utils.js@@ -242,6 +242,21 @@});};+ //http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element+ $.fn.putCursorAtEnd = function() {+ return this.each(function() {+ $(this).focus();++ if (this.setSelectionRange) {+ var len = $(this).val().length * 2;+ this.setSelectionRange(len, len);+ } else {+ $(this).val($(this).val());+ }+ this.scrollTop = 999999;+ });+ };+})(jQuery);}