Merge branch 'atcomplete'
This commit is contained in:
commit
2765b0ba41
2 changed files with 57 additions and 21 deletions
|
@ -13,20 +13,28 @@ function ACPopup(elm,backend_url){
|
||||||
this.ready=true;
|
this.ready=true;
|
||||||
this.kp_timer = false;
|
this.kp_timer = false;
|
||||||
this.url = backend_url;
|
this.url = backend_url;
|
||||||
|
|
||||||
style = $(elm).offset();
|
if(typeof elm.editorId == "undefined") {
|
||||||
w = $(elm).width();
|
style = $(elm).offset();
|
||||||
h = $(elm).height();
|
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.top=style.top+h;
|
||||||
style.width = w;
|
style.width = w;
|
||||||
style.position = 'absolute';
|
style.position = 'absolute';
|
||||||
/* style['max-height'] = '150px';
|
/* style['max-height'] = '150px';
|
||||||
style.border = '1px solid red';
|
style.border = '1px solid red';
|
||||||
style.background = '#cccccc';
|
style.background = '#cccccc';
|
||||||
|
|
||||||
style.overflow = 'auto';
|
style.overflow = 'auto';
|
||||||
style['z-index'] = '100000';
|
style['z-index'] = '100000';
|
||||||
*/
|
*/
|
||||||
style.display = 'none';
|
style.display = 'none';
|
||||||
|
|
||||||
this.cont = $("<div class='acpopup'></div>");
|
this.cont = $("<div class='acpopup'></div>");
|
||||||
|
@ -65,7 +73,7 @@ ACPopup.prototype._search = function(){
|
||||||
that.cont.show();
|
that.cont.show();
|
||||||
$(data.items).each(function(){
|
$(data.items).each(function(){
|
||||||
html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick)
|
html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick)
|
||||||
that.add(html, this.nick + '+' + this.id + ' - ' + this.link);
|
that.add(html, this.nick + '+' + this.id + ' - ' + this.link);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
that.cont.hide();
|
that.cont.hide();
|
||||||
|
@ -74,16 +82,25 @@ ACPopup.prototype._search = function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
ACPopup.prototype.add = function(label, value){
|
ACPopup.prototype.add = function(label, value){
|
||||||
var that=this;
|
var that=this;
|
||||||
var elm = $("<div class='acpopupitem' title='"+value+"'>"+label+"</div>");
|
var elm = $("<div class='acpopupitem' title='"+value+"'>"+label+"</div>");
|
||||||
elm.click(function(e){
|
elm.click(function(e){
|
||||||
t = $(this).attr('title').replace(new RegExp(' \- .*'),'');
|
t = $(this).attr('title').replace(new RegExp(' \- .*'),'');
|
||||||
el=$(that.element);
|
if(typeof(that.element.container) === "undefined") {
|
||||||
sel = el.getSelection();
|
el=$(that.element);
|
||||||
sel.start = sel.start- that.searchText.length;
|
sel = el.getSelection();
|
||||||
el.setSelection(sel.start,sel.end).replaceSelectedText(t).collapseSelection(false);
|
sel.start = sel.start- that.searchText.length;
|
||||||
that.close();
|
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);
|
$(this.cont).append(elm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,26 @@ function initEditor(cb){
|
||||||
content_css: "$baseurl/view/custom_tinymce.css",
|
content_css: "$baseurl/view/custom_tinymce.css",
|
||||||
theme_advanced_path : false,
|
theme_advanced_path : false,
|
||||||
setup : function(ed) {
|
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) {
|
ed.onKeyUp.add(function(ed, e) {
|
||||||
var txt = tinyMCE.activeEditor.getContent();
|
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;
|
textlen = txt.length;
|
||||||
if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
|
if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
|
||||||
$('#profile-jot-desc').html(ispublic);
|
$('#profile-jot-desc').html(ispublic);
|
||||||
|
@ -41,6 +58,8 @@ function initEditor(cb){
|
||||||
$('#profile-jot-desc').html(' ');
|
$('#profile-jot-desc').html(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Character count
|
||||||
|
|
||||||
if(textlen <= 140) {
|
if(textlen <= 140) {
|
||||||
$('#character-counter').removeClass('red');
|
$('#character-counter').removeClass('red');
|
||||||
$('#character-counter').removeClass('orange');
|
$('#character-counter').removeClass('orange');
|
||||||
|
@ -71,8 +90,8 @@ function initEditor(cb){
|
||||||
editor = true;
|
editor = true;
|
||||||
// setup acl popup
|
// setup acl popup
|
||||||
$("a#jot-perms-icon").fancybox({
|
$("a#jot-perms-icon").fancybox({
|
||||||
'transitionIn' : 'none',
|
'transitionIn' : 'elastic',
|
||||||
'transitionOut' : 'none'
|
'transitionOut' : 'elastic'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (typeof cb!="undefined") cb();
|
if (typeof cb!="undefined") cb();
|
||||||
|
|
Loading…
Reference in a new issue