1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
(function ($) {
|
4 |
|
|
$.fn.insertAtCursor = function (tagName) {
|
5 |
|
|
return this.each(function(){
|
6 |
|
|
if (document.selection) {
|
7 |
|
|
|
8 |
|
|
this.focus();
|
9 |
|
|
sel = document.selection.createRange();
|
10 |
|
|
sel.text = tagName;
|
11 |
|
|
this.focus();
|
12 |
|
|
}else if (this.selectionStart || this.selectionStart == '0') {
|
13 |
|
|
|
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); |