From 282461f8fb999cfc6bf34e7e4e97fc5c66e30ffd Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 16:09:29 +0200 Subject: [PATCH 1/9] lint compliance --- www/debug/inner.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/www/debug/inner.js b/www/debug/inner.js index a8bacb840..698483710 100644 --- a/www/debug/inner.js +++ b/www/debug/inner.js @@ -598,6 +598,19 @@ define([ console.log(doc); }; + var extractMetadata = function (content) { + if (Array.isArray(content)) { + var m = content[content.length - 1]; + if (typeof(m.metadata) === 'object') { + // pad + return m.metadata; + } + } else if (typeof(content.metadata) === 'object') { + return content.metadata; + } + return; + }; + // Get the realtime metadata when in history mode var getLastMetadata = function () { var newContentStr = cpNfInner.chainpad.getUserDoc(); @@ -630,18 +643,6 @@ define([ cpNfInner.chainpad.contentUpdate(toRestore); }; - var extractMetadata = function (content) { - if (Array.isArray(content)) { - var m = content[content.length - 1]; - if (typeof(m.metadata) === 'object') { - // pad - return m.metadata; - } - } else if (typeof(content.metadata) === 'object') { - return content.metadata; - } - return; - }; config.onInit = function (info) { Title = common.createTitle({}); From a614f6335e40ad933d0fa8ee1770eab2ce35fa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Benqu=C3=A9?= Date: Tue, 29 Sep 2020 15:40:53 +0100 Subject: [PATCH 2/9] Swap tooltips for timeline buttons --- www/common/sframe-common-history.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 865b7fb3b..fa9462eed 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -415,7 +415,7 @@ define([ var prev = h('button.cp-toolbar-history-previous', { title: Messages.history_prev }, [ h('i.fa.fa-step-backward') ]); - var fastNext = h('button.cp-toolbar-history-next', { title: Messages.history_next }, [ + var fastNext = h('button.cp-toolbar-history-next', { title: Messages.history_fastNext }, [ h('i.fa.fa-users'), h('i.fa.fa-step-forward'), ]); @@ -423,7 +423,7 @@ define([ h('i.fa.fa-user'), h('i.fa.fa-step-forward'), ]); - var next = h('button.cp-toolbar-history-next', { title: Messages.history_fastNext }, [ + var next = h('button.cp-toolbar-history-next', { title: Messages.history_next }, [ h('i.fa.fa-step-forward') ]); var $fastPrev = $(fastPrev); From 3f0dbe7565a7f005130ac84079fa5aeafe4b570d Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 16:44:07 +0200 Subject: [PATCH 3/9] Drive history UI --- .../src/less2/include/toolbar-history.less | 20 ++++++++ www/common/sframe-common-history.js | 49 ++++++++++++++----- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 10dc5d4e1..0d3395255 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -49,6 +49,26 @@ } } + &.cp-history-drive { + .cp-history-timeline-container { + height: 20px !important; + } + .cp-history-timeline-users { + display: none !important; + } + .cp-history-timeline-legend { + display: none !important; + } + .cp-history-timeline-pos { + height: 18px !important; + } + .cp-toolbar-history-loadmore { + font-size: 10px !important; + } + .cp-history-timeline-actions { + margin-left: 21px !important; + } + } &.cp-smallpatch { .cp-history-snapshot { border: none !important; diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 865b7fb3b..284a39774 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -159,19 +159,27 @@ define([ title: snapshotsData[hash].title }, h('i.fa.fa-camera'))); } - check(user, getAuthor(i, 1), i); - check(users, getAuthor(i, 2), i); + if (config.drive) { + // Display only one bar, split by patch + check(user, i, i); + } else { + // Display two bars, split by author(s) + check(user, getAuthor(i, 1), i); + check(users, getAuthor(i, 2), i); + } } if (snapshotsOnly) { // We only want to redraw the snapshots - $bar.find('.cp-history-snapshotsi').html('').append([ + $bar.find('.cp-history-snapshots').html('').append([ $pos, snapshotsEl ]); } else { $(user.el).css('width', (100*(max + 1 - user.i)/max)+'%'); - $(users.el).css('width', (100*(max + 1 - users.i)/max)+'%'); + if (!config.drive) { + $(users.el).css('width', (100*(max + 1 - users.i)/max)+'%'); + } $bar.html('').append([ h('span.cp-history-timeline-users', users.list), @@ -415,7 +423,7 @@ define([ var prev = h('button.cp-toolbar-history-previous', { title: Messages.history_prev }, [ h('i.fa.fa-step-backward') ]); - var fastNext = h('button.cp-toolbar-history-next', { title: Messages.history_next }, [ + var fastNext = h('button.cp-toolbar-history-next', { title: Messages.history_fastNnext }, [ h('i.fa.fa-users'), h('i.fa.fa-step-forward'), ]); @@ -423,9 +431,18 @@ define([ h('i.fa.fa-user'), h('i.fa.fa-step-forward'), ]); - var next = h('button.cp-toolbar-history-next', { title: Messages.history_fastNext }, [ + var next = h('button.cp-toolbar-history-next', { title: Messages.history_next }, [ h('i.fa.fa-step-forward') ]); + if (config.drive) { + fastNext = h('button.cp-toolbar-history-next', { title: Messages.history_next }, [ + h('i.fa.fa-fast-forward'), + ]); + fastPrev = h('button.cp-toolbar-history-previous', {title: Messages.history_prev}, [ + h('i.fa.fa-fast-backward'), + ]); + } + var $fastPrev = $(fastPrev); var $userPrev = $(userPrev); var $prev = $(prev); @@ -456,13 +473,13 @@ define([ h('div.cp-history-timeline-actions', [ h('span.cp-history-timeline-prev', [ fastPrev, - userPrev, + config.drive ? undefined : userPrev, prev, ]), time, h('span.cp-history-timeline-next', [ next, - userNext, + config.drive ? undefined : userNext, fastNext ]) ]) @@ -506,6 +523,7 @@ define([ restore.disabled = true; } if (config.drive) { + $hist.addClass('cp-history-drive'); snapshot.disabled = true; share.disabled = true; } @@ -552,10 +570,17 @@ define([ // Version buttons $prev.click(function () { render(get(c - 1)); }); $next.click(function () { render(get(c + 1)); }); - $userPrev.click(function () { render(get(c - 1, false, 1)); }); - $userNext.click(function () { render(get(c + 1, false, 1)); }); - $fastPrev.click(function () { render(get(c - 1, false, 2)); }); - $fastNext.click(function () { render(get(c + 1, false, 2)); }); + if (config.drive) { + $fastPrev.click(function () { render(get(c - 10)); }); + $fastNext.click(function () { render(get(c + 10)); }); + $userPrev.click(function () { render(get(c - 10)); }); + $userNext.click(function () { render(get(c + 10)); }); + } else { + $userPrev.click(function () { render(get(c - 1, false, 1)); }); + $userNext.click(function () { render(get(c + 1, false, 1)); }); + $fastPrev.click(function () { render(get(c - 1, false, 2)); }); + $fastNext.click(function () { render(get(c + 1, false, 2)); }); + } onKeyDown = function (e) { var p = function () { e.preventDefault(); }; if (e.which === 39) { p(); return $next.click(); } // Right From 21eb1b6a1b8faf55c737f6a2d91a7f9782c22e4b Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 16:49:40 +0200 Subject: [PATCH 4/9] Fix overflowing spinner when loading history --- customize.dist/src/less2/include/toolbar-history.less | 5 +++++ www/common/sframe-common-history.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 0d3395255..9ab6604cb 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -22,6 +22,11 @@ font: @colortheme_app-font; } + &.cp-history-init { + padding: 0; + height: 32px; + } + .cp-toolbar-history-timeline { display: flex; flex-flow: column; diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 284a39774..abe3cb01a 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -20,6 +20,7 @@ define([ History.state = true; var $toolbar = config.$toolbar; var $hist = $toolbar.find('.cp-toolbar-history'); + $hist.addClass('cp-history-init'); if (!config.applyVal || !config.setHistory || !config.onLocal || !config.onRemote) { throw new Error("Missing config element: applyVal, onLocal, onRemote, setHistory"); @@ -411,6 +412,7 @@ define([ // Create the history toolbar var display = function () { $hist.html(''); + $hist.removeClass('cp-history-init'); var fastPrev = h('button.cp-toolbar-history-previous', { title: Messages.history_fastPrev }, [ h('i.fa.fa-step-backward'), @@ -524,8 +526,8 @@ define([ } if (config.drive) { $hist.addClass('cp-history-drive'); - snapshot.disabled = true; - share.disabled = true; + $(snapshot).hide(); + $(share).hide(); } $hist.append([timeline, actions]); From 11493f27afc0d3101e7765de74789be8f9373d99 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 16:59:40 +0200 Subject: [PATCH 5/9] Fix history cursor with large patch width --- .../src/less2/include/toolbar-history.less | 95 ++----------------- www/common/sframe-common-history.js | 2 +- 2 files changed, 7 insertions(+), 90 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 9ab6604cb..606ab33e5 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -84,9 +84,8 @@ border: none !important; width: 2px !important; background: @pos-color; - &:after { - margin-left: -8px !important; - top: -8px !important; + &:before { + left: -6px; } } } @@ -192,96 +191,14 @@ height: 37px; //background: @pos-color; position: absolute; - &:after { - content: ''; - border: 9px solid transparent; - border-top-color: @pos-color; + &:before { + margin-top: -17px; + font-size: 24px; position: absolute; - top: -9px; - margin-left: -1px; - width: 100%; + left: ~"calc(50% - 6px)"; } } -/* - .cp-history-filler { - flex: 1; - } - .cp-toolbar-history-close, - .cp-toolbar-history-revert { - background: white; - color: black; - //margin-top: 5px; - &:hover { - background-color: #e6e6e6; - } - } - .cp-toolbar-history-loadmore { - height: 100%; - color: black; - width: 25px; - position: absolute; - left: 0; - padding: 0; - } - .cp-toolbar-history-version { - position: absolute; - height: 25px; - line-height: 25px; - width: 100%; - text-align: center; - color: black; - } - .cp-toolbar-history-goto { - display: inline-block; - vertical-align: middle; - text-align: center; - flex: 1; - flex-basis: 80%; - min-width: 0; - max-width: 600px; - input { width: 75px; } - } - .cp-toolbar-history-goto-input { - padding-left: 5px; - margin-left: 5px; - vertical-align: middle; - } - .cp-toolbar-history-bar { - width: 100%; - background: white; - height: 25px; - margin: auto; - position: relative; - } - .cp-toolbar-history-pos-container { - width: ~"calc(100% - 2px)"; - height: 25px; - position: relative; - } - @pos-color: #55FF55; - .cp-toolbar-history-pos { - width: 2px; - height: 25px; - background: @pos-color; - &:after { - content: ''; - border: 6px solid transparent; - border-top-color: @pos-color; - margin-left: -5px; - } - } - button { - color: @cryptpad_text_col; - background-color: rgba(0,0,0,0.2); - &:hover { - background-color: rgba(0,0,0,0.4); - } - } - .fa-spinner { - font-size: 66px; - } -*/ } } diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 146d02718..c956d2297 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -457,7 +457,7 @@ define([ h('i.fa.fa-refresh.fa-spin.fa-3x.fa-fw', { style: 'display: none;' }) ]); - var pos = h('span.cp-history-timeline-pos'); + var pos = h('span.cp-history-timeline-pos.fa.fa-caret-down'); var time = h('div.cp-history-timeline-time'); $time = $(time); $version = $(); // XXX From 61df9d5254762f2f7dfadb458d58cb4575a1b88e Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 17:02:53 +0200 Subject: [PATCH 6/9] Fix title border issue with small screens --- customize.dist/src/less2/include/toolbar.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/customize.dist/src/less2/include/toolbar.less b/customize.dist/src/less2/include/toolbar.less index b787fb63b..863e828a7 100644 --- a/customize.dist/src/less2/include/toolbar.less +++ b/customize.dist/src/less2/include/toolbar.less @@ -483,6 +483,7 @@ height: @toolbar_line-height; box-sizing: border-box; line-height: @toolbar_line-height; + border: 1px solid transparent; } .cp-toolbar-title-readonly { font-size: 14px; @@ -490,7 +491,7 @@ .cp-toolbar-title-value { padding: 5px; line-height: @toolbar_line-height - 10px; - border: 0; + //border: 0; } .cp-toolbar-title-edit, .cp-toolbar-title-save { box-sizing: border-box; From 945a436eb237feace2a69d784c5505de7a3b1867 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 17:15:26 +0200 Subject: [PATCH 7/9] Fix readonly issue in history mode --- www/common/sframe-app-framework.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index b66294416..92e42616c 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -883,7 +883,7 @@ define([ onEditableChange: evEditableStateChange.reg, // Determine whether the UI should be locked for editing. - isLocked: function () { return state !== STATE.READY; }, + isLocked: function () { return state !== STATE.READY || unsyncMode; }, // Determine whether the pad is a "read only" pad and cannot be changed. isReadOnly: function () { return readOnly; }, From cbd6cf7dfbbd834e6dd766df20865a571618abc7 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 17:15:48 +0200 Subject: [PATCH 8/9] Improve cursor alignment in history mode --- customize.dist/src/less2/include/toolbar-history.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 606ab33e5..261933e1c 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -192,8 +192,8 @@ //background: @pos-color; position: absolute; &:before { - margin-top: -17px; - font-size: 24px; + margin-top: -16px; + font-size: 23px; position: absolute; left: ~"calc(50% - 6px)"; } From 79dff8737757ac593d876ad1a0b20d42b7c7a496 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Sep 2020 17:26:07 +0200 Subject: [PATCH 9/9] Fix switching from large to small cursor in history --- customize.dist/src/less2/include/toolbar-history.less | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 261933e1c..68e5450e3 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -81,7 +81,8 @@ background: @pos-color; } .cp-history-timeline-pos { - border: none !important; + border-right: none; + border-left: none; width: 2px !important; background: @pos-color; &:before { @@ -192,8 +193,8 @@ //background: @pos-color; position: absolute; &:before { - margin-top: -16px; - font-size: 23px; + top: -17px; + font-size: 24px; position: absolute; left: ~"calc(50% - 6px)"; }