mirror of
https://github.com/9001/copyparty.git
synced 2026-08-16 15:23:08 -06:00
bbox: cbz: go-to-page (#1535)
add "go-to-page" button + page-number in url --------- Signed-off-by: ed <s@ocv.me> Co-authored-by: ed <s@ocv.me>
This commit is contained in:
parent
d3b9599421
commit
12d877b0d0
|
|
@ -28,7 +28,7 @@ window.baguetteBox = (function () {
|
||||||
onChange: null,
|
onChange: null,
|
||||||
readDirRtl: false,
|
readDirRtl: false,
|
||||||
},
|
},
|
||||||
overlay, slider, btnPrev, btnNext, btnHelp, btnAnim, btnRotL, btnRotR, btnSel, btnFull, btnZoom, btnVmode, btnReadDir, btnClose,
|
overlay, slider, btnPrev, btnNext, btnHelp, btnAnim, btnRotL, btnRotR, btnSel, btnFull, btnZoom, btnVmode, btnReadDir, btnGoPage, btnClose,
|
||||||
currentGallery = [],
|
currentGallery = [],
|
||||||
currentIndex = 0,
|
currentIndex = 0,
|
||||||
isOverlayVisible = false,
|
isOverlayVisible = false,
|
||||||
|
|
@ -46,6 +46,7 @@ window.baguetteBox = (function () {
|
||||||
imagesElements = [],
|
imagesElements = [],
|
||||||
documentLastFocus = null,
|
documentLastFocus = null,
|
||||||
isFullscreen = false,
|
isFullscreen = false,
|
||||||
|
isCbz = false,
|
||||||
vmute = false,
|
vmute = false,
|
||||||
vloop = sread('vmode') == 'L',
|
vloop = sread('vmode') == 'L',
|
||||||
vnext = sread('vmode') == 'C',
|
vnext = sread('vmode') == 'C',
|
||||||
|
|
@ -137,6 +138,9 @@ window.baguetteBox = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var trapFocusInsideOverlay = function (e) {
|
var trapFocusInsideOverlay = function (e) {
|
||||||
|
if (modal.busy)
|
||||||
|
return;
|
||||||
|
|
||||||
if (overlay.style.display === 'block' && (overlay.contains && !overlay.contains(e.target))) {
|
if (overlay.style.display === 'block' && (overlay.contains && !overlay.contains(e.target))) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
btnClose.focus();
|
btnClose.focus();
|
||||||
|
|
@ -196,6 +200,16 @@ window.baguetteBox = (function () {
|
||||||
return [selectorData.galleries, options];
|
return [selectorData.galleries, options];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCbzPage() {
|
||||||
|
try {
|
||||||
|
var ret = parseInt(/,p([0-9]+)(,|$)/.exec(location.hash)[1]);
|
||||||
|
if (isNum(ret))
|
||||||
|
return Math.max(Math.min(ret, currentGallery.length), 1) - 1;
|
||||||
|
}
|
||||||
|
catch (ex) { }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
function bindCbzClickListeners(tagsNodeList, userOptions) {
|
function bindCbzClickListeners(tagsNodeList, userOptions) {
|
||||||
var cbzNodes = [].filter.call(tagsNodeList, function (element) {
|
var cbzNodes = [].filter.call(tagsNodeList, function (element) {
|
||||||
return re_cbz.test(element.href);
|
return re_cbz.test(element.href);
|
||||||
|
|
@ -212,10 +226,9 @@ window.baguetteBox = (function () {
|
||||||
|
|
||||||
e.preventDefault ? e.preventDefault() : e.returnValue = false;
|
e.preventDefault ? e.preventDefault() : e.returnValue = false;
|
||||||
fillCbzGallery(gallery, cbzElement, eventHandler).then(function () {
|
fillCbzGallery(gallery, cbzElement, eventHandler).then(function () {
|
||||||
prepareOverlay(gallery, userOptions);
|
prepareOverlay(gallery, userOptions, true);
|
||||||
showOverlay(0);
|
showOverlay(getCbzPage());
|
||||||
}
|
}).catch(function (reason) {
|
||||||
).catch(function (reason) {
|
|
||||||
console.error("cbz-ded", reason);
|
console.error("cbz-ded", reason);
|
||||||
var t;
|
var t;
|
||||||
try {
|
try {
|
||||||
|
|
@ -269,6 +282,7 @@ window.baguetteBox = (function () {
|
||||||
href: imageHref,
|
href: imageHref,
|
||||||
imageElement: cbzElement,
|
imageElement: cbzElement,
|
||||||
eventHandler: eventHandler,
|
eventHandler: eventHandler,
|
||||||
|
page: index + 1,
|
||||||
};
|
};
|
||||||
gallery.push(galleryItem);
|
gallery.push(galleryItem);
|
||||||
});
|
});
|
||||||
|
|
@ -317,6 +331,7 @@ window.baguetteBox = (function () {
|
||||||
'<button id="bbox-full" type="button" tt="full-screen">⛶</button>' +
|
'<button id="bbox-full" type="button" tt="full-screen">⛶</button>' +
|
||||||
'<button id="bbzoom" type="button" tt="zoom/stretch">z</button>' +
|
'<button id="bbzoom" type="button" tt="zoom/stretch">z</button>' +
|
||||||
'<button id="bbox-vmode" type="button" tt="a"></button>' +
|
'<button id="bbox-vmode" type="button" tt="a"></button>' +
|
||||||
|
'<button id="bbox-gopage" type="button" tt="go to page">pg</button>' +
|
||||||
'<button id="bbox-close" type="button" aria-label="Close">X</button>' +
|
'<button id="bbox-close" type="button" aria-label="Close">X</button>' +
|
||||||
'</div></div>'
|
'</div></div>'
|
||||||
);
|
);
|
||||||
|
|
@ -336,6 +351,7 @@ window.baguetteBox = (function () {
|
||||||
btnFull = ebi('bbox-full');
|
btnFull = ebi('bbox-full');
|
||||||
btnZoom = ebi('bbzoom');
|
btnZoom = ebi('bbzoom');
|
||||||
btnVmode = ebi('bbox-vmode');
|
btnVmode = ebi('bbox-vmode');
|
||||||
|
btnGoPage = ebi('bbox-gopage');
|
||||||
btnClose = ebi('bbox-close');
|
btnClose = ebi('bbox-close');
|
||||||
|
|
||||||
bcfg_bind(options, 'bbzoom', 'bbzoom', false, setzoom);
|
bcfg_bind(options, 'bbzoom', 'bbzoom', false, setzoom);
|
||||||
|
|
@ -357,6 +373,7 @@ window.baguetteBox = (function () {
|
||||||
['F', 'toggle fullscreen'],
|
['F', 'toggle fullscreen'],
|
||||||
['Z', 'toggle zoom/stretch'],
|
['Z', 'toggle zoom/stretch'],
|
||||||
['S', 'toggle file selection'],
|
['S', 'toggle file selection'],
|
||||||
|
['G', 'cbz: go to page'],
|
||||||
['space, P, K', 'video: play / pause'],
|
['space, P, K', 'video: play / pause'],
|
||||||
['U', 'video: seek 10sec back'],
|
['U', 'video: seek 10sec back'],
|
||||||
['O', 'video: seek 10sec ahead'],
|
['O', 'video: seek 10sec ahead'],
|
||||||
|
|
@ -442,6 +459,8 @@ window.baguetteBox = (function () {
|
||||||
btnZoom.click();
|
btnZoom.click();
|
||||||
else if (kl == "s")
|
else if (kl == "s")
|
||||||
tglsel();
|
tglsel();
|
||||||
|
else if (kl == "g" && isCbz)
|
||||||
|
gotoCbzPage(e);
|
||||||
else if (kl == "r")
|
else if (kl == "r")
|
||||||
rotn(e.shiftKey ? -1 : 1);
|
rotn(e.shiftKey ? -1 : 1);
|
||||||
else if (kl == "y")
|
else if (kl == "y")
|
||||||
|
|
@ -507,6 +526,24 @@ window.baguetteBox = (function () {
|
||||||
v.play();
|
v.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotoCbzPage(e) {
|
||||||
|
ev(e);
|
||||||
|
|
||||||
|
var cur = currentIndex + 1,
|
||||||
|
max = currentGallery.length;
|
||||||
|
|
||||||
|
modal.prompt('Go to page (1-' + max + ')', '' + cur, function (v) {
|
||||||
|
if (!v)
|
||||||
|
return;
|
||||||
|
|
||||||
|
v = parseInt(v);
|
||||||
|
if (!isNum(v))
|
||||||
|
return toast.warn(4, 'invalid input');
|
||||||
|
|
||||||
|
show(Math.max(Math.min(v, max), 1) - 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function tglVmode() {
|
function tglVmode() {
|
||||||
if (vloop) {
|
if (vloop) {
|
||||||
vnext = true;
|
vnext = true;
|
||||||
|
|
@ -636,6 +673,7 @@ window.baguetteBox = (function () {
|
||||||
bind(btnRotR, 'click', rotr);
|
bind(btnRotR, 'click', rotr);
|
||||||
bind(btnSel, 'click', tglsel);
|
bind(btnSel, 'click', tglsel);
|
||||||
bind(btnFull, 'click', tglfull);
|
bind(btnFull, 'click', tglfull);
|
||||||
|
bind(btnGoPage, 'click', gotoCbzPage);
|
||||||
bind(slider, 'contextmenu', contextmenuHandler);
|
bind(slider, 'contextmenu', contextmenuHandler);
|
||||||
bind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent);
|
bind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent);
|
||||||
bind(overlay, 'touchmove', touchmoveHandler, passiveEvent);
|
bind(overlay, 'touchmove', touchmoveHandler, passiveEvent);
|
||||||
|
|
@ -660,6 +698,7 @@ window.baguetteBox = (function () {
|
||||||
unbind(btnRotR, 'click', rotr);
|
unbind(btnRotR, 'click', rotr);
|
||||||
unbind(btnSel, 'click', tglsel);
|
unbind(btnSel, 'click', tglsel);
|
||||||
unbind(btnFull, 'click', tglfull);
|
unbind(btnFull, 'click', tglfull);
|
||||||
|
unbind(btnGoPage, 'click', gotoCbzPage);
|
||||||
unbind(slider, 'contextmenu', contextmenuHandler);
|
unbind(slider, 'contextmenu', contextmenuHandler);
|
||||||
unbind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent);
|
unbind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent);
|
||||||
unbind(overlay, 'touchmove', touchmoveHandler, passiveEvent);
|
unbind(overlay, 'touchmove', touchmoveHandler, passiveEvent);
|
||||||
|
|
@ -668,10 +707,13 @@ window.baguetteBox = (function () {
|
||||||
timer.rm(rotn);
|
timer.rm(rotn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOverlay(gallery, userOptions) {
|
function prepareOverlay(gallery, userOptions, cbz) {
|
||||||
if (currentGallery === gallery)
|
if (currentGallery === gallery)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
isCbz = cbz;
|
||||||
|
btnGoPage.style.display = isCbz ? '' : 'none';
|
||||||
|
|
||||||
currentGallery = gallery;
|
currentGallery = gallery;
|
||||||
setOptions(userOptions);
|
setOptions(userOptions);
|
||||||
slider.innerHTML = '';
|
slider.innerHTML = '';
|
||||||
|
|
|
||||||
|
|
@ -5946,7 +5946,11 @@ var thegrid = (function () {
|
||||||
},
|
},
|
||||||
onChange: function (i, maxIdx) {
|
onChange: function (i, maxIdx) {
|
||||||
if (this[i].imageElement) {
|
if (this[i].imageElement) {
|
||||||
sethash('g' + this[i].imageElement.getAttribute('ref') + getsort());
|
var h = 'g' + this[i].imageElement.getAttribute('ref');
|
||||||
|
if (this[i].page)
|
||||||
|
h += ',p' + this[i].page;
|
||||||
|
h += getsort();
|
||||||
|
sethash(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue