diff --git a/customize.dist/fsStore.js b/customize.dist/fsStore.js index fd86e4dd3..56c4a6977 100644 --- a/customize.dist/fsStore.js +++ b/customize.dist/fsStore.js @@ -98,6 +98,10 @@ define([ return exp; }; + Store.getLoginName = function () { + return storeObj.login_name; + }; + var changeHandlers = Store.changeHandlers = []; Store.change = function (f) { diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 27f9b08a9..19e752e05 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -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'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index cae310dda..f91a81d09 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -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'; diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 77dfddd6f..a3ce2f85e 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -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 = $('', {'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 = $('

'); if (account) { - var $userAccount = $('', {'class': 'userAccount'}).append('Account: ' + accountName); + var $userAccount = $('', {'class': 'userAccount'}).append(Messages.user_accountName + ': ' + accountName); $userAdminContent.append($userAccount); $userAdminContent.append($('
')); } - var $userName = $('', {'class': 'userDisplayName'}).append('Display name: ').append($displayedName.clone()); + var $userName = $('', {'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 = $('', {'class': 'fa fa-user'}); var $button = $('

').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); }); diff --git a/www/pad/main.js b/www/pad/main.js index 845a88a8d..7930e659f 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -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);