diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 26df06081..e6112a5ad 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -65,6 +65,17 @@ } } } + &.cp-history-oo { + .cp-history-timeline-container { + height: 20px !important; + .cp-history-timeline-pos { + height: 20px !important; + } + } + .cp-history-timeline-actions { + margin-left: 0 !important; + } + } .cp-history-timeline-line { display: flex; .cp-history-timeline-legend { @@ -149,6 +160,12 @@ margin-right: 5px; } } + .cp-history-timeline-version:empty { + display: none; + } + .cp-history-timeline-time:empty { + display: none; + } .cp-history-timeline-next { button:last-child { margin-right: 0; diff --git a/www/common/onlyoffice/history.js b/www/common/onlyoffice/history.js index 329c3cb40..d12d433e6 100644 --- a/www/common/onlyoffice/history.js +++ b/www/common/onlyoffice/history.js @@ -12,13 +12,14 @@ define([ History.loading = true; var $toolbar = config.$toolbar; var sframeChan = common.getSframeChannel(); + History.readOnly = common.getMetadataMgr().getPrivateData().readOnly || !common.isLoggedIn(); if (!config.onlyoffice || !config.setHistory || !config.onCheckpoint || !config.onPatch) { throw new Error("Missing config element"); } var cpIndex = -1; - var msgIndex = 0; + var msgIndex = -1; var ooMessages = {}; var loading = false; var update = function () {}; @@ -42,11 +43,13 @@ define([ var $version, $time, $share; var $hist = $toolbar.find('.cp-toolbar-history'); + $hist.addClass('cp-smallpatch'); + $hist.addClass('cp-history-oo'); var $bottom = $toolbar.find('.cp-toolbar-bottom'); var getVersion = function () { var major = sortedCp.length - cpIndex; - return major + '.' + msgIndex; + return major + '.' + (msgIndex+1); }; var showVersion = function (initial) { var v = getVersion(); @@ -55,15 +58,16 @@ define([ } $version.text("Version: " + v); // XXX - var $pos = $hist.find('.cp-toolbar-history-pos'); + var $pos = $hist.find('.cp-history-timeline-pos'); var cps = sortedCp.length; var id = sortedCp[cps - cpIndex -1] || -1; if (!ooMessages[id]) { return; } var msgs = ooMessages[id]; - var p = 100*(msgIndex / (msgs.length)); + console.log(ooMessages); + var p = 100*((msgIndex+1) / (msgs.length)); $pos.css('margin-left', p+'%'); - var time = msgs[msgIndex].time; + var time = msgs[msgIndex] && msgs[msgIndex].time; if (time) { $time.text(new Date(time).toLocaleString()); } else { $time.text(''); } }; @@ -93,7 +97,7 @@ define([ // Next cp or last hash var fromHash = nextId ? hashes[nextId].hash : config.onlyoffice.lastHash; - msgIndex = 0; + msgIndex = -1; showVersion(); if (ooMessages[id]) { @@ -129,25 +133,12 @@ define([ var Messages = common.Messages; - var states = []; - $hist.html('').css('display', 'flex'); $bottom.hide(); UI.spinner($hist).get().show(); - var $fastPrev = $('