user-mention.js
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function($, undefined) {
$(document).ready(function() {
var is_community = _.isEmpty($('html.profile-type-is-community')) !== true;
var community = null;
if (is_community) {
community = noosfero.profile;
}
$('#comment_body, #leave_scrap_content, form.profile-wall-reply-form textarea').mentionsInput({
onDataRequest: function (mode, keyword, onDataRequestCompleteCallback) {
var search_url = "/search/search_for_friends_and_members?q="+keyword;
$.ajax({
method: "GET",
url: search_url,
dataType: "json",
data: {'community': community},
success: function (response) {
var data = response.map(function(item) {
return {
name: item.identifier,
fullName: item.name,
id: item.id,
type: 'contact'
};
});
// Call this to populate mention.
onDataRequestCompleteCallback.call(this, data);
}
}); // $.ajax end
},
triggerChar: '@',
allowRepeat: true,
minChars: 3,
keepTriggerCharacter: true
}); // mentionsInput end
}); // ready end
}) (jQuery);