Add handlers to login and logout buttons

pull/1/head
yflory 8 years ago
parent 767ba8b549
commit efed1f5efe

@ -98,6 +98,10 @@ define([
return exp;
};
Store.getLoginName = function () {
return storeObj.login_name;
};
var changeHandlers = Store.changeHandlers = [];
Store.change = function (f) {

@ -61,6 +61,11 @@ define(function () {
out.userButton = 'UTILISATEUR';
out.userButtonTitle = "Changer votre nom d'utilisateur";
out.changeNamePrompt = 'Changer votre nom (laisser vide pour rester anonyme) : ';
out.user_login = "Connexion";
out.user_logout = "Déconnexion";
out.user_rename = "Changer le nom affiché";
out.user_displayName = "Nom affiché";
out.user_accountName = "Nom d'utilisateur";
out.renameButton = 'RENOMMER';
out.renameButtonTitle = 'Changer le titre utilisé par ce document dans la page d\'accueil de Cryptpad';

@ -63,6 +63,11 @@ define(function () {
out.userButton = 'USER';
out.userButtonTitle = 'Change your username';
out.changeNamePrompt = 'Change your name (leave empty to be anonymous): ';
out.user_login = "Log in";
out.user_logout = "Log out";
out.user_rename = "Change display name";
out.user_displayName = "Display name";
out.user_accountName = "Account name";
out.renameButton = 'RENAME';
out.renameButtonTitle = 'Change the title under which this document is listed on your home page';

@ -38,6 +38,7 @@ define([
var DROPDOWN_CLS = Bar.constants.dropdown = "cryptpad-dropdown";
var TITLE_CLS = Bar.constants.title = "cryptpad-title";
var USER_CLS = Bar.constants.userAdmin = "cryptpad-user";
var USERBUTTON_CLS = Bar.constants.changeUsername = "cryptpad-change-username";
var SPINNER_DISAPPEAR_TIME = 3000;
@ -356,32 +357,37 @@ define([
"and `lastName` (object) if you want to display the user admin menu.")
}
var $displayedName = $('<span>', {'class': USERNAME_CLS});
var accountName = null; //TODO Cryptpad.getStore().getAccountName()
var accountName = Cryptpad.getStore().getLoginName ? Cryptpad.getStore().getLoginName() : null;
var account = typeof accountName === "string";
var $userAdminContent = $('<p>');
if (account) {
var $userAccount = $('<span>', {'class': 'userAccount'}).append('Account: ' + accountName);
var $userAccount = $('<span>', {'class': 'userAccount'}).append(Messages.user_accountName + ': ' + accountName);
$userAdminContent.append($userAccount);
$userAdminContent.append($('<br>'));
}
var $userName = $('<span>', {'class': 'userDisplayName'}).append('Display name: ').append($displayedName.clone());
var $userName = $('<span>', {'class': 'userDisplayName'}).append(Messages.user_displayName + ': ').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'
attributes: {'class': USERBUTTON_CLS},
content: Messages.user_rename
}];
if (account) {
options.push({
tag: 'a',
attributes: {'class': 'logout'},
content: Messages.user_logout
});
} else {
options.push({
tag: 'a',
attributes: {'class': 'login'},
content: Messages.user_login
});
}
var $icon = $('<span>', {'class': 'fa fa-user'});
var $button = $('<div>').append($icon).append($displayedName.clone());
if (account) {
@ -397,9 +403,14 @@ define([
$userAdmin.find('a.logout').click(function (e) {
Cryptpad.logout();
window.location.reload();
});
$userAdmin.find('a.login').click(function (e) {
window.open = '/user';
});
if (config.userName && config.userName.setName && config.userName.lastName) {
$userAdmin.find('a.changeUserName').click(function (e) {
$userAdmin.find('a.' + USERBUTTON_CLS).click(function (e) {
Cryptpad.prompt(Messages.changeNamePrompt, config.userName.lastName.lastName || '', function (newName) {
config.userName.setName(newName);
});

@ -590,6 +590,7 @@ define([
var $userBlock = $bar.find('.' + Toolbar.constants.username);
var $editShare = $bar.find('.' + Toolbar.constants.editShare);
var $viewShare = $bar.find('.' + Toolbar.constants.viewShare);
var $usernameButton = module.$userNameButton = $bar.find('.' + Toolbar.constants.changeUsername);
var editHash;
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);

Loading…
Cancel
Save