Merge branch 'history' into historyOO

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

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

@ -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;

@ -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; },

@ -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");
@ -159,19 +160,27 @@ define([
title: snapshotsData[hash].title
}, 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(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)+'%');
if (!config.drive) {
$(users.el).css('width', (100*(max + 1 - users.i)/max)+'%');
}
$bar.html('').append([
h('span.cp-history-timeline-users', users.list),
@ -403,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'),
@ -415,7 +425,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,9 +433,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);
@ -438,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
@ -456,13 +475,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,8 +525,9 @@ define([
restore.disabled = true;
}
if (config.drive) {
snapshot.disabled = true;
share.disabled = true;
$hist.addClass('cp-history-drive');
$(snapshot).hide();
$(share).hide();
}
$hist.append([timeline, actions]);
@ -552,10 +572,17 @@ define([
// Version buttons
$prev.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)); });
$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

@ -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({});

Loading…
Cancel
Save