From 4ec13ea3334a16ef2ab51e574c4a85e5180ef7e9 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 11 Jun 2024 14:50:57 +0200 Subject: [PATCH] wip #6954 @2 --- js/libs/fluidbook/fluidbook.input.js | 20 ++++++-- js/libs/fluidbook/fluidbook.js | 3 ++ js/libs/fluidbook/fluidbook.screensaver.js | 54 ++++++++++++++++++++++ style/00-import.less | 3 +- style/screensaver.less | 16 +++++++ 5 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 js/libs/fluidbook/fluidbook.screensaver.js create mode 100644 style/screensaver.less diff --git a/js/libs/fluidbook/fluidbook.input.js b/js/libs/fluidbook/fluidbook.input.js index 08b0c9fe..32eaa81f 100644 --- a/js/libs/fluidbook/fluidbook.input.js +++ b/js/libs/fluidbook/fluidbook.input.js @@ -68,7 +68,9 @@ FluidbookInput.prototype = { isUsingMouse: function () { return this.usingMouse; - }, isUsingKeyboard: function () { + }, + + isUsingKeyboard: function () { return this.usingKeyboard; }, @@ -78,13 +80,17 @@ FluidbookInput.prototype = { this.usingKeyboard = this.usingMouse = false; this.setTouchClasses(); } - }, useMouse: function () { + }, + + useMouse: function () { if (!this.usingMouse) { this.hasMouse = this.usingMouse = true; this.usingKeyboard = this.usingTouch = false; this.setMouseClasses(); } - }, useKeyboard: function () { + }, + + useKeyboard: function () { if (!this.usingKeyboard) { this.hasKeyboard = this.usingKeyboard = true; this.usingMouse = this.usingTouch = false; @@ -100,14 +106,18 @@ FluidbookInput.prototype = { .addClass('using-touch') .addClass('no-using-keyboard'); - }, setMouseClasses: function () { + }, + + setMouseClasses: function () { $('html').addClass('using-mouse') .addClass('no-using-touch') .addClass('no-using-keyboard') .removeClass('no-using-mouse') .removeClass('using-touch') .removeClass('using-keyboard'); - }, setKeyboardClasses: function () { + }, + + setKeyboardClasses: function () { $('html').addClass('using-keyboard') .addClass('no-using-touch') .addClass('no-using-mouse') diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index a47552f4..e43d3736 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -113,6 +113,9 @@ Fluidbook.prototype = { if (window.FluidbookSlideshow) { this.slideshow = new FluidbookSlideshow(this); } + if (window.FluidbookScreensaver) { + this.screensaver = new FluidbookScreensaver(this); + } this.printing = new FluidbookPrint(this); this.posad = new FluidbookPOSAd(this); this.notes = new FluidbookNotes(this); diff --git a/js/libs/fluidbook/fluidbook.screensaver.js b/js/libs/fluidbook/fluidbook.screensaver.js new file mode 100644 index 00000000..3cbe67df --- /dev/null +++ b/js/libs/fluidbook/fluidbook.screensaver.js @@ -0,0 +1,54 @@ +function FluidbookScreensaver(fluidbook) { + this.fluidbook = fluidbook; + this.timer = null; + this.sleepTime = 1000 * parseInt(this.fluidbook.settings.screensaver_sleep_time); + this.init(); +} + +FluidbookScreensaver.prototype = { + init: function () { + let $this = this; + $(document).on('touchmove keydown keyup click mousemove touchstart touchend mouseup mousedown', function () { + if ($("#screensaver").is(":visible")) { + $this.wakeup(); + } else { + $this.resetTimer(); + } + return true; + }); + + $("body").append('
'); + this.resetTimer(); + }, + + resetTimer: function () { + if ($("#screensaver").is(":visible")) { + return false; + } + let $this = this; + clearTimeout(this.timer); + this.timer = setTimeout(function () { + $this.sleep(); + }, this.sleepTime); + }, + + wakeup: function () { + this.hide(); + + }, + + sleep: function () { + this.show(); + if (this.fluidbook.settings.screensaver_wake_action === 'page') { + this.fluidbook.setCurrentPage(this.fluidbook.settings.screensaver_wake_action_page); + } + }, + + show: function () { + $("#screensaver").show(); + }, + + hide: function () { + $("#screensaver").hide(); + } +} \ No newline at end of file diff --git a/style/00-import.less b/style/00-import.less index 4dccd334..3d312017 100644 --- a/style/00-import.less +++ b/style/00-import.less @@ -3,4 +3,5 @@ @import "mmenu/mmenu"; @import "nav-horizontal"; @import "input-radio"; -@import "accessibility"; \ No newline at end of file +@import "accessibility"; +@import "screensaver"; \ No newline at end of file diff --git a/style/screensaver.less b/style/screensaver.less new file mode 100644 index 00000000..014876cd --- /dev/null +++ b/style/screensaver.less @@ -0,0 +1,16 @@ +#screensaver { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 10000; + cursor: default; + + video { + width: 100%; + height: 100%; + object-fit: cover; + pointer-events: none; + } +} \ No newline at end of file -- 2.39.5