64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
var enableAt = function(_editor) {
|
|
var editor = _editor;
|
|
if(editor.edit == undefined || editor.edit.iframe == undefined){
|
|
return;
|
|
}
|
|
|
|
var id = arguments[1] ? arguments[1] : undefined;
|
|
var type = arguments[2] ? arguments[2] : 'Activity';
|
|
|
|
var ifr = editor.edit.iframe[0];
|
|
var doc = ifr.contentDocument || iframe.contentWindow.document;
|
|
var ifrBody = doc.body;
|
|
//ifrBody.contentEditable = false;
|
|
$(ifrBody).attr('enable_at', 'true');
|
|
console.log("enable at");
|
|
|
|
//$.fn.atwho.debug = true;
|
|
|
|
|
|
var names = [];
|
|
if("undefined" !== (typeof atPersonLists)){
|
|
names = atPersonLists;
|
|
}
|
|
|
|
if('undefined' != (typeof id)){
|
|
names = '/at/' + id + '.json?type='+type;
|
|
}
|
|
|
|
//var names = ["Jacob","Isabella","Ethan","Emma","Michael","Olivia","Alexander","Sophia","William","Ava","Joshua","Emily","Daniel","Madison","Jayden","Abigail","Noah","Chloe","你好","你你你", "가"];
|
|
//
|
|
//var names = $.map(names,function(value,i) {
|
|
// return {'id':i,'name':value,'email':value+"@email.com"};
|
|
//});
|
|
|
|
var at_config = {
|
|
at: "@",
|
|
data: names,
|
|
insertTpl: '<span class="at" data-user-id="${userid}"><a href="/users/${userid}">@${name}(${login})</a></span>',
|
|
displayTpl: "<li>${name} <small>${login}</small></li>",
|
|
searchKey: 'searchKey',
|
|
limit: 200
|
|
};
|
|
|
|
console.log(_editor.options);
|
|
|
|
var input = $(ifrBody);
|
|
|
|
_editor.options.enable_at = (function(){
|
|
var first = true;
|
|
return function(){
|
|
if(first){
|
|
input.atwho(at_config);
|
|
first = false;
|
|
}
|
|
}
|
|
})();
|
|
|
|
//$(ifrBody).atwho(at_config);
|
|
|
|
|
|
//$inputor.caret('pos', 47);
|
|
//$inputor.focus().atwho('run');
|
|
};
|