mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-07-23 20:20:30 +08:00
For bug 73308
This commit is contained in:
@ -358,8 +358,8 @@ if (window.Common === undefined) {
|
||||
_postMessage({event:'onMakeActionLink', data: config});
|
||||
},
|
||||
|
||||
requestUsers: function (command, id) {
|
||||
_postMessage({event:'onRequestUsers', data: {c: command, id: id}});
|
||||
requestUsers: function (command, id, from, count, search) { // from, count, search are used for mentions
|
||||
_postMessage({event:'onRequestUsers', data: {c: command, id: id, from: from, count: count, search: search}});
|
||||
},
|
||||
|
||||
requestSendNotify: function (emails) {
|
||||
|
||||
@ -51,7 +51,7 @@ Common.UI.ExternalUsers = new( function() {
|
||||
api,
|
||||
userColors = [];
|
||||
|
||||
var _get = function(type, ids) {
|
||||
var _get = function(type, ids, from, count, search) {
|
||||
if (type==='info') {
|
||||
(typeof ids !== 'object') && (ids = [ids]);
|
||||
ids && (ids = _.uniq(ids));
|
||||
@ -67,7 +67,7 @@ Common.UI.ExternalUsers = new( function() {
|
||||
type = type || 'mention';
|
||||
if (externalUsers[type]===undefined) {
|
||||
isUsersLoading = true;
|
||||
Common.Gateway.requestUsers(type || 'mention');
|
||||
Common.Gateway.requestUsers(type || 'mention', undefined, from || 0, count || 100, search || '');
|
||||
} else {
|
||||
Common.NotificationCenter.trigger('mentions:setusers', type, externalUsers[type]);
|
||||
}
|
||||
@ -125,10 +125,12 @@ Common.UI.ExternalUsers = new( function() {
|
||||
externalUsers = [];
|
||||
return;
|
||||
}
|
||||
var type = data.c || 'mention';
|
||||
externalUsers[type] = data.users || [];
|
||||
var type = data.c || 'mention',
|
||||
users = data.users || [];
|
||||
if (data.total===undefined) // use old scheme
|
||||
externalUsers[type] = users;
|
||||
isUsersLoading = false;
|
||||
Common.NotificationCenter.trigger('mentions:setusers', type, externalUsers[type]);
|
||||
Common.NotificationCenter.trigger('mentions:setusers', type, users, data.total);
|
||||
});
|
||||
|
||||
Common.NotificationCenter.on('mentions:clearusers', function(type) {
|
||||
|
||||
@ -1123,6 +1123,8 @@ define([
|
||||
me.e = event;
|
||||
});
|
||||
textBox && textBox.on('input', function (event) {
|
||||
clearTimeout(me._state.timerEmailList);
|
||||
|
||||
var $this = $(this),
|
||||
start = this.selectionStart,
|
||||
val = $this.val(),
|
||||
@ -1141,7 +1143,9 @@ define([
|
||||
res = str.match(/^(?:[@]|[+](?!1))(\S*)/);
|
||||
if (res && res.length>1) {
|
||||
str = res[1]; // send to show email menu
|
||||
me.onEmailListMenu(str, left, right);
|
||||
me._state.timerEmailList = setTimeout(function () {
|
||||
me.onEmailListMenu(str, left, right);
|
||||
}, 300);
|
||||
} else
|
||||
me.onEmailListMenu(); // hide email menu
|
||||
});
|
||||
@ -1210,29 +1214,46 @@ define([
|
||||
},
|
||||
|
||||
onEmailListMenu: function(str, left, right) {
|
||||
clearTimeout(this._state.timerEmailList);
|
||||
if (typeof str == 'string') {
|
||||
this._state.emailSearch = {
|
||||
str: str,
|
||||
left: left,
|
||||
right: right
|
||||
right: right,
|
||||
from: 0,
|
||||
count: 100,
|
||||
total: undefined,
|
||||
scrollTop: 0
|
||||
};
|
||||
Common.UI.ExternalUsers.get('mention');
|
||||
var data = this._state.emailSearch;
|
||||
Common.UI.ExternalUsers.get('mention', undefined, data.from, data.count, data.str);
|
||||
} else {
|
||||
this._state.emailSearch = null;
|
||||
this.emailMenu.rendered && this.emailMenu.cmpEl.css('display', 'none');
|
||||
}
|
||||
},
|
||||
|
||||
onEmailListMenuCallback: function(type, users) {
|
||||
onEmailListMenuNext: function() {
|
||||
var data = this._state.emailSearch;
|
||||
if (data && data.total!==undefined && data.from + data.count < data.total) {
|
||||
data.from += data.count;
|
||||
Common.UI.ExternalUsers.get('mention', undefined, data.from, data.count, data.str);
|
||||
}
|
||||
},
|
||||
|
||||
onEmailListMenuCallback: function(type, users, total) {
|
||||
if (!this._state.emailSearch || users.length<1 || type && type!=='mention') return;
|
||||
|
||||
var me = this,
|
||||
menu = me.emailMenu,
|
||||
str = this._state.emailSearch.str,
|
||||
left = this._state.emailSearch.left,
|
||||
right = this._state.emailSearch.right;
|
||||
right = this._state.emailSearch.right,
|
||||
from = this._state.emailSearch.from,
|
||||
isClientSearch = total===undefined;// || from===0 && !str && total<this._state.emailSearch.count; ???
|
||||
|
||||
this._state.emailSearch = null;
|
||||
this._state.emailSearch.total = total;
|
||||
isClientSearch && (this._state.emailSearch = null);
|
||||
|
||||
var menuContainer = me.$window.find(Common.Utils.String.format('#menu-container-{0}', menu.id)),
|
||||
textbox = this.commentsView.getTextBox(),
|
||||
@ -1255,29 +1276,39 @@ define([
|
||||
tb && tb.focus();
|
||||
}, 10);
|
||||
});
|
||||
!isClientSearch && menu.scroller.cmpEl.on('scroll', function (event) {
|
||||
let st = $(event.target).scrollTop();
|
||||
if (me._state.emailSearch && me._state.emailSearch.scrollTop < st)
|
||||
me.onEmailListMenuNext();
|
||||
me._state.emailSearch.scrollTop = st;
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < menu.items.length; i++) {
|
||||
menu.removeItem(menu.items[i]);
|
||||
i--;
|
||||
if (isClientSearch || from===0) {
|
||||
for (var i = 0; i < menu.items.length; i++) {
|
||||
menu.removeItem(menu.items[i]);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (users.length>0) {
|
||||
str = str.toLowerCase();
|
||||
if (str.length>0) {
|
||||
users = _.filter(users, function(item) {
|
||||
if (item.email && 0 === item.email.toLowerCase().indexOf(str)) return true;
|
||||
if (isClientSearch) {
|
||||
str = str.toLowerCase();
|
||||
if (str.length>0) {
|
||||
users = _.filter(users, function(item) {
|
||||
if (item.email && 0 === item.email.toLowerCase().indexOf(str)) return true;
|
||||
|
||||
let arr = item.name ? item.name.toLowerCase().split(' ') : [],
|
||||
inName = false;
|
||||
for (let i=0; i<arr.length; i++) {
|
||||
if (0 === arr[i].indexOf(str)) {
|
||||
inName = true;
|
||||
break;
|
||||
let arr = item.name ? item.name.toLowerCase().split(' ') : [],
|
||||
inName = false;
|
||||
for (let i=0; i<arr.length; i++) {
|
||||
if (0 === arr[i].indexOf(str)) {
|
||||
inName = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return inName;
|
||||
});
|
||||
return inName;
|
||||
});
|
||||
}
|
||||
}
|
||||
var tpl = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem">' +
|
||||
'<div style="overflow: hidden; text-overflow: ellipsis; max-width: 195px;"><%= Common.Utils.String.htmlEncode(caption) %></div>' +
|
||||
|
||||
Reference in New Issue
Block a user