Replace the username button by a dropdown menu
This commit is contained in:
@@ -376,7 +376,7 @@
|
|||||||
background: #bbb;
|
background: #bbb;
|
||||||
}
|
}
|
||||||
.dropdown-bar .dropdown-bar-content p {
|
.dropdown-bar .dropdown-bar-content p {
|
||||||
width: 210px;
|
min-width: 160px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
width: 210px;
|
min-width: 160px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0px 6px;
|
padding: 0px 6px;
|
||||||
|
|
||||||
|
.fa {font-family: FontAwesome;}
|
||||||
|
|
||||||
.unselectable;
|
.unselectable;
|
||||||
|
|
||||||
font: normal normal normal 12px Arial,Helvetica,Tahoma,Verdana,Sans-Serif;
|
font: normal normal normal 12px Arial,Helvetica,Tahoma,Verdana,Sans-Serif;
|
||||||
@@ -287,10 +289,17 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.cryptpad-toolbar-username {
|
.fa-user {
|
||||||
line-height: 32px;
|
margin-right: 5px;
|
||||||
button {
|
}
|
||||||
line-height: initial;
|
.cryptpad-user {
|
||||||
|
.buttonTitle {
|
||||||
|
.fa-user {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
.cryptpad-toolbar-username {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.lag {
|
.lag {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
background: #bbb;
|
background: #bbb;
|
||||||
}
|
}
|
||||||
.dropdown-bar .dropdown-bar-content p {
|
.dropdown-bar .dropdown-bar-content p {
|
||||||
width: 210px;
|
min-width: 160px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
@@ -103,6 +103,9 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 9001;
|
z-index: 9001;
|
||||||
}
|
}
|
||||||
|
.cryptpad-toolbar .fa {
|
||||||
|
font-family: FontAwesome;
|
||||||
|
}
|
||||||
.cryptpad-toolbar a {
|
.cryptpad-toolbar a {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
@@ -357,11 +360,14 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
.cryptpad-toolbar-username {
|
.fa-user {
|
||||||
line-height: 32px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
.cryptpad-toolbar-username button {
|
.cryptpad-user .buttonTitle .fa-user {
|
||||||
line-height: initial;
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
.cryptpad-user .buttonTitle .cryptpad-toolbar-username {
|
||||||
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
.lag {
|
.lag {
|
||||||
height: 15px !important;
|
height: 15px !important;
|
||||||
|
|||||||
@@ -366,6 +366,14 @@ define([
|
|||||||
|
|
||||||
var onInit = config.onInit = function (info) {
|
var onInit = config.onInit = function (info) {
|
||||||
userList = info.userList;
|
userList = info.userList;
|
||||||
|
|
||||||
|
module.userName = {};
|
||||||
|
// The lastName is stored in an object passed to the toolbar so that when the user clicks on
|
||||||
|
// the "change display name" button, the prompt already knows his current name
|
||||||
|
getLastName(function (err, lastName) {
|
||||||
|
module.userName.lastName = lastName;
|
||||||
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
userData: userData,
|
userData: userData,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
@@ -375,6 +383,10 @@ define([
|
|||||||
defaultName: defaultName,
|
defaultName: defaultName,
|
||||||
suggestName: suggestName
|
suggestName: suggestName
|
||||||
},
|
},
|
||||||
|
userName: {
|
||||||
|
setName: setName,
|
||||||
|
lastName: module.userName
|
||||||
|
},
|
||||||
common: Cryptpad
|
common: Cryptpad
|
||||||
};
|
};
|
||||||
if (readOnly) {delete config.changeNameID; }
|
if (readOnly) {delete config.changeNameID; }
|
||||||
@@ -392,15 +404,6 @@ define([
|
|||||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the object sent for the "change username" button so that we can update the field value correctly
|
|
||||||
var userNameButtonObject = module.userName = {};
|
|
||||||
/* add a "change username" button */
|
|
||||||
getLastName(function (err, lastName) {
|
|
||||||
userNameButtonObject.lastName = lastName;
|
|
||||||
var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName).hide();
|
|
||||||
$userBlock.append($username);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* add an export button */
|
/* add an export button */
|
||||||
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
||||||
$rightside.append($export);
|
$rightside.append($export);
|
||||||
|
|||||||
@@ -984,7 +984,9 @@ define([
|
|||||||
return $container;
|
return $container;
|
||||||
};
|
};
|
||||||
|
|
||||||
var createLanguageSelector = common.createLanguageSelector = function ($container, $block) {
|
// Provide $container if you want to put the generated block in another element
|
||||||
|
// Provide $initBlock if you already have the menu block and you want the content inserted in it
|
||||||
|
var createLanguageSelector = common.createLanguageSelector = function ($container, $initBlock) {
|
||||||
var options = [];
|
var options = [];
|
||||||
var languages = Messages._languages;
|
var languages = Messages._languages;
|
||||||
for (var l in languages) {
|
for (var l in languages) {
|
||||||
@@ -1002,7 +1004,7 @@ define([
|
|||||||
text: Messages.language, // Button initial text
|
text: Messages.language, // Button initial text
|
||||||
options: options, // Entries displayed in the menu
|
options: options, // Entries displayed in the menu
|
||||||
left: true, // Open to the left of the button
|
left: true, // Open to the left of the button
|
||||||
container: $block // optional
|
container: $initBlock // optional
|
||||||
};
|
};
|
||||||
var $block = createDropdown(dropdownConfig);
|
var $block = createDropdown(dropdownConfig);
|
||||||
$block.attr('id', 'language-selector');
|
$block.attr('id', 'language-selector');
|
||||||
|
|||||||
@@ -233,16 +233,18 @@ define([
|
|||||||
var $userElement = $userAdminElement.find('.' + USERNAME_CLS);
|
var $userElement = $userAdminElement.find('.' + USERNAME_CLS);
|
||||||
$userElement.show();
|
$userElement.show();
|
||||||
if (readOnly === 1) {
|
if (readOnly === 1) {
|
||||||
$userElement.html('<span class="' + READONLY_CLS + '">' + Messages.readonly + '</span>');
|
//$userElement.html('<span class="' + READONLY_CLS + '">' + Messages.readonly + '</span>');
|
||||||
|
$userElement.addClass('ro').text(Messages.readonly);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var name = userData[myUserName] && userData[myUserName].name;
|
var name = userData[myUserName] && userData[myUserName].name;
|
||||||
var icon = '<span class="fa fa-user" style="font-family:FontAwesome;"></span>';
|
//var icon = '<span class="fa fa-user" style="font-family:FontAwesome;"></span>';
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = Messages.anonymous;
|
name = Messages.anonymous;
|
||||||
}
|
}
|
||||||
$userElement.find("button").show();
|
// $userElement.find("button").show();
|
||||||
$userElement.find("button").html(icon + ' ' + name);
|
// $userElement.find("button").html(icon + ' ' + name);
|
||||||
|
$userElement.removeClass('ro').text(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -318,8 +320,9 @@ define([
|
|||||||
$linkContainer.append($aTagSmall).append($aTagBig);
|
$linkContainer.append($aTagSmall).append($aTagBig);
|
||||||
};
|
};
|
||||||
|
|
||||||
var createUserAdmin = function ($topContainer, lagElement, Cryptpad) {
|
var createUserAdmin = function ($topContainer, config, lagElement, Cryptpad) {
|
||||||
var $lag = $(lagElement);
|
var $lag = $(lagElement);
|
||||||
|
//TODO check if we should displayed that button and if we can (userName.setName, userName.lastName and userdata required)
|
||||||
|
|
||||||
var $userContainer = $('<span>', {
|
var $userContainer = $('<span>', {
|
||||||
'class': USER_CLS
|
'class': USER_CLS
|
||||||
@@ -334,7 +337,57 @@ define([
|
|||||||
// Dropdown language selector
|
// Dropdown language selector
|
||||||
Cryptpad.createLanguageSelector($userContainer);
|
Cryptpad.createLanguageSelector($userContainer);
|
||||||
|
|
||||||
var $usernameElement = $('<span>', {'class': USERNAME_CLS}).appendTo($userContainer);
|
// User dropdown
|
||||||
|
var $displayedName = $('<span>', {'class': USERNAME_CLS});
|
||||||
|
var accountName = null; //TODO Cryptpad.getStore().getAccountName()
|
||||||
|
var account = typeof accountName === "string";
|
||||||
|
var $userAdminContent = $('<p>');
|
||||||
|
if (account) {
|
||||||
|
var $userAccount = $('<span>', {'class': 'userAccount'}).append('Account: ' + accountName);
|
||||||
|
$userAdminContent.append($userAccount);
|
||||||
|
$userAdminContent.append($('<br>'));
|
||||||
|
}
|
||||||
|
var $userName = $('<span>', {'class': 'userDisplayName'}).append('Display name: ').append($displayedName.clone());
|
||||||
|
$userAdminContent.append($userName);
|
||||||
|
var options = [{
|
||||||
|
tag: 'p',
|
||||||
|
content: $userAdminContent.html()
|
||||||
|
}, {
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {'class': 'changeUserName'},
|
||||||
|
content: 'Change username'
|
||||||
|
}, {
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {'class': 'login'}, //TODO
|
||||||
|
content: 'Login'
|
||||||
|
}, {
|
||||||
|
tag: 'a',
|
||||||
|
attributes: {'class': 'logout'}, //TODO
|
||||||
|
content: 'Logout'
|
||||||
|
}];
|
||||||
|
var $icon = $('<span>', {'class': 'fa fa-user'});
|
||||||
|
var $button = $('<div>').append($icon).append($displayedName.clone());
|
||||||
|
if (account) {
|
||||||
|
$button.append('(' + accountName + ')');
|
||||||
|
}
|
||||||
|
var dropdownConfig = {
|
||||||
|
text: $button.html(), // Button initial text
|
||||||
|
options: options, // Entries displayed in the menu
|
||||||
|
left: true, // Open to the left of the button
|
||||||
|
};
|
||||||
|
var $userAdmin = Cryptpad.createDropdown(dropdownConfig);
|
||||||
|
$userContainer.append($userAdmin);
|
||||||
|
|
||||||
|
$userAdmin.find('a.logout').click(function (e) {
|
||||||
|
Cryptpad.logout();
|
||||||
|
});
|
||||||
|
if (config.userName && config.userName.setName && config.userName.lastName) {
|
||||||
|
$userAdmin.find('a.changeUserName').click(function (e) {
|
||||||
|
Cryptpad.prompt(Messages.changeNamePrompt, config.userName.lastName.lastName || '', function (newName) {
|
||||||
|
config.userName.setName(newName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return $userContainer;
|
return $userContainer;
|
||||||
};
|
};
|
||||||
@@ -427,7 +480,7 @@ define([
|
|||||||
var $titleElement = createTitle(toolbar.find('.' + TOP_CLS), readOnly, config.title, Cryptpad);
|
var $titleElement = createTitle(toolbar.find('.' + TOP_CLS), readOnly, config.title, Cryptpad);
|
||||||
var $linkElement = createLinkToMain(toolbar.find('.' + TOP_CLS));
|
var $linkElement = createLinkToMain(toolbar.find('.' + TOP_CLS));
|
||||||
var lagElement = createLagElement();
|
var lagElement = createLagElement();
|
||||||
var $userAdminElement = createUserAdmin(toolbar.find('.' + TOP_CLS), lagElement, Cryptpad);
|
var $userAdminElement = createUserAdmin(toolbar.find('.' + TOP_CLS), config, lagElement, Cryptpad);
|
||||||
var spinner = createSpinner($userAdminElement);
|
var spinner = createSpinner($userAdminElement);
|
||||||
var userData = config.userData;
|
var userData = config.userData;
|
||||||
// readOnly = 1 (readOnly enabled), 0 (disabled), -1 (old pad without readOnly mode)
|
// readOnly = 1 (readOnly enabled), 0 (disabled), -1 (old pad without readOnly mode)
|
||||||
@@ -465,14 +518,11 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update user list
|
// Update user list
|
||||||
if (config.userData) {
|
if (userData) {
|
||||||
userList.change.push(function (newUserData) {
|
userList.change.push(function (newUserData) {
|
||||||
var users = userList.users;
|
var users = userList.users;
|
||||||
if (users.indexOf(myUserName) !== -1) { connected = true; }
|
if (users.indexOf(myUserName) !== -1) { connected = true; }
|
||||||
if (!connected) { return; }
|
if (!connected) { return; }
|
||||||
/*if (newUserData) { // Someone has changed his name/color
|
|
||||||
userData = newUserData;
|
|
||||||
}*/
|
|
||||||
checkSynchronizing(users, myUserName, $stateElement);
|
checkSynchronizing(users, myUserName, $stateElement);
|
||||||
updateUserList(myUserName, userListElement, users, userData, readOnly, $userAdminElement);
|
updateUserList(myUserName, userListElement, users, userData, readOnly, $userAdminElement);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -152,40 +152,16 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var setName = APP.setName = function (newName) {
|
|
||||||
if (typeof(newName) !== 'string') { return; }
|
|
||||||
var myUserNameTemp = Cryptpad.fixHTML(newName.trim());
|
|
||||||
if(myUserNameTemp.length > 32) {
|
|
||||||
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
||||||
}
|
|
||||||
var myUserName = myUserNameTemp;
|
|
||||||
Cryptpad.setAttribute('username', myUserName, function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
logError("Couldn't set username", err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
APP.userName.lastName = myUserName;
|
|
||||||
var $button = APP.$userNameButton;
|
|
||||||
var $span = $('<div>').append($button.find('span').clone()).html();
|
|
||||||
$button.html($span + myUserName);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var $userBlock = APP.$bar.find('.' + Toolbar.constants.username);
|
|
||||||
|
|
||||||
// Store the object sent for the "change username" button so that we can update the field value correctly
|
// Store the object sent for the "change username" button so that we can update the field value correctly
|
||||||
var userNameButtonObject = APP.userName = {};
|
var userNameButtonObject = APP.userName = {};
|
||||||
/* add a "change username" button */
|
/* add a "change username" button */
|
||||||
if (!APP.readOnly) {
|
if (!APP.readOnly) {
|
||||||
getLastName(function (err, lastName) {
|
getLastName(function (err, lastName) {
|
||||||
userNameButtonObject.lastName = lastName;
|
APP.userName.lastName = lastName;
|
||||||
var $username = APP.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName).hide();
|
APP.$displayName.text(lastName);
|
||||||
$userBlock.append($username);
|
|
||||||
$username.append(lastName);
|
|
||||||
$username.show();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$userBlock.html('<span class="' + Toolbar.constants.readonly + '">' + Messages.readonly + '</span>');
|
APP.$displayName.html('<span class="' + Toolbar.constants.readonly + '">' + Messages.readonly + '</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE MANAGER
|
// FILE MANAGER
|
||||||
@@ -1703,6 +1679,23 @@ define([
|
|||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var setName = APP.setName = function (newName) {
|
||||||
|
if (typeof(newName) !== 'string') { return; }
|
||||||
|
var myUserNameTemp = Cryptpad.fixHTML(newName.trim());
|
||||||
|
if(myUserNameTemp.length > 32) {
|
||||||
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
||||||
|
}
|
||||||
|
var myUserName = myUserNameTemp;
|
||||||
|
Cryptpad.setAttribute('username', myUserName, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
logError("Couldn't set username", err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APP.userName.lastName = myUserName;
|
||||||
|
APP.$displayName.text(myUserName);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// don't initialize until the store is ready.
|
// don't initialize until the store is ready.
|
||||||
Cryptpad.ready(function () {
|
Cryptpad.ready(function () {
|
||||||
var storeObj = Cryptpad.getStore().getProxy && Cryptpad.getStore().getProxy().proxy ? Cryptpad.getStore().getProxy() : undefined;
|
var storeObj = Cryptpad.getStore().getProxy && Cryptpad.getStore().getProxy().proxy ? Cryptpad.getStore().getProxy() : undefined;
|
||||||
@@ -1752,17 +1745,23 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
var userList = APP.userList = info.userList;
|
var userList = APP.userList = info.userList;
|
||||||
|
APP.userName = {};
|
||||||
var config = {
|
var config = {
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
ifrw: window,
|
ifrw: window,
|
||||||
common: Cryptpad,
|
common: Cryptpad,
|
||||||
|
userName: {
|
||||||
|
setName: setName,
|
||||||
|
lastName: APP.userName
|
||||||
|
},
|
||||||
hideShare: true
|
hideShare: true
|
||||||
};
|
};
|
||||||
var toolbar = APP.toolbar = info.realtime.toolbar = Toolbar.create(APP.$bar, info.myID, info.realtime, info.getLag, userList, config);
|
var toolbar = APP.toolbar = info.realtime.toolbar = Toolbar.create(APP.$bar, info.myID, info.realtime, info.getLag, userList, config);
|
||||||
|
|
||||||
var $bar = APP.$bar;
|
var $bar = APP.$bar;
|
||||||
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
||||||
var $userBlock = $bar.find('.' + Toolbar.constants.username);
|
var $userBlock = $bar.find('.' + Toolbar.constants.userAdmin);
|
||||||
|
APP.$displayName = $bar.find('.' + Toolbar.constants.username);
|
||||||
|
|
||||||
if (APP.homePageIframe) {
|
if (APP.homePageIframe) {
|
||||||
var $linkToMain = $bar.find('.cryptpad-link a');
|
var $linkToMain = $bar.find('.cryptpad-link a');
|
||||||
|
|||||||
@@ -559,6 +559,14 @@ define([
|
|||||||
|
|
||||||
var onInit = realtimeOptions.onInit = function (info) {
|
var onInit = realtimeOptions.onInit = function (info) {
|
||||||
userList = info.userList;
|
userList = info.userList;
|
||||||
|
|
||||||
|
module.userName = {};
|
||||||
|
// The lastName is stored in an object passed to the toolbar so that when the user clicks on
|
||||||
|
// the "change display name" button, the prompt already knows his current name
|
||||||
|
getLastName(function (err, lastName) {
|
||||||
|
module.userName.lastName = lastName;
|
||||||
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
userData: userData,
|
userData: userData,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
@@ -568,6 +576,10 @@ define([
|
|||||||
defaultName: defaultName,
|
defaultName: defaultName,
|
||||||
suggestName: suggestName
|
suggestName: suggestName
|
||||||
},
|
},
|
||||||
|
userName: {
|
||||||
|
setName: setName,
|
||||||
|
lastName: module.userName
|
||||||
|
},
|
||||||
common: Cryptpad
|
common: Cryptpad
|
||||||
};
|
};
|
||||||
if (readOnly) {delete config.changeNameID; }
|
if (readOnly) {delete config.changeNameID; }
|
||||||
@@ -585,14 +597,7 @@ define([
|
|||||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the object sent for the "change username" button so that we can update the field value correctly
|
|
||||||
var userNameButtonObject = module.userName = {};
|
|
||||||
/* add a "change username" button */
|
|
||||||
getLastName(function (err, lastName) {
|
|
||||||
userNameButtonObject.lastName = lastName;
|
|
||||||
var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName).hide();
|
|
||||||
$userBlock.append($username);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* add an export button */
|
/* add an export button */
|
||||||
var $export = Cryptpad.createButton('export', true, {}, exportFile);
|
var $export = Cryptpad.createButton('export', true, {}, exportFile);
|
||||||
|
|||||||
@@ -643,6 +643,14 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
userList = APP.userList = info.userList;
|
userList = APP.userList = info.userList;
|
||||||
|
|
||||||
|
APP.userName = {};
|
||||||
|
// The lastName is stored in an object passed to the toolbar so that when the user clicks on
|
||||||
|
// the "change display name" button, the prompt already knows his current name
|
||||||
|
getLastName(function (err, lastName) {
|
||||||
|
APP.userName.lastName = lastName;
|
||||||
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
userData: userData,
|
userData: userData,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
@@ -651,6 +659,10 @@ define([
|
|||||||
defaultName: defaultName,
|
defaultName: defaultName,
|
||||||
suggestName: suggestName
|
suggestName: suggestName
|
||||||
},
|
},
|
||||||
|
userName: {
|
||||||
|
setName: setName,
|
||||||
|
lastName: APP.userName
|
||||||
|
},
|
||||||
ifrw: window,
|
ifrw: window,
|
||||||
common: Cryptpad,
|
common: Cryptpad,
|
||||||
};
|
};
|
||||||
@@ -662,15 +674,6 @@ define([
|
|||||||
var $editShare = $bar.find('.' + Toolbar.constants.editShare);
|
var $editShare = $bar.find('.' + Toolbar.constants.editShare);
|
||||||
var $viewShare = $bar.find('.' + Toolbar.constants.viewShare);
|
var $viewShare = $bar.find('.' + Toolbar.constants.viewShare);
|
||||||
|
|
||||||
// Store the object sent for the "change username" button so that we can update the field value correctly
|
|
||||||
var userNameButtonObject = APP.userName = {};
|
|
||||||
/* add a "change username" button */
|
|
||||||
getLastName(function (err, lastName) {
|
|
||||||
userNameButtonObject.lastName = lastName;
|
|
||||||
var $username = APP.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName).hide();
|
|
||||||
$userBlock.append($username);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* add a forget button */
|
/* add a forget button */
|
||||||
var forgetCb = function (err, title) {
|
var forgetCb = function (err, title) {
|
||||||
if (err) { return; }
|
if (err) { return; }
|
||||||
|
|||||||
@@ -409,6 +409,14 @@ define([
|
|||||||
|
|
||||||
var onInit = config.onInit = function (info) {
|
var onInit = config.onInit = function (info) {
|
||||||
userList = info.userList;
|
userList = info.userList;
|
||||||
|
|
||||||
|
module.userName = {};
|
||||||
|
// The lastName is stored in an object passed to the toolbar so that when the user clicks on
|
||||||
|
// the "change display name" button, the prompt already knows his current name
|
||||||
|
getLastName(function (err, lastName) {
|
||||||
|
module.userName.lastName = lastName;
|
||||||
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
userData: userData,
|
userData: userData,
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
@@ -418,6 +426,10 @@ define([
|
|||||||
defaultName: defaultName,
|
defaultName: defaultName,
|
||||||
suggestName: suggestName
|
suggestName: suggestName
|
||||||
},
|
},
|
||||||
|
userName: {
|
||||||
|
setName: setName,
|
||||||
|
lastName: module.userName
|
||||||
|
},
|
||||||
common: Cryptpad
|
common: Cryptpad
|
||||||
};
|
};
|
||||||
if (readOnly) {delete config.changeNameID; }
|
if (readOnly) {delete config.changeNameID; }
|
||||||
@@ -435,15 +447,6 @@ define([
|
|||||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the object sent for the "change username" button so that we can update the field value correctly
|
|
||||||
var userNameButtonObject = module.userName = {};
|
|
||||||
/* add a "change username" button */
|
|
||||||
getLastName(function (err, lastName) {
|
|
||||||
userNameButtonObject.lastName = lastName;
|
|
||||||
var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName).hide();
|
|
||||||
$userBlock.append($username);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* add an export button */
|
/* add an export button */
|
||||||
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
||||||
$rightside.append($export);
|
$rightside.append($export);
|
||||||
|
|||||||
Reference in New Issue
Block a user