Merge branch 'usability1' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
ansuz 8 years ago
commit 901a708be6

@ -45,6 +45,7 @@ define(function () {
out.userButton = 'UTILISATEUR'; out.userButton = 'UTILISATEUR';
out.userButtonTitle = "Changer votre nom d'utilisateur"; out.userButtonTitle = "Changer votre nom d'utilisateur";
out.changeNamePrompt = 'Changer votre nom (laisser vide pour rester anonyme) : ';
out.renameButton = 'RENOMMER'; out.renameButton = 'RENOMMER';
out.renameButtonTitle = 'Changer le titre utilisé par ce document dans la page d\'accueil de Cryptpad'; out.renameButtonTitle = 'Changer le titre utilisé par ce document dans la page d\'accueil de Cryptpad';

@ -45,7 +45,7 @@ define(function () {
out.userButton = 'USER'; out.userButton = 'USER';
out.userButtonTitle = 'Change your username'; out.userButtonTitle = 'Change your username';
out.changeNamePrompt = 'Change your name: '; out.changeNamePrompt = 'Change your name (leave empty to be anonymous): ';
out.renameButton = 'RENAME'; out.renameButton = 'RENAME';
out.renameButtonTitle = 'Change the title under which this document is listed on your home page'; out.renameButtonTitle = 'Change the title under which this document is listed on your home page';

@ -198,6 +198,7 @@ define([
console.error(err); console.error(err);
return; return;
} }
module.userName.lastName = myUserName;
onLocal(); onLocal();
}); });
}; };
@ -321,12 +322,12 @@ 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 */ /* add a "change username" button */
getLastName(function (err, lastName) { getLastName(function (err, lastName) {
var usernameCb = function (newName) { userNameButtonObject.lastName = lastName;
setName (newName); var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName);
};
var $username = Cryptpad.createButton('username', false, {lastName: lastName}, usernameCb);
$userBlock.append($username).hide(); $userBlock.append($username).hide();
}); });
@ -555,6 +556,8 @@ define([
addToUserList(myData); addToUserList(myData);
if (typeof(lastName) === 'string' && lastName.length) { if (typeof(lastName) === 'string' && lastName.length) {
setName(lastName); setName(lastName);
} else {
module.$userNameButton.click();
} }
onLocal(); onLocal();
}); });

@ -719,9 +719,8 @@ define([
title: Messages.userButton + '\n' + Messages.userButtonTitle title: Messages.userButton + '\n' + Messages.userButtonTitle
}).html('<span class="fa fa-user" style="font-family:FontAwesome;"></span>'); }).html('<span class="fa fa-user" style="font-family:FontAwesome;"></span>');
if (data && typeof data.lastName !== "undefined" && callback) { if (data && typeof data.lastName !== "undefined" && callback) {
var lastName = data.lastName;
button.click(function() { button.click(function() {
common.prompt(Messages.changeNamePrompt, lastName, function (newName) { common.prompt(Messages.changeNamePrompt, data.lastName, function (newName) {
callback(newName); callback(newName);
}); });
}); });

@ -291,12 +291,13 @@ define([
name: myUserName name: myUserName
}; };
addToUserList(myData); addToUserList(myData);
editor.fire('change');
Cryptpad.setAttribute('username', newName, function (err, data) { Cryptpad.setAttribute('username', newName, function (err, data) {
if (err) { if (err) {
console.error("Couldn't set username"); console.error("Couldn't set username");
return;
} }
module.userName.lastName = myUserName;
editor.fire('change');
}); });
}; };
@ -535,12 +536,12 @@ 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 */ /* add a "change username" button */
getLastName(function (err, lastName) { getLastName(function (err, lastName) {
var usernameCb = function (newName) { userNameButtonObject.lastName = lastName;
setName (newName); var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName);
};
var $username = Cryptpad.createButton('username', false, {lastName: lastName}, usernameCb);
$userBlock.append($username).hide(); $userBlock.append($username).hide();
}); });
@ -638,6 +639,8 @@ define([
addToUserList(myData); addToUserList(myData);
if (typeof(lastName) === 'string' && lastName.length) { if (typeof(lastName) === 'string' && lastName.length) {
setName(lastName); setName(lastName);
} else {
module.$userNameButton.click();
} }
realtimeOptions.onLocal(); realtimeOptions.onLocal();
}); });

@ -246,6 +246,7 @@ define([
console.error(err); console.error(err);
return; return;
} }
module.userName.lastName = myUserName;
onLocal(); onLocal();
}); });
}; };
@ -398,12 +399,12 @@ 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 */ /* add a "change username" button */
getLastName(function (err, lastName) { getLastName(function (err, lastName) {
var usernameCb = function (newName) { userNameButtonObject.lastName = lastName;
setName (newName); var $username = module.$userNameButton = Cryptpad.createButton('username', false, userNameButtonObject, setName);
};
var $username = Cryptpad.createButton('username', false, {lastName: lastName}, usernameCb);
$userBlock.append($username).hide(); $userBlock.append($username).hide();
}); });
@ -655,6 +656,8 @@ define([
addToUserList(myData); addToUserList(myData);
if (typeof(lastName) === 'string' && lastName.length) { if (typeof(lastName) === 'string' && lastName.length) {
setName(lastName); setName(lastName);
} else {
module.$userNameButton.click();
} }
onLocal(); onLocal();
}); });

Loading…
Cancel
Save