]> _ Git - fluidbook-html5.git/commitdiff
wip #6954 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 11 Jun 2024 12:50:57 +0000 (14:50 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 11 Jun 2024 12:50:57 +0000 (14:50 +0200)
js/libs/fluidbook/fluidbook.input.js
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.screensaver.js [new file with mode: 0644]
style/00-import.less
style/screensaver.less [new file with mode: 0644]

index 08b0c9fe55406ce61ee5419196e72c1aa6b4017c..32eaa81f5e55efce1fc54ed0ca110138899aa6fc 100644 (file)
@@ -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')
index a47552f4caa1073a51f88ee256cbf15840626fa5..e43d3736ffcee81e6e419b2431217f32c2f4f04b 100644 (file)
@@ -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 (file)
index 0000000..3cbe67d
--- /dev/null
@@ -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('<div id="screensaver"><video src="data/screensaver/' + this.fluidbook.settings.screensaver + '" autoplay preload="auto" muted loop></video></div>');
+        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
index 4dccd3342e46b460d1925aaa14acf20d5c69e927..3d3120171270285233e662c2cc2409c2519cb194 100644 (file)
@@ -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 (file)
index 0000000..014876c
--- /dev/null
@@ -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