diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js index 872516044..c9e4fa35e 100644 --- a/loleaflet/dist/toolbar/toolbar.js +++ b/loleaflet/dist/toolbar/toolbar.js @@ -468,7 +468,7 @@ $(function () { {type: 'html', id: 'right'}, {type: 'html', id: 'modifiedstatuslabel', html: '
'}, {type: 'break'}, - {type: 'menu', id: 'userlist', caption: _('Users'), items: [ + {type: 'menu', id: 'userlist', caption: _('1 user'), items: [ { id: '-1', text: _('You'), disabled: true }, ]}, {type: 'break'}, @@ -1357,7 +1357,20 @@ function getUserListItem(viewId, userName) { var userListItem = { id: viewId, text: userName, disabled: true }; return userListItem; } +var nUsers = _('%n users'); +function updateUserListCount(userlist) { + var count = userlist.items.length; + if (count > 1) { + userlist.caption = nUsers.replace('%n', count); + } else if (count === 1) { + userlist.caption = '1 user'; + } +} + map.on('addview', function(e) { + if (!e.viewId || !e.username) + return; + $('#tb_toolbar-down_item_userlist') .w2overlay({ class: 'loleaflet-font', @@ -1374,10 +1387,14 @@ map.on('addview', function(e) { var userlist = w2ui['toolbar-down'].get('userlist'); userlist.items.push(getUserListItem(e.viewId, e.username)); + updateUserListCount(userlist); w2ui['toolbar-down'].refresh(); }); map.on('removeview', function(e) { + if (!e.viewId || !e.username) + return; + $('#tb_toolbar-down_item_userlist') .w2overlay({ class: 'loleaflet-font', @@ -1395,9 +1412,11 @@ map.on('removeview', function(e) { for (var idx in userlist.items) { if (userlist.items[idx].id == e.viewId) { userlist.items.splice(idx, 1); + break; } } + updateUserListCount(userlist); w2ui['toolbar-down'].refresh(); });