mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
move cursor to end in share input
This commit is contained in:
@@ -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 input
|
||||
setTimeout(function() {
|
||||
$('#post_' + pid + '_link').select();
|
||||
$('#post_' + pid + '_link').putCursorAtEnd().select();
|
||||
|
||||
|
||||
}, 50);
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user