Bug 11696: ensure that print overdue notices use the print template
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / lib / jquery / plugins / jquery.insertatcaret.js
1 /*!
2  * jQuery insertAtCaret
3  * Allows inserting text where the caret is in a textarea
4  * Copyright (c) 2003-2010 phpMyAdmin devel team
5  * Version: 1.0
6  * Developed by the phpMyAdmin devel team. Modified by Alex King and variaas
7  * http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript
8  * http://www.mail-archive.com/jquery-en@googlegroups.com/msg08708.html
9  * Licensed under the GPL license:
10  * http://www.gnu.org/licenses/gpl.html
11  */
12 ;(function($) {
13
14 $.fn.insertAtCaret = function (myValue) {
15
16     return this.each(function() {
17
18         //IE support
19         if (document.selection) {
20
21             this.focus();
22             sel = document.selection.createRange();
23             sel.text = myValue;
24             this.focus();
25
26         } else if (this.selectionStart || this.selectionStart == '0') {
27
28             //MOZILLA / NETSCAPE support
29             var startPos = this.selectionStart;
30             var endPos = this.selectionEnd;
31             var scrollTop = this.scrollTop;
32             this.value = this.value.substring(0, startPos)+ myValue+ this.value.substring(endPos,this.value.length);
33             this.focus();
34             this.selectionStart = startPos + myValue.length;
35             this.selectionEnd = startPos + myValue.length;
36             this.scrollTop = scrollTop;
37
38         } else {
39
40             this.value += myValue;
41             this.focus();
42         }
43     });
44 };
45
46 })(jQuery);