diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less index 00c514269..dd8063e01 100644 --- a/customize.dist/src/less/toolbar.less +++ b/customize.dist/src/less/toolbar.less @@ -136,13 +136,14 @@ } } .cryptpad-limit { - box-sizing: content-box; - height: 16px; - width: 16px; + box-sizing: border-box; + height: 26px; + width: 26px; display: inline-block; padding: 3px; - margin: 3px; - margin-right: 6px; + margin: 0px; + margin-right: 3px; + vertical-align: middle; span { color: red; cursor: pointer; @@ -151,24 +152,11 @@ } } - .cryptpad-lag { - box-sizing: content-box; - height: 16px; - width: 16px; - display: inline-block; - padding: 5px; - margin: 3px 0; - div { - margin: auto; - } + .clag () { + background: transparent; } -.clag () { - background: transparent; -} - - - #newLag { + .cryptpad-lag { height: 20px; width: 23px; background: transparent; @@ -439,9 +427,8 @@ .cryptpad-user { position: absolute; right: 0; - span:not(.cryptpad-lag) { + :not(.cryptpad-lag) span { vertical-align: top; - //display: inline-block; } button { span.fa { @@ -501,7 +488,7 @@ border-radius: 5px; } } -.cryptpad-spinner { +.cryptpad-spinner > span { height: 16px; width: 16px; margin: 8px; diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css index 1934d11c4..4689803c4 100644 --- a/customize.dist/toolbar.css +++ b/customize.dist/toolbar.css @@ -215,13 +215,14 @@ font-weight: bold; } .cryptpad-toolbar .cryptpad-limit { - box-sizing: content-box; - height: 16px; - width: 16px; + box-sizing: border-box; + height: 26px; + width: 26px; display: inline-block; padding: 3px; - margin: 3px; - margin-right: 6px; + margin: 0px; + margin-right: 3px; + vertical-align: middle; } .cryptpad-toolbar .cryptpad-limit span { color: red; @@ -230,17 +231,6 @@ font-size: 20px; } .cryptpad-toolbar .cryptpad-lag { - box-sizing: content-box; - height: 16px; - width: 16px; - display: inline-block; - padding: 5px; - margin: 3px 0; -} -.cryptpad-toolbar .cryptpad-lag div { - margin: auto; -} -.cryptpad-toolbar #newLag { height: 20px; width: 23px; background: transparent; @@ -250,7 +240,7 @@ vertical-align: top; box-sizing: content-box; } -.cryptpad-toolbar #newLag span { +.cryptpad-toolbar .cryptpad-lag span { display: inline-block; width: 4px; margin: 0; @@ -261,50 +251,50 @@ border: 1px solid black; transition: background 1s, border 1s; } -.cryptpad-toolbar #newLag span:last-child { +.cryptpad-toolbar .cryptpad-lag span:last-child { margin-right: 0; } -.cryptpad-toolbar #newLag span.bar1 { +.cryptpad-toolbar .cryptpad-lag span.bar1 { height: 5px; } -.cryptpad-toolbar #newLag span.bar2 { +.cryptpad-toolbar .cryptpad-lag span.bar2 { height: 10px; } -.cryptpad-toolbar #newLag span.bar3 { +.cryptpad-toolbar .cryptpad-lag span.bar3 { height: 15px; } -.cryptpad-toolbar #newLag span.bar4 { +.cryptpad-toolbar .cryptpad-lag span.bar4 { height: 20px; } -.cryptpad-toolbar #newLag.lag0 span { +.cryptpad-toolbar .cryptpad-lag.lag0 span { background: transparent; border-color: red; } -.cryptpad-toolbar #newLag.lag1 .bar2, -.cryptpad-toolbar #newLag.lag1 .bar3, -.cryptpad-toolbar #newLag.lag1 .bar4 { +.cryptpad-toolbar .cryptpad-lag.lag1 .bar2, +.cryptpad-toolbar .cryptpad-lag.lag1 .bar3, +.cryptpad-toolbar .cryptpad-lag.lag1 .bar4 { background: transparent; } -.cryptpad-toolbar #newLag.lag1 span { +.cryptpad-toolbar .cryptpad-lag.lag1 span { background-color: orange; border-color: orange; } -.cryptpad-toolbar #newLag.lag2 .bar3, -.cryptpad-toolbar #newLag.lag2 .bar4 { +.cryptpad-toolbar .cryptpad-lag.lag2 .bar3, +.cryptpad-toolbar .cryptpad-lag.lag2 .bar4 { background: transparent; } -.cryptpad-toolbar #newLag.lag2 span { +.cryptpad-toolbar .cryptpad-lag.lag2 span { background-color: orange; border-color: orange; } -.cryptpad-toolbar #newLag.lag3 .bar4 { +.cryptpad-toolbar .cryptpad-lag.lag3 .bar4 { background: transparent; } -.cryptpad-toolbar #newLag.lag3 span { +.cryptpad-toolbar .cryptpad-lag.lag3 span { background-color: #5cb85c; border-color: #5cb85c; } -.cryptpad-toolbar #newLag.lag4 span { +.cryptpad-toolbar .cryptpad-lag.lag4 span { background-color: #5cb85c; border-color: #5cb85c; } @@ -517,7 +507,7 @@ position: absolute; right: 0; } -.cryptpad-toolbar-top .cryptpad-user span:not(.cryptpad-lag) { +.cryptpad-toolbar-top .cryptpad-user :not(.cryptpad-lag) span { vertical-align: top; } .cryptpad-toolbar-top .cryptpad-user button span.fa { @@ -571,7 +561,7 @@ padding: 3px 3px; border-radius: 5px; } -.cryptpad-spinner { +.cryptpad-spinner > span { height: 16px; width: 16px; margin: 8px; diff --git a/www/code/main.js b/www/code/main.js index 35bcd90d4..50ff90aa1 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -3,7 +3,7 @@ define([ '/bower_components/chainpad-crypto/crypto.js', '/bower_components/chainpad-netflux/chainpad-netflux.js', '/bower_components/textpatcher/TextPatcher.js', - '/common/toolbar.js', + '/common/toolbar2.js', 'json.sortify', '/bower_components/chainpad-json-validator/json-ot.js', '/common/cryptpad-common.js', @@ -382,8 +382,12 @@ define([ userList = info.userList; var configTb = { - displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'], - userData: userData, + displayed: ['title', 'useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'], + userList: { + data: userData, + list: userList, + userNetfluxId: info.myID + }, readOnly: readOnly, ifrw: ifrw, share: { @@ -395,9 +399,12 @@ define([ defaultName: defaultName, suggestName: suggestName }, - common: Cryptpad + common: Cryptpad, + realtime: info.realtime, + network: info.network, + $container: $bar }; - toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, userList, configTb); + toolbar = module.toolbar = Toolbar.create(configTb); var $rightside = $bar.find('.' + Toolbar.constants.rightside); var $userBlock = $bar.find('.' + Toolbar.constants.username); diff --git a/www/common/toolbar.js b/www/common/toolbar.js index f8781d073..e64639bc8 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -96,14 +96,14 @@ define([ var createSpinner = function ($container, config) { if (config.displayed.indexOf('spinner') !== -1) { - var $spin = $(''); + var $spin = $('', {'class':SPINNER_CLS}); var $spinner = $('', { id: uid(), - 'class': SPINNER_CLS + ' spin fa fa-spinner fa-pulse', + 'class': 'spin fa fa-spinner fa-pulse', }).appendTo($spin).hide(); $('', { id: uid(), - 'class': SPINNER_CLS + ' synced fa fa-check', + 'class': 'synced fa fa-check', title: Messages.synced }).appendTo($spin); $container.prepend($spin); @@ -388,7 +388,7 @@ define([ 'class': LAG_ELEM_CLS, id: uid(), }); - var $a = $('', {id: 'newLag'}); + var $a = $('', {'class': 'cryptpad-lag', id: 'newLag'}); $('', {'class': 'bar1'}).appendTo($a); $('', {'class': 'bar2'}).appendTo($a); $('', {'class': 'bar3'}).appendTo($a); @@ -407,7 +407,7 @@ define([ var title; var $lag = $(lagElement); if (lag) { - $lag.attr('class', ''); + $lag.attr('class', 'cryptpad-lag'); firstConnection = false; title = Messages.lag + ' : ' + lag + ' ms\n'; if (lag > 30000) { @@ -428,7 +428,7 @@ define([ } } else if (!firstConnection) { - $lag.attr('class', ''); + $lag.attr('class', 'cryptpad-lag'); // Display the red light at the 2nd failed attemp to get the lag lagLight.addClass('lag-red'); title = Messages.redLight; diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js new file mode 100644 index 000000000..2a1ceaeba --- /dev/null +++ b/www/common/toolbar2.js @@ -0,0 +1,907 @@ +define([ + 'jquery', + '/customize/application_config.js', + '/api/config' +], function ($, Config, ApiConfig) { + var Messages = {}; + var Cryptpad; + + var Bar = { + constants: {}, + }; + + var SPINNER_DISAPPEAR_TIME = 3000; + + // Toolbar parts + var TOOLBAR_CLS = Bar.constants.toolbar = 'cryptpad-toolbar'; + var TOP_CLS = Bar.constants.top = 'cryptpad-toolbar-top'; + var LEFTSIDE_CLS = Bar.constants.leftside = 'cryptpad-toolbar-leftside'; + var RIGHTSIDE_CLS = Bar.constants.rightside = 'cryptpad-toolbar-rightside'; + var HISTORY_CLS = Bar.constants.history = 'cryptpad-toolbar-history'; + + // Userlist + var USERLIST_CLS = Bar.constants.userlist = "cryptpad-dropdown-users"; + var EDITSHARE_CLS = Bar.constants.editShare = "cryptpad-dropdown-editShare"; + var VIEWSHARE_CLS = Bar.constants.viewShare = "cryptpad-dropdown-viewShare"; + var SHARE_CLS = Bar.constants.viewShare = "cryptpad-dropdown-share"; + + // Top parts + var USER_CLS = Bar.constants.userAdmin = "cryptpad-user"; + var SPINNER_CLS = Bar.constants.spinner = 'cryptpad-spinner'; + var STATE_CLS = Bar.constants.state = 'cryptpad-state'; + var LAG_CLS = Bar.constants.lag = 'cryptpad-lag'; + var LIMIT_CLS = Bar.constants.lag = 'cryptpad-limit'; + var TITLE_CLS = Bar.constants.title = "cryptpad-title"; + var NEWPAD_CLS = Bar.constants.newpad = "cryptpad-newpad"; + + // User admin menu + var USERADMIN_CLS = Bar.constants.user = 'cryptpad-user-dropdown'; + var USERNAME_CLS = Bar.constants.username = 'cryptpad-toolbar-username'; + var READONLY_CLS = Bar.constants.readonly = 'cryptpad-readonly'; + var USERBUTTON_CLS = Bar.constants.changeUsername = "cryptpad-change-username"; + + // Create the toolbar element + + var uid = function () { + return 'cryptpad-uid-' + String(Math.random()).substring(2); + }; + + var styleToolbar = function ($container, href, version) { + href = href || '/customize/toolbar.css' + (version?('?' + version): ''); + + $.ajax({ + url: href, + dataType: 'text', + success: function (data) { + $container.append($('