diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index c33ea7f8..4ef9ce09 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -22,7 +22,7 @@ window.baguetteBox = (function () { afterHide: null, onChange: null, }, - overlay, slider, btnPrev, btnNext, btnVmode, btnClose, + overlay, slider, btnPrev, btnNext, btnHelp, btnVmode, btnClose, currentGallery = [], currentIndex = 0, isOverlayVisible = false, @@ -174,8 +174,9 @@ window.baguetteBox = (function () { '' + '' + '
' + + '' + '' + - '' + + '' + '
' ); overlay = ctr.firstChild; @@ -185,11 +186,45 @@ window.baguetteBox = (function () { slider = ebi('bbox-slider'); btnPrev = ebi('bbox-prev'); btnNext = ebi('bbox-next'); + btnHelp = ebi('bbox-help'); btnVmode = ebi('bbox-vmode'); btnClose = ebi('bbox-close'); bindEvents(); } + function halp() { + if (ebi('bbox-halp')) + return; + + var list = [ + ['# hotkey', '# operation'], + ['escape', 'close'], + ['left, J', 'previous file'], + ['right, L', 'next file'], + ['home', 'first file'], + ['end', 'last file'], + ['space, P, K', 'video: play / pause'], + ['U', 'video: seek 10sec back'], + ['P', 'video: seek 10sec ahead'], + ['M', 'video: toggle mute'], + ['R', 'video: toggle loop'], + ['C', 'video: toggle auto-next'], + ['F', 'video: toggle fullscreen'], + ], + d = mknod('table'), + html = ['']; + + for (var a = 0; a < list.length; a++) + html.push('' + list[a][0] + '' + list[a][1] + ''); + + d.innerHTML = html.join('\n') + ''; + d.setAttribute('id', 'bbox-halp'); + d.onclick = function () { + overlay.removeChild(d); + }; + overlay.appendChild(d); + } + function keyDownHandler(e) { if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing) return; @@ -310,6 +345,7 @@ window.baguetteBox = (function () { bind(btnNext, 'click', showNextImage); bind(btnClose, 'click', hideOverlay); bind(btnVmode, 'click', tglVmode); + bind(btnHelp, 'click', halp); bind(slider, 'contextmenu', contextmenuHandler); bind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent); bind(overlay, 'touchmove', touchmoveHandler, passiveEvent); @@ -323,6 +359,7 @@ window.baguetteBox = (function () { unbind(btnNext, 'click', showNextImage); unbind(btnClose, 'click', hideOverlay); unbind(btnVmode, 'click', tglVmode); + unbind(btnHelp, 'click', halp); unbind(slider, 'contextmenu', contextmenuHandler); unbind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent); unbind(overlay, 'touchmove', touchmoveHandler, passiveEvent); @@ -435,6 +472,10 @@ window.baguetteBox = (function () { if (options.bodyClass && document.body.classList) document.body.classList.remove(options.bodyClass); + var h = ebi('bbox-halp'); + if (h) + h.parentNode.removeChild(h); + if (options.afterHide) options.afterHide(); diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index b6473b6b..88bc873c 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -1249,8 +1249,7 @@ html.light #bbox-overlay figcaption a { .bbox-btn { position: fixed; } -.bbox-btn, -#bbox-btns>button { +#bbox-overlay button { cursor: pointer; outline: none; padding: 0 .3em; @@ -1258,20 +1257,18 @@ html.light #bbox-overlay figcaption a { border: 0; border-radius: 15%; background: rgba(50, 50, 50, 0.5); - color: #ddd; - font: 1.6em sans-serif; + color: rgba(255,255,255,0.7); transition: background-color .3s ease; - line-height: 1em; + transition: color .3s ease; + font-size: 1.4em; + line-height: 1.4em; vertical-align: top; } -.bbox-btn:focus, -.bbox-btn:hover { +#bbox-overlay button:focus, +#bbox-overlay button:hover { + color: rgba(255,255,255,0.9); background: rgba(50, 50, 50, 0.9); } -button#bbox-vmode { - font-size: 1em; - line-height: 1.6em; -} #bbox-next { right: 1%; } @@ -1283,6 +1280,21 @@ button#bbox-vmode { right: 2%; position: fixed; } +#bbox-halp { + color: #fff; + background: #333; + position: absolute; + top: 0; + left: 0; + z-index: 20; + padding: .4em; +} +#bbox-halp td { + padding: .2em .5em; +} +#bbox-halp td:first-child { + text-align: right; +} .bbox-spinner { width: 40px; height: 40px;