mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Ember Upgrade: 1.0
This commit is contained in:
38
vendor/assets/javascripts/jquery.putcursoratend.js
vendored
Normal file
38
vendor/assets/javascripts/jquery.putcursoratend.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// jQuery plugin: PutCursorAtEnd 1.0
|
||||
// http://plugins.jquery.com/project/PutCursorAtEnd
|
||||
// by teedyay
|
||||
//
|
||||
// Puts the cursor at the end of a textbox/ textarea
|
||||
|
||||
// codesnippet: 691e18b1-f4f9-41b4-8fe8-bc8ee51b48d4
|
||||
(function($)
|
||||
{
|
||||
jQuery.fn.putCursorAtEnd = function()
|
||||
{
|
||||
return this.each(function()
|
||||
{
|
||||
$(this).focus()
|
||||
|
||||
// If this function exists...
|
||||
if (this.setSelectionRange)
|
||||
{
|
||||
// ... then use it
|
||||
// (Doesn't work in IE)
|
||||
|
||||
// Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh.
|
||||
var len = $(this).val().length * 2;
|
||||
this.setSelectionRange(len, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ... otherwise replace the contents with itself
|
||||
// (Doesn't work in Google Chrome)
|
||||
$(this).val($(this).val());
|
||||
}
|
||||
|
||||
// Scroll to the bottom, in case we're in a tall textarea
|
||||
// (Necessary for Firefox and Google Chrome)
|
||||
this.scrollTop = 999999;
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user