diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index fb36487309..031afc7dae 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -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) { diff --git a/apps/common/main/lib/controller/ExternalUsers.js b/apps/common/main/lib/controller/ExternalUsers.js index d939a32ded..71b3755a87 100644 --- a/apps/common/main/lib/controller/ExternalUsers.js +++ b/apps/common/main/lib/controller/ExternalUsers.js @@ -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) { diff --git a/apps/common/main/lib/view/ReviewPopover.js b/apps/common/main/lib/view/ReviewPopover.js index a2fc67a327..00bddd2d70 100644 --- a/apps/common/main/lib/view/ReviewPopover.js +++ b/apps/common/main/lib/view/ReviewPopover.js @@ -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 && total0) { - 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' + '
<%= Common.Utils.String.htmlEncode(caption) %>
' +