File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -582,3 +582,36 @@ function getRandomInt(min, max){
582582 return Math.floor(Math.random() * (max - min + 1)) + min;
583583}
584584
585+ jQuery('.addPlaceholder').live("click", function(){
586+ var placeholderText = jQuery(this).text();
587+ var template = jQuery(this).siblings(':input');
588+ template.insertAtCaret(placeholderText);
589+ });
590+
591+ jQuery.fn.extend({
592+ insertAtCaret: function(myValue){
593+ return this.each(function(i) {
594+ if (document.selection) {
595+ //For browsers like Internet Explorer
596+ this.focus();
597+ sel = document.selection.createRange();
598+ sel.text = myValue;
599+ this.focus();
600+ } else if (this.selectionStart || this.selectionStart == '0') {
601+ //For browsers like Firefox and Webkit based
602+ var startPos = this.selectionStart;
603+ var endPos = this.selectionEnd;
604+ var scrollTop = this.scrollTop;
605+ this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length);
606+ this.focus();
607+ this.selectionStart = startPos + myValue.length;
608+ this.selectionEnd = startPos + myValue.length;
609+ this.scrollTop = scrollTop;
610+ } else {
611+ this.value += myValue;
612+ this.focus();
613+ }
614+ })
615+ }
616+ });
617+
You can’t perform that action at this time.
0 commit comments