From d3fe780805f572951f619818920746df1d42466b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 12 Dec 2014 17:58:01 +0100 Subject: [PATCH] fix initial loading limit of user management on large screens --- settings/js/users/users.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 62e18d1be04..d910e1ec129 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -353,10 +353,13 @@ var UserList = { UserDeleteHandler.deleteEntry(); }); }, - update: function (gid) { + update: function (gid, limit) { if (UserList.updating) { return; } + if(!limit) { + limit = UserList.usersToLoad; + } $userList.siblings('.loading').css('visibility', 'visible'); UserList.updating = true; if(gid === undefined) { @@ -366,7 +369,7 @@ var UserList = { var pattern = filter.getPattern(); $.get( OC.generateUrl('/settings/users/users'), - { offset: UserList.offset, limit: UserList.usersToLoad, gid: gid, pattern: pattern }, + { offset: UserList.offset, limit: limit, gid: gid, pattern: pattern }, function (result) { var loadedUsers = 0; var trs = []; @@ -385,6 +388,8 @@ var UserList = { if (result.length > 0) { UserList.doSort(); $userList.siblings('.loading').css('visibility', 'hidden'); + // reset state on load + UserList.noMoreEntries = false; } else { UserList.noMoreEntries = true; @@ -537,7 +542,7 @@ var UserList = { return; } if (UserList.scrollArea.scrollTop() + UserList.scrollArea.height() > UserList.scrollArea.get(0).scrollHeight - 500) { - UserList.update(UserList.currentGid, true); + UserList.update(UserList.currentGid); } }, @@ -770,7 +775,14 @@ $(document).ready(function () { } }); + // calculate initial limit of users to load + var initialUserCountLimit = 20, + containerHeight = $('#app-content').height(); + if(containerHeight > 40) { + initialUserCountLimit = Math.floor(containerHeight/40); + } + // trigger loading of users on startup - UserList.update(UserList.currentGid); + UserList.update(UserList.currentGid, initialUserCountLimit); }); -- 2.39.5