Last change
on this file since 20968 was
11252,
checked in by mistic100, 13 years ago
|
first commit, only compatible with Piwigo 2.2.3 and last version of Comments on Albums
|
File size:
988 bytes
|
Line | |
---|
1 | /** |
---|
2 | * insertAtCaret function by sebagr.com |
---|
3 | * http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery/2819568#2819568 |
---|
4 | */ |
---|
5 | jQuery.fn.extend({ |
---|
6 | insertAtCaret: function(myValue){ |
---|
7 | return this.each(function(i) { |
---|
8 | if (document.selection) { |
---|
9 | this.focus(); |
---|
10 | sel = document.selection.createRange(); |
---|
11 | sel.text = myValue; |
---|
12 | this.focus(); |
---|
13 | } |
---|
14 | else if (this.selectionStart || this.selectionStart == '0') { |
---|
15 | var startPos = this.selectionStart; |
---|
16 | var endPos = this.selectionEnd; |
---|
17 | var scrollTop = this.scrollTop; |
---|
18 | this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length); |
---|
19 | this.focus(); |
---|
20 | this.selectionStart = startPos + myValue.length; |
---|
21 | this.selectionEnd = startPos + myValue.length; |
---|
22 | this.scrollTop = scrollTop; |
---|
23 | } else { |
---|
24 | this.value += myValue; |
---|
25 | this.focus(); |
---|
26 | } |
---|
27 | }) |
---|
28 | } |
---|
29 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.