Mentions: search users by email or name
This commit is contained in:
parent
bb8e4f5f7f
commit
b730cd4a7f
|
@ -1044,24 +1044,25 @@ define([
|
||||||
str = str.toLowerCase();
|
str = str.toLowerCase();
|
||||||
if (str.length>0) {
|
if (str.length>0) {
|
||||||
users = _.filter(users, function(item) {
|
users = _.filter(users, function(item) {
|
||||||
return (0 === item.email.toLowerCase().indexOf(str))
|
return (item.email && 0 === item.email.toLowerCase().indexOf(str) || item.name && 0 === item.name.toLowerCase().indexOf(str))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var tpl = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" style="font-size: 12px;"><div><%= caption %></div><div style="color: #909090;"><%= options.value %></div></a>');
|
var tpl = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" style="font-size: 12px;"><div><%= caption %></div><div style="color: #909090;"><%= options.value %></div></a>');
|
||||||
_.each(users, function(menuItem, index) {
|
_.each(users, function(menuItem, index) {
|
||||||
|
if (menuItem.email && menuItem.name) {
|
||||||
var mnu = new Common.UI.MenuItem({
|
var mnu = new Common.UI.MenuItem({
|
||||||
caption : menuItem.name,
|
caption : menuItem.name,
|
||||||
value : menuItem.email,
|
value : menuItem.email,
|
||||||
template : tpl
|
template : tpl
|
||||||
|
|
||||||
}).on('click', function(item, e) {
|
}).on('click', function(item, e) {
|
||||||
me.insertEmailToTextbox(item.options.value, left, right);
|
me.insertEmailToTextbox(item.options.value, left, right);
|
||||||
});
|
});
|
||||||
menu.addItem(mnu);
|
menu.addItem(mnu);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (users.length>0) {
|
if (menu.items.length>0) {
|
||||||
menuContainer.css({left: showPoint[0], top : showPoint[1]});
|
menuContainer.css({left: showPoint[0], top : showPoint[1]});
|
||||||
menu.menuAlignEl = textbox;
|
menu.menuAlignEl = textbox;
|
||||||
menu.show();
|
menu.show();
|
||||||
|
|
Loading…
Reference in a new issue