diff --git a/customize.dist/main.css b/customize.dist/main.css index 0f2de7ab9..6ec0172ea 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -577,7 +577,7 @@ html.cp, font-size: .875em; background-color: #fafafa; color: #555; - font-family: Georgia,Cambria,serif; + font-family: Ubuntu,Georgia,Cambria,serif; height: 100%; } .cp { @@ -1090,6 +1090,48 @@ html.cp, color: #FA5858; cursor: pointer !important; } +/* Pin limit */ +.limit-container .cryptpad-limit-bar { + display: inline-block; + height: 26px; + width: 200px; + margin: 2px; + box-sizing: border-box; + border: 1px solid #999; + background: white; + position: relative; + text-align: center; + line-height: 24px; + vertical-align: middle; +} +.limit-container .cryptpad-limit-bar .usage { + height: 24px; + display: inline-block; + background: blue; + position: absolute; + left: 0; + z-index: 1; +} +.limit-container .cryptpad-limit-bar .usage.normal { + background: #5cb85c; +} +.limit-container .cryptpad-limit-bar .usage.warning { + background: orange; +} +.limit-container .cryptpad-limit-bar .usage.above { + background: red; +} +.limit-container .cryptpad-limit-bar .usageText { + position: relative; + color: black; + text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white; + z-index: 2; + font-size: 16px; + font-weight: bold; +} +.limit-container .upgrade { + margin-left: 10px; +} #cors-store { display: none; } diff --git a/customize.dist/src/less/cryptpad.less b/customize.dist/src/less/cryptpad.less index db8af27ce..883e62ce4 100644 --- a/customize.dist/src/less/cryptpad.less +++ b/customize.dist/src/less/cryptpad.less @@ -8,12 +8,14 @@ @import "./topbar.less"; @import "./footer.less"; +@toolbar-green: #5cb85c; + html.cp, .cp body { font-size: .875em; background-color: @page-white; //@base; color: @fore; - font-family: Georgia,Cambria,serif; + font-family: Ubuntu,Georgia,Cambria,serif; height: 100%; } @@ -536,6 +538,51 @@ noscript { } } +/* Pin limit */ +.limit-container { + .cryptpad-limit-bar { + display: inline-block; + height: 26px; + width: 200px; + margin: 2px; + box-sizing: border-box; + border: 1px solid #999; + background: white; + position: relative; + text-align: center; + line-height: 24px; + vertical-align: middle; + .usage { + height: 24px; + display: inline-block; + background: blue; + position: absolute; + left: 0; + z-index:1; + &.normal { + background: @toolbar-green; + } + &.warning { + background: orange; + } + &.above { + background: red; + } + } + .usageText { + position: relative; + color: black; + text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white; + z-index: 2; + font-size: 16px; + font-weight: bold; + } + } + .upgrade { + margin-left: 10px; + } +} + // hack for our cross-origin iframe #cors-store { display: none; diff --git a/customize.dist/src/less/toolbar.less b/customize.dist/src/less/toolbar.less index 15ab91911..c216e2835 100644 --- a/customize.dist/src/less/toolbar.less +++ b/customize.dist/src/less/toolbar.less @@ -105,43 +105,6 @@ vertical-align: top; margin-left: 10px; } - .cryptpad-drive-limit { - display: inline-block; - height: 26px; - width: 200px; - margin: 2px; - box-sizing: border-box; - border: 1px solid #999; - background: white; - position: relative; - text-align: center; - line-height: 24px; - .usage { - height: 24px; - display: inline-block; - background: blue; - position: absolute; - left: 0; - z-index:1; - &.normal { - background: @toolbar-green; - } - &.warning { - background: orange; - } - &.above { - background: red; - } - } - .usageText { - position: relative; - color: black; - text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white; - z-index: 2; - font-size: 16px; - font-weight: bold; - } - } .cryptpad-limit { box-sizing: border-box; height: 26px; diff --git a/customize.dist/toolbar.css b/customize.dist/toolbar.css index 3d7e0df0b..2b80dc69c 100644 --- a/customize.dist/toolbar.css +++ b/customize.dist/toolbar.css @@ -183,43 +183,6 @@ vertical-align: top; margin-left: 10px; } -.cryptpad-toolbar .cryptpad-drive-limit { - display: inline-block; - height: 26px; - width: 200px; - margin: 2px; - box-sizing: border-box; - border: 1px solid #999; - background: white; - position: relative; - text-align: center; - line-height: 24px; -} -.cryptpad-toolbar .cryptpad-drive-limit .usage { - height: 24px; - display: inline-block; - background: blue; - position: absolute; - left: 0; - z-index: 1; -} -.cryptpad-toolbar .cryptpad-drive-limit .usage.normal { - background: #5cb85c; -} -.cryptpad-toolbar .cryptpad-drive-limit .usage.warning { - background: orange; -} -.cryptpad-toolbar .cryptpad-drive-limit .usage.above { - background: red; -} -.cryptpad-toolbar .cryptpad-drive-limit .usageText { - position: relative; - color: black; - text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white; - z-index: 2; - font-size: 16px; - font-weight: bold; -} .cryptpad-toolbar .cryptpad-limit { box-sizing: border-box; height: 26px; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index a5ca2907e..c6c396c00 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -772,6 +772,50 @@ define([ common.getPinnedUsage(todo); }; + var LIMIT_REFRESH_RATE = 30000; // milliseconds + common.createUsageBar = function (cb) { + var todo = function (err, state, data) { + var $container = $('', {'class':'limit-container'}); + if (!data) { + return void window.setTimeout(function () { + Cryptpad.isOverPinLimit(todo); + }, LIMIT_REFRESH_RATE); + } + var usage = data.usage; + var limit = data.limit; + var unit = Messages.MB; + var $limit = $('', {'class': 'cryptpad-limit-bar'}).appendTo($container); + var quota = usage/limit; + var width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width + var $usage = $('', {'class': 'usage'}).css('width', width+'px'); + + if (quota >= 0.8) { + var origin = encodeURIComponent(window.location.origin); + var $upgradeLink = $('', { + href: "https://account.cryptpad.fr/#!on=" + origin, + rel: "noreferrer noopener", + target: "_blank", + }).appendTo($container); + $('