]> _ Git - fluidbook-html5.git/commitdiff
wip #3577 @2.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Apr 2020 16:30:14 +0000 (18:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Apr 2020 16:30:14 +0000 (18:30 +0200)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.widget.js [new file with mode: 0644]
style/fluidbook.less
style/widget.less [new file with mode: 0644]

index 47b7e9274d2460394bab010140128070d64e6255..d62a9c80885abe122b6b1d5544cc306d83c2a1ca 100644 (file)
@@ -89,6 +89,7 @@ Fluidbook.prototype = {
         if (typeof window.FluidbookTabs === 'function') {
             this.tabs = new FluidbookTabs(this);
         }
+        this.widget = new FluidbookWidget(this);
 
         this.refw = 0;
         this.refh = 0;
diff --git a/js/libs/fluidbook/fluidbook.widget.js b/js/libs/fluidbook/fluidbook.widget.js
new file mode 100644 (file)
index 0000000..cd09fbb
--- /dev/null
@@ -0,0 +1,69 @@
+function FluidbookWidget(fluidbook) {
+    this.fluidbook = fluidbook;
+    this.featureEnabled = true;
+    this.enabled = false;
+
+    this.init();
+}
+
+FluidbookWidget.prototype = {
+    init: function () {
+        if ($_GET['widget'] != '1') {
+            return;
+        }
+        this.action = $_GET.hasOwnProperty('action') ? $_GET['action'] : 'fullscreen';
+        this.enabled = true;
+        var $this = this;
+        $(this.fluidbook).on('fluidbook.resize', function () {
+            $this.update();
+        });
+
+        $("#fluidbook").on('click', function () {
+            return $this.click();
+        });
+        this.update(true);
+    },
+
+    click: function () {
+        var active = this.isWidgetModeActive();
+        if (active) {
+            if (this.action === 'fullscreen') {
+                screenfull.toggle();
+            } else if (this.action === 'popup') {
+                top.window.open(window.location);
+            }
+        }
+        return !active;
+    },
+
+    update: function (force) {
+        var newMode = this.isWidgetModeActive();
+        if (force !== true && newMode === this.enabled) {
+            return;
+        }
+        this.enabled = newMode;
+        if (this.enabled) {
+            this.enable();
+        } else {
+            this.disable();
+        }
+    },
+
+    enable: function () {
+        console.log('enable widget mode');
+        $("body").addClass('widget');
+        if ($_GET['background'] !== undefined) {
+            $("#background,#splash").attr('style', 'background-color: ' + $_GET['background'] + ' !important;background-image:none !important');
+        }
+    },
+
+    disable: function () {
+        console.log('disable widget mode');
+        $("body").removeClass('widget');
+        $("#background,#splash").attr('style', '');
+    },
+
+    isWidgetModeActive: function () {
+        return this.featureEnabled && !screenfull.isFullscreen;
+    }
+}
\ No newline at end of file
index 8d49bfa874ec83de13489f3d8659f88dbaef0323..edaa642cedfb705f1d0a07c77798525a1529a167 100644 (file)
@@ -2861,4 +2861,5 @@ body > input {
 }
 
 @import "mobilefirst.less";
-@import "tabs.less";
\ No newline at end of file
+@import "tabs.less";
+@import "widget.less";
\ No newline at end of file
diff --git a/style/widget.less b/style/widget.less
new file mode 100644 (file)
index 0000000..0b78a8c
--- /dev/null
@@ -0,0 +1,5 @@
+body.widget {
+  footer#credits {
+    display: none;
+  }
+}
\ No newline at end of file