From 88d5b4cc9c2562edb600bfefd47132d067c909dd Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 18 Jan 2017 11:00:46 +0100 Subject: [PATCH] Add a 'New pad' button in the toolbar --- customize.dist/src/less/toolbar.less | 2 +- customize.dist/toolbar.css | 2 +- customize.dist/translations/messages.fr.js | 3 +++ customize.dist/translations/messages.js | 3 +++ www/code/main.js | 2 +- www/common/toolbar.js | 25 ++++++++++++++++++++-- www/pad/main.js | 2 +- www/poll/main.js | 2 +- www/slide/main.js | 2 +- 9 files changed, 35 insertions(+), 8 deletions(-) diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less index 49927787a..b85a1d420 100644 --- a/customize.dist/src/less/toolbar.less +++ b/customize.dist/src/less/toolbar.less @@ -300,7 +300,7 @@ } } .buttonTitle { - .fa-user { + .fa:not(.fa-caret-down) { margin-right: 5px; } .account-name { diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css index 86422fea8..ab02c7b41 100644 --- a/customize.dist/toolbar.css +++ b/customize.dist/toolbar.css @@ -370,7 +370,7 @@ .cryptpad-user p.accountData > span span { font-weight: normal; } -.cryptpad-user .buttonTitle .fa-user { +.cryptpad-user .buttonTitle .fa:not(.fa-caret-down) { margin-right: 5px; } .cryptpad-user .buttonTitle .account-name { diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 19e752e05..22d778d14 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -82,6 +82,9 @@ define(function () { out.shareSuccess = 'URL copiée dans le presse-papiers'; out.shareFailed = "Échec de la copie de l'URL dans le presse-papiers"; + out.newPadButton = 'Nouveau'; + out.newPadButtonTitle = 'Créer un nouveau document'; + out.presentButton = 'PRÉSENTER'; out.presentButtonTitle = "Entrer en mode présentation"; out.presentSuccess = 'Appuyer sur Échap pour quitter le mode présentation'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index f91a81d09..9aa315ec1 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -84,6 +84,9 @@ define(function () { out.shareSuccess = 'Copied URL to clipboard'; out.shareFailed = "Failed to copy URL to clipboard"; + out.newPadButton = 'New'; + out.newPadButtonTitle = 'Create a new document'; + out.presentButton = 'PRESENT'; out.presentButtonTitle = "Enter presentation mode"; out.presentSuccess = 'Hit ESC to exit presentation mode'; diff --git a/www/code/main.js b/www/code/main.js index 348fc2ceb..47ac9d919 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -375,7 +375,7 @@ define([ }); var config = { - displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist'], + displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'], userData: userData, readOnly: readOnly, ifrw: ifrw, diff --git a/www/common/toolbar.js b/www/common/toolbar.js index ada2534aa..aeee16456 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -326,9 +326,7 @@ define([ }; var createUserAdmin = function ($topContainer, config, readOnly, lagElement, Cryptpad) { - if (config.displayed.indexOf('useradmin') === -1 && config.displayed.indexOf('share') === -1) { return; } var $lag = $(lagElement); - //TODO check if we should displayed that button and if we can (userName.setName, userName.lastName and userdata required) var $userContainer = $('', { 'class': USER_CLS @@ -349,6 +347,29 @@ define([ Cryptpad.createLanguageSelector($userContainer); } + if (config.displayed.indexOf('newpad') !== -1) { + var pads_options = []; + ['pad', 'code', 'slide', 'poll'].forEach(function (p) { + pads_options.push({ + tag: 'a', + attributes: { + 'target': '_blank', // TODO: open in the same window? + 'href': '/' + p, + }, + content: Messages.type[p] // Pretty name of the language value + }); + }); + var $newButton = $('
').append($('', {'class': 'fa fa-plus'})).append(Messages.newPadButton); + var dropdownConfig = { + text: $newButton.html(), // Button initial text + options: pads_options, // Entries displayed in the menu + left: true, // Open to the left of the button + }; + var $newPadBlock = Cryptpad.createDropdown(dropdownConfig); + $newPadBlock.find('button').attr('title', Messages.newPadButtonTitle); + $newPadBlock.appendTo($userContainer); + } + // User dropdown if (config.displayed.indexOf('useradmin') !== -1) { if (!config.userName || !config.userName.setName || !config.userName.lastName) { diff --git a/www/pad/main.js b/www/pad/main.js index e0a7bc4f8..852ad7cd5 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -568,7 +568,7 @@ define([ }); var config = { - displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist'], + displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'], userData: userData, readOnly: readOnly, ifrw: ifrw, diff --git a/www/poll/main.js b/www/poll/main.js index ab696ecb5..e97935dae 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -652,7 +652,7 @@ define([ }); var config = { - displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist'], + displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'], userData: userData, readOnly: readOnly, title: { diff --git a/www/slide/main.js b/www/slide/main.js index 4becaa0f0..aecc139b1 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -418,7 +418,7 @@ define([ }); var config = { - displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist'], + displayed: ['useradmin', 'language', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad'], userData: userData, readOnly: readOnly, ifrw: ifrw,