From 5013a09230163104521a6fb20e12555ab9d37f42 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 17 Oct 2017 10:10:26 -0700 Subject: [PATCH] added click and space bar play/pause for videos --- public/assets/css/general.css | 4 +-- public/assets/js/showFunctions.js | 23 ++++++++++++++++ views/layouts/show.handlebars | 1 + views/layouts/showlite.handlebars | 1 + views/partials/asset.handlebars | 10 +++---- views/partials/assetInfo.handlebars | 2 +- views/showLite.handlebars | 42 ++++++++++++++--------------- 7 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 public/assets/js/showFunctions.js diff --git a/public/assets/css/general.css b/public/assets/css/general.css index 600a5d2e..801812cb 100644 --- a/public/assets/css/general.css +++ b/public/assets/css/general.css @@ -492,8 +492,8 @@ table { width: 100%; } -.video-show { - +#video-player { + cursor: pointer; } /* item lists */ diff --git a/public/assets/js/showFunctions.js b/public/assets/js/showFunctions.js new file mode 100644 index 00000000..94047cd3 --- /dev/null +++ b/public/assets/js/showFunctions.js @@ -0,0 +1,23 @@ +function playOrPause(video){ + if (video.paused == true) { + video.play(); + } + else{ + video.pause(); + } +} + +// if a video player is present, set the listeners +const video = document.getElementById('video-player'); +if (video) { + // add event listener for click + video.addEventListener('click', ()=> { + playOrPause(video); + }); + // add event listener for space bar + document.body.onkeyup = (event) => { + if (event.keyCode == 32) { + playOrPause(video); + } + }; +} \ No newline at end of file diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index b6448b8b..6742ff90 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -26,6 +26,7 @@
{{{ body }}}
+ diff --git a/views/layouts/showlite.handlebars b/views/layouts/showlite.handlebars index 114bae03..6471042e 100644 --- a/views/layouts/showlite.handlebars +++ b/views/layouts/showlite.handlebars @@ -18,6 +18,7 @@ {{{ body }}} + diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 0fc42a3d..bbbdb8e6 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,4 +1,3 @@ - {{#ifConditional fileInfo.fileType '===' 'video/mp4'}} {{#ifConditional fileInfo.fileExt '===' 'gifv'}} {{else}} - \ No newline at end of file + + + +{{/ifConditional}} \ No newline at end of file diff --git a/views/partials/assetInfo.handlebars b/views/partials/assetInfo.handlebars index 0af336d2..9e7e428a 100644 --- a/views/partials/assetInfo.handlebars +++ b/views/partials/assetInfo.handlebars @@ -5,7 +5,7 @@