root / drupal7 / sites / all / modules / token_insert / token_insert.js @ 74f6bef0
1 |
|
---|---|
2 |
// General Insert API functions.
|
3 |
(function ($) { |
4 |
$.fn.insertAtCursor = function (tagName) { |
5 |
return this.each(function(){ |
6 |
if (document.selection) {
|
7 |
//IE support
|
8 |
this.focus();
|
9 |
sel = document.selection.createRange(); |
10 |
sel.text = tagName; |
11 |
this.focus();
|
12 |
}else if (this.selectionStart || this.selectionStart == '0') { |
13 |
//MOZILLA/NETSCAPE support
|
14 |
startPos = this.selectionStart;
|
15 |
endPos = this.selectionEnd;
|
16 |
scrollTop = this.scrollTop;
|
17 |
this.value = this.value.substring(0, startPos) + tagName + this.value.substring(endPos,this.value.length); |
18 |
this.focus();
|
19 |
this.selectionStart = startPos + tagName.length;
|
20 |
this.selectionEnd = startPos + tagName.length;
|
21 |
this.scrollTop = scrollTop;
|
22 |
} else {
|
23 |
this.value += tagName;
|
24 |
this.focus();
|
25 |
} |
26 |
}); |
27 |
}; |
28 |
})(jQuery); |