tinymce autocomplete
This commit is contained in:
parent
e19b597180
commit
51b0f583b0
1 changed files with 21 additions and 12 deletions
|
@ -20,11 +20,11 @@ function ACPopup(elm,backend_url){
|
|||
h = $(elm).height();
|
||||
}
|
||||
else {
|
||||
style = $('.profile-jot-text').offset();
|
||||
w = 300;
|
||||
h = 150;
|
||||
|
||||
style = $(elm.container).offset();
|
||||
w = elm.container.offsetWidth;
|
||||
h = elm.container.offsetHeight;
|
||||
}
|
||||
|
||||
style.top=style.top+h;
|
||||
style.width = w;
|
||||
style.position = 'absolute';
|
||||
|
@ -87,11 +87,20 @@ ACPopup.prototype.add = function(label, value){
|
|||
var elm = $("<div class='acpopupitem' title='"+value+"'>"+label+"</div>");
|
||||
elm.click(function(e){
|
||||
t = $(this).attr('title').replace(new RegExp(' \- .*'),'');
|
||||
if(typeof(that.element.container) === "undefined") {
|
||||
el=$(that.element);
|
||||
sel = el.getSelection();
|
||||
sel.start = sel.start- that.searchText.length;
|
||||
el.setSelection(sel.start,sel.end).replaceSelectedText(t).collapseSelection(false);
|
||||
el.setSelection(sel.start,sel.end).replaceSelectedText(t+' ').collapseSelection(false);
|
||||
that.close();
|
||||
}
|
||||
else {
|
||||
txt = tinyMCE.activeEditor.getContent();
|
||||
newtxt = txt.replace(that.searchText,t+' ');
|
||||
tinyMCE.activeEditor.setContent(newtxt);
|
||||
tinyMCE.activeEditor.focus();
|
||||
that.close();
|
||||
}
|
||||
});
|
||||
$(this.cont).append(elm);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue