Merge branch 'history' into historyOO

pull/1/head
yflory 4 years ago
commit 385edd6cf4

@ -22,6 +22,11 @@
font: @colortheme_app-font; font: @colortheme_app-font;
} }
&.cp-history-init {
padding: 0;
height: 32px;
}
.cp-toolbar-history-timeline { .cp-toolbar-history-timeline {
display: flex; display: flex;
flex-flow: column; flex-flow: column;
@ -49,6 +54,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-smallpatch {
.cp-history-snapshot { .cp-history-snapshot {
border: none !important; border: none !important;
@ -56,12 +81,12 @@
background: @pos-color; background: @pos-color;
} }
.cp-history-timeline-pos { .cp-history-timeline-pos {
border: none !important; border-right: none;
border-left: none;
width: 2px !important; width: 2px !important;
background: @pos-color; background: @pos-color;
&:after { &:before {
margin-left: -8px !important; left: -6px;
top: -8px !important;
} }
} }
} }
@ -184,97 +209,13 @@
height: 37px; height: 37px;
//background: @pos-color; //background: @pos-color;
position: absolute; position: absolute;
&:after { &:before {
content: ''; top: -17px;
border: 9px solid transparent; font-size: 24px;
border-top-color: @pos-color;
position: absolute; position: absolute;
top: -9px; left: ~"calc(50% - 6px)";
margin-left: -1px;
width: 100%;
}
}
/*
.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;
left: 0;
}
.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;
} }
*/
} }
} }

@ -483,6 +483,7 @@
height: @toolbar_line-height; height: @toolbar_line-height;
box-sizing: border-box; box-sizing: border-box;
line-height: @toolbar_line-height; line-height: @toolbar_line-height;
border: 1px solid transparent;
} }
.cp-toolbar-title-readonly { .cp-toolbar-title-readonly {
font-size: 14px; font-size: 14px;
@ -490,7 +491,7 @@
.cp-toolbar-title-value { .cp-toolbar-title-value {
padding: 5px; padding: 5px;
line-height: @toolbar_line-height - 10px; line-height: @toolbar_line-height - 10px;
border: 0; //border: 0;
} }
.cp-toolbar-title-edit, .cp-toolbar-title-save { .cp-toolbar-title-edit, .cp-toolbar-title-save {
box-sizing: border-box; box-sizing: border-box;

@ -883,7 +883,7 @@ define([
onEditableChange: evEditableStateChange.reg, onEditableChange: evEditableStateChange.reg,
// Determine whether the UI should be locked for editing. // 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. // Determine whether the pad is a "read only" pad and cannot be changed.
isReadOnly: function () { return readOnly; }, isReadOnly: function () { return readOnly; },

@ -20,6 +20,7 @@ define([
History.state = true; History.state = true;
var $toolbar = config.$toolbar; var $toolbar = config.$toolbar;
var $hist = $toolbar.find('.cp-toolbar-history'); var $hist = $toolbar.find('.cp-toolbar-history');
$hist.addClass('cp-history-init');
if (!config.applyVal || !config.setHistory || !config.onLocal || !config.onRemote) { if (!config.applyVal || !config.setHistory || !config.onLocal || !config.onRemote) {
throw new Error("Missing config element: applyVal, onLocal, onRemote, setHistory"); throw new Error("Missing config element: applyVal, onLocal, onRemote, setHistory");
@ -159,19 +160,27 @@ define([
title: snapshotsData[hash].title title: snapshotsData[hash].title
}, h('i.fa.fa-camera'))); }, h('i.fa.fa-camera')));
} }
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(user, getAuthor(i, 1), i);
check(users, getAuthor(i, 2), i); check(users, getAuthor(i, 2), i);
} }
}
if (snapshotsOnly) { if (snapshotsOnly) {
// We only want to redraw the snapshots // We only want to redraw the snapshots
$bar.find('.cp-history-snapshotsi').html('').append([ $bar.find('.cp-history-snapshots').html('').append([
$pos, $pos,
snapshotsEl snapshotsEl
]); ]);
} else { } else {
$(user.el).css('width', (100*(max + 1 - user.i)/max)+'%'); $(user.el).css('width', (100*(max + 1 - user.i)/max)+'%');
if (!config.drive) {
$(users.el).css('width', (100*(max + 1 - users.i)/max)+'%'); $(users.el).css('width', (100*(max + 1 - users.i)/max)+'%');
}
$bar.html('').append([ $bar.html('').append([
h('span.cp-history-timeline-users', users.list), h('span.cp-history-timeline-users', users.list),
@ -403,6 +412,7 @@ define([
// Create the history toolbar // Create the history toolbar
var display = function () { var display = function () {
$hist.html(''); $hist.html('');
$hist.removeClass('cp-history-init');
var fastPrev = h('button.cp-toolbar-history-previous', { title: Messages.history_fastPrev }, [ var fastPrev = h('button.cp-toolbar-history-previous', { title: Messages.history_fastPrev }, [
h('i.fa.fa-step-backward'), h('i.fa.fa-step-backward'),
@ -415,7 +425,7 @@ define([
var prev = h('button.cp-toolbar-history-previous', { title: Messages.history_prev }, [ var prev = h('button.cp-toolbar-history-previous', { title: Messages.history_prev }, [
h('i.fa.fa-step-backward') 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-users'),
h('i.fa.fa-step-forward'), h('i.fa.fa-step-forward'),
]); ]);
@ -423,9 +433,18 @@ define([
h('i.fa.fa-user'), h('i.fa.fa-user'),
h('i.fa.fa-step-forward'), 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') 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 $fastPrev = $(fastPrev);
var $userPrev = $(userPrev); var $userPrev = $(userPrev);
var $prev = $(prev); var $prev = $(prev);
@ -438,7 +457,7 @@ define([
h('i.fa.fa-refresh.fa-spin.fa-3x.fa-fw', { style: 'display: none;' }) 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'); var time = h('div.cp-history-timeline-time');
$time = $(time); $time = $(time);
$version = $(); // XXX $version = $(); // XXX
@ -456,13 +475,13 @@ define([
h('div.cp-history-timeline-actions', [ h('div.cp-history-timeline-actions', [
h('span.cp-history-timeline-prev', [ h('span.cp-history-timeline-prev', [
fastPrev, fastPrev,
userPrev, config.drive ? undefined : userPrev,
prev, prev,
]), ]),
time, time,
h('span.cp-history-timeline-next', [ h('span.cp-history-timeline-next', [
next, next,
userNext, config.drive ? undefined : userNext,
fastNext fastNext
]) ])
]) ])
@ -506,8 +525,9 @@ define([
restore.disabled = true; restore.disabled = true;
} }
if (config.drive) { if (config.drive) {
snapshot.disabled = true; $hist.addClass('cp-history-drive');
share.disabled = true; $(snapshot).hide();
$(share).hide();
} }
$hist.append([timeline, actions]); $hist.append([timeline, actions]);
@ -552,10 +572,17 @@ define([
// Version buttons // Version buttons
$prev.click(function () { render(get(c - 1)); }); $prev.click(function () { render(get(c - 1)); });
$next.click(function () { render(get(c + 1)); }); $next.click(function () { render(get(c + 1)); });
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)); }); $userPrev.click(function () { render(get(c - 1, false, 1)); });
$userNext.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)); }); $fastPrev.click(function () { render(get(c - 1, false, 2)); });
$fastNext.click(function () { render(get(c + 1, false, 2)); }); $fastNext.click(function () { render(get(c + 1, false, 2)); });
}
onKeyDown = function (e) { onKeyDown = function (e) {
var p = function () { e.preventDefault(); }; var p = function () { e.preventDefault(); };
if (e.which === 39) { p(); return $next.click(); } // Right if (e.which === 39) { p(); return $next.click(); } // Right

@ -598,6 +598,19 @@ define([
console.log(doc); 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 // Get the realtime metadata when in history mode
var getLastMetadata = function () { var getLastMetadata = function () {
var newContentStr = cpNfInner.chainpad.getUserDoc(); var newContentStr = cpNfInner.chainpad.getUserDoc();
@ -630,18 +643,6 @@ define([
cpNfInner.chainpad.contentUpdate(toRestore); 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) { config.onInit = function (info) {
Title = common.createTitle({}); Title = common.createTitle({});

Loading…
Cancel
Save