mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
remember scroll position when leaving the textfile viewer
This commit is contained in:
parent
842817d9e3
commit
1690889ed8
|
@ -4462,6 +4462,7 @@ var thegrid = (function () {
|
|||
filecols.uivis();
|
||||
|
||||
aligngriditems();
|
||||
restore_scroll();
|
||||
};
|
||||
|
||||
r.setdirty = function () {
|
||||
|
@ -7767,10 +7768,36 @@ ebi('path').onclick = function (e) {
|
|||
};
|
||||
|
||||
|
||||
var scroll_y = -1;
|
||||
var scroll_vp = '\n';
|
||||
var scroll_obj = null;
|
||||
function persist_scroll() {
|
||||
var obj = scroll_obj;
|
||||
if (!obj) {
|
||||
var o1 = document.getElementsByTagName('html')[0];
|
||||
var o2 = document.body;
|
||||
obj = o1.scrollTop > o2.scrollTop ? o1 : o2;
|
||||
}
|
||||
var y = obj.scrollTop;
|
||||
if (y > 0)
|
||||
scroll_obj = obj;
|
||||
|
||||
scroll_y = y;
|
||||
scroll_vp = get_evpath();
|
||||
}
|
||||
function restore_scroll() {
|
||||
if (get_evpath() == scroll_vp && scroll_obj && scroll_obj.scrollTop < 1)
|
||||
scroll_obj.scrollTop = scroll_y;
|
||||
}
|
||||
|
||||
|
||||
ebi('files').onclick = ebi('docul').onclick = function (e) {
|
||||
if (!treectl.csel && e && (ctrl(e) || e.shiftKey))
|
||||
return true;
|
||||
|
||||
if (!showfile.active())
|
||||
persist_scroll();
|
||||
|
||||
var tgt = e.target.closest('a[id]');
|
||||
if (tgt && tgt.getAttribute('id').indexOf('f-') === 0 && tgt.textContent.endsWith('/')) {
|
||||
var el = treectl.find(tgt.textContent.slice(0, -1));
|
||||
|
|
Loading…
Reference in a new issue