Merge branch 'atcomplete'

This commit is contained in:
Friendika 2011-11-04 01:52:33 -07:00
commit 2765b0ba41
2 changed files with 57 additions and 21 deletions

View File

@ -14,9 +14,17 @@ function ACPopup(elm,backend_url){
this.kp_timer = false;
this.url = backend_url;
if(typeof elm.editorId == "undefined") {
style = $(elm).offset();
w = $(elm).width();
h = $(elm).height();
}
else {
style = $(elm.container).offset();
w = elm.container.offsetWidth;
h = elm.container.offsetHeight;
}
style.top=style.top+h;
style.width = w;
style.position = 'absolute';
@ -79,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);
}

View File

@ -30,9 +30,26 @@ function initEditor(cb){
content_css: "$baseurl/view/custom_tinymce.css",
theme_advanced_path : false,
setup : function(ed) {
//Character count
cPopup = null;
ed.onKeyDown.add(function(ed,e) {
if(cPopup !== null)
cPopup.onkey(e);
});
ed.onKeyUp.add(function(ed, e) {
var txt = tinyMCE.activeEditor.getContent();
match = txt.match(/@([^ \n]+)$/);
if(match!==null) {
if(cPopup === null) {
cPopup = new ACPopup(this,baseurl+"/acl");
}
if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
if(! cPopup.ready) cPopup = null;
}
else {
if(cPopup !== null) { cPopup.close(); cPopup = null; }
}
textlen = txt.length;
if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
$('#profile-jot-desc').html(ispublic);
@ -41,6 +58,8 @@ function initEditor(cb){
$('#profile-jot-desc').html('&nbsp;');
}
//Character count
if(textlen <= 140) {
$('#character-counter').removeClass('red');
$('#character-counter').removeClass('orange');
@ -71,8 +90,8 @@ function initEditor(cb){
editor = true;
// setup acl popup
$("a#jot-perms-icon").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none'
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
} else {
if (typeof cb!="undefined") cb();