Feature: Timeslider follow (#4133)

When new edits come in changes are followed in the time slider.
This commit is contained in:
John McLear 2020-07-19 23:46:58 +01:00 committed by GitHub
parent a785914aa4
commit bf24063234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 8 deletions

View file

@ -104,6 +104,7 @@
"pad.chat.stick.title": "Stick chat to screen",
"pad.chat.writeMessage.placeholder": "Write your message here",
"timeslider.followContents": "Follow pad content updates",
"timeslider.pageTitle": "{{appTitle}} Timeslider",
"timeslider.toolbar.returnbutton": "Return to pad",
"timeslider.toolbar.authors": "Authors:",

View file

@ -255,6 +255,11 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
debugLog(e);
}
var lineNumber = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines;
if($('#options-followContents').is(":checked") || $('#options-followContents').prop("checked")){
goToLineNumber(lineNumber);
}
Changeset.mutateTextLines(changeset, padContents);
padContents.currentRevision = revision;
padContents.currentTime += timeDelta * 1000;
@ -585,6 +590,14 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
receiveAuthorData(clientVars.collab_client_vars.historicalAuthorData);
return changesetLoader;
function goToLineNumber(lineNumber){
// Sets the Y scrolling of the browser to go to this line
var line = $('#innerdocbody').find("div:nth-child("+(lineNumber+1)+")");
var newY = $(line)[0].offsetTop;
let ecb = document.getElementById('editorcontainerbox');
ecb.scrollTo({top: newY, behavior: 'smooth'});
}
}
exports.loadBroadcastJS = loadBroadcastJS;

View file

@ -226,14 +226,20 @@
<div id="settings" class="popup"><div class="popup-content">
<h1 data-l10n-id="pad.settings.padSettings"></h1>
<label for="viewfontmenu" data-l10n-id="pad.settings.fontType">Font type:</label>
<select id="viewfontmenu">
<option value="" data-l10n-id="pad.settings.fontType.normal">Normal</option>
<%= fonts = ["Quicksand", "Roboto", "Alegreya", "PlayfairDisplay", "Montserrat", "OpenDyslexic", "RobotoMono"] %>
<% for(var i=0; i < fonts.length; i++) { %>
<option value="<%=fonts[i]%>"><%=fonts[i]%></option>
<% } %>
</select>
<p>
<label for="viewfontmenu" data-l10n-id="pad.settings.fontType">Font type:</label>
<select id="viewfontmenu">
<option value="" data-l10n-id="pad.settings.fontType.normal">Normal</option>
<%= fonts = ["Quicksand", "Roboto", "Alegreya", "PlayfairDisplay", "Montserrat", "OpenDyslexic", "RobotoMono"] %>
<% for(var i=0; i < fonts.length; i++) { %>
<option value="<%=fonts[i]%>"><%=fonts[i]%></option>
<% } %>
</select>
</p>
<p>
<input type="checkbox" id="options-followContents" checked="checked">
<label for="options-followContents" data-l10n-id="timeslider.followContents"></label>
</p>
</div></div>
</div>
</body>