|
|
@ -1,6 +1,7 @@
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/customize/messages.js',
|
|
|
|
'/bower_components/jquery/dist/jquery.min.js',
|
|
|
|
'/bower_components/jquery/dist/jquery.min.js',
|
|
|
|
|
|
|
|
'/bower_components/bootstrap/js/dropdown.js',
|
|
|
|
], function (Messages) {
|
|
|
|
], function (Messages) {
|
|
|
|
var $ = window.jQuery;
|
|
|
|
var $ = window.jQuery;
|
|
|
|
|
|
|
|
|
|
|
@ -95,19 +96,17 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var getOtherUsers = function(myUserName, userList, userData) {
|
|
|
|
var getOtherUsers = function(myUserName, userList, userData) {
|
|
|
|
var i = 0;
|
|
|
|
var i = 0;
|
|
|
|
var list = '';
|
|
|
|
var list = [];
|
|
|
|
userList.forEach(function(user) {
|
|
|
|
userList.forEach(function(user) {
|
|
|
|
if(user !== myUserName) {
|
|
|
|
if(user !== myUserName) {
|
|
|
|
var data = (userData) ? (userData[user] || null) : null;
|
|
|
|
var data = (userData) ? (userData[user] || null) : null;
|
|
|
|
var userName = (data) ? data.name : null;
|
|
|
|
var userName = (data) ? data.name : null;
|
|
|
|
if(userName) {
|
|
|
|
if(userName) {
|
|
|
|
if(i === 0) { list = ' : '; }
|
|
|
|
list.push(userName);
|
|
|
|
list += userName + ', ';
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return (i > 0) ? list.slice(0, -2) : list;
|
|
|
|
return list;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var arrayIntersect = function(a, b) {
|
|
|
|
var arrayIntersect = function(a, b) {
|
|
|
@ -131,34 +130,48 @@ define([
|
|
|
|
userList = readOnly === -1 ? userList : arrayIntersect(userList, Object.keys(userData));
|
|
|
|
userList = readOnly === -1 ? userList : arrayIntersect(userList, Object.keys(userData));
|
|
|
|
var innerHTML;
|
|
|
|
var innerHTML;
|
|
|
|
var numberOfViewUsers = numberOfUsers - userList.length;
|
|
|
|
var numberOfViewUsers = numberOfUsers - userList.length;
|
|
|
|
|
|
|
|
var editUsersNames = getOtherUsers(myUserName, userList, userData);
|
|
|
|
|
|
|
|
var editTitle = Messages.editUsersIcon;
|
|
|
|
|
|
|
|
var anonymous = numberOfUsers - editUsersNames.length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Display the user list in the title property of the "edit users" icon.
|
|
|
|
|
|
|
|
if (readOnly === 0) {
|
|
|
|
|
|
|
|
editTitle += '\n' + Messages.yourself;
|
|
|
|
|
|
|
|
anonymous--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (editUsersNames.length > 0) {
|
|
|
|
|
|
|
|
editTitle += '\n' + editUsersNames.join('\n');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anonymous > 0) {
|
|
|
|
|
|
|
|
var text = anonymous === 1 ? Messages.anonymousUser : Messages.anonymousUsers;
|
|
|
|
|
|
|
|
editTitle += '\n' + anonymous + " " + text;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $editIcon = $('<button>', {
|
|
|
|
|
|
|
|
'class': 'fa fa-users',
|
|
|
|
|
|
|
|
style: 'font-family: FontAwesome;',
|
|
|
|
|
|
|
|
title: editTitle
|
|
|
|
|
|
|
|
}).text(' ' + userList.length + ' people editing');
|
|
|
|
|
|
|
|
var $viewIcon = $('<span>', {
|
|
|
|
|
|
|
|
disabled: 'disabled',
|
|
|
|
|
|
|
|
'class': 'fa fa-eye',
|
|
|
|
|
|
|
|
style: 'font-family: FontAwesome',
|
|
|
|
|
|
|
|
title: Messages.viewUsersIcon
|
|
|
|
|
|
|
|
}).text(' ' + numberOfViewUsers + ' people viewing');
|
|
|
|
|
|
|
|
var innerHTML;
|
|
|
|
if (readOnly === 1) {
|
|
|
|
if (readOnly === 1) {
|
|
|
|
innerHTML = '<span class="' + READONLY_CLS + '">' + Messages.readonly + '</span>';
|
|
|
|
innerHTML = '<span class="' + READONLY_CLS + '">' + Messages.readonly + '</span>';
|
|
|
|
if (userList.length === 0) {
|
|
|
|
|
|
|
|
innerHTML += Messages.nobodyIsEditing;
|
|
|
|
|
|
|
|
} else if (userList.length === 1) {
|
|
|
|
|
|
|
|
innerHTML += Messages.onePersonIsEditing + getOtherUsers(myUserName, userList, userData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
innerHTML += Messages._getKey('peopleAreEditing', [userList.length]) + getOtherUsers(myUserName, userList, userData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the current user
|
|
|
|
|
|
|
|
numberOfViewUsers--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (userList.length === 1) {
|
|
|
|
|
|
|
|
innerHTML = Messages.editingAlone;
|
|
|
|
|
|
|
|
} else if (userList.length === 2) {
|
|
|
|
|
|
|
|
innerHTML = Messages.editingWithOneOtherPerson + getOtherUsers(myUserName, userList, userData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
innerHTML = Messages.editingWith + ' ' + (userList.length - 1) + ' ' + Messages.otherPeople + getOtherUsers(myUserName, userList, userData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
innerHTML += getViewers(numberOfViewUsers);
|
|
|
|
else {
|
|
|
|
if (userData[myUserName]) {
|
|
|
|
var name = userData[myUserName] && userData[myUserName].name;
|
|
|
|
var name = userData[myUserName].name;
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
if (!name) {
|
|
|
|
name = '<span title="' + Messages.anonymous + '" class="fa fa-user-secret" style="font-family:FontAwesome"></span>';
|
|
|
|
name = '<span title="' + Messages.anonymous + '" class="fa fa-user-secret" style="font-family:FontAwesome"></span>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
innerHTML = '<span class="' + USERNAME_CLS + '">' + name + '</span> | ' + innerHTML;
|
|
|
|
innerHTML = '<span class="' + USERNAME_CLS + '">' + name + '</span> | ';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
innerHTML += $('<div>').append($editIcon).html();
|
|
|
|
|
|
|
|
if (readOnly !== -1) {
|
|
|
|
|
|
|
|
innerHTML += ' | ' + $('<div>').append($viewIcon).html();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
listElement.innerHTML = innerHTML;
|
|
|
|
listElement.innerHTML = innerHTML;
|
|
|
|
};
|
|
|
|
};
|
|
|
|