Merge pull request #21509 from owncloud/users-scrolltop

Keep scroll position in users page when sorting
This commit is contained in:
Thomas Müller 2016-01-13 11:00:48 +01:00
commit ca4f24aa97
1 changed files with 8 additions and 1 deletions

View File

@ -259,6 +259,10 @@ var UserList = {
} }
}, },
doSort: function() { doSort: function() {
// some browsers like Chrome lose the scrolling information
// when messing with the list elements
var lastScrollTop = this.scrollArea.scrollTop();
var lastScrollLeft = this.scrollArea.scrollLeft();
var rows = $userListBody.find('tr').get(); var rows = $userListBody.find('tr').get();
rows.sort(function(a, b) { rows.sort(function(a, b) {
@ -284,6 +288,8 @@ var UserList = {
if(items.length > 0) { if(items.length > 0) {
$userListBody.append(items); $userListBody.append(items);
} }
this.scrollArea.scrollTop(lastScrollTop);
this.scrollArea.scrollLeft(lastScrollLeft);
}, },
checkUsersToLoad: function() { checkUsersToLoad: function() {
//30 shall be loaded initially, from then on always 10 upon scrolling //30 shall be loaded initially, from then on always 10 upon scrolling
@ -605,10 +611,11 @@ $(document).ready(function () {
// Implements User Search // Implements User Search
OCA.Search.users= new UserManagementFilter(UserList, GroupList); OCA.Search.users= new UserManagementFilter(UserList, GroupList);
UserList.scrollArea = $('#app-content');
UserList.doSort(); UserList.doSort();
UserList.availableGroups = $userList.data('groups'); UserList.availableGroups = $userList.data('groups');
UserList.scrollArea = $('#app-content');
UserList.scrollArea.scroll(function(e) {UserList._onScroll(e);}); UserList.scrollArea.scroll(function(e) {UserList._onScroll(e);});
$userList.after($('<div class="loading" style="height: 200px; visibility: hidden;"></div>')); $userList.after($('<div class="loading" style="height: 200px; visibility: hidden;"></div>'));