]> _ Git - fluidbook-html5.git/commitdiff
done #1185 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Mar 2017 14:45:05 +0000 (15:45 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 3 Mar 2017 14:45:05 +0000 (15:45 +0100)
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.privacy.js [new file with mode: 0644]
js/libs/storage.js
style/fluidbook.css
style/fluidbook.less

index 94d16b5bb4cc36932a734990bb9379ca43bec7c8..6f79b0e4275df4f12aecc356c49a80708ebdc0da 100644 (file)
@@ -49,6 +49,7 @@ Fluidbook.prototype = {
         } else {
             this.form == false;
         }
+        this.privacy=new FluidbookPrivacy(this);
         this.refw = 0;
         this.refh = 0;
         this.zoom = 1;
@@ -142,6 +143,8 @@ Fluidbook.prototype = {
             })
         }
 
+       $(this).trigger('fluidbookhidesplash');
+
     },
     ready: function () {
         if (this.isReady) {
diff --git a/js/libs/fluidbook/fluidbook.privacy.js b/js/libs/fluidbook/fluidbook.privacy.js
new file mode 100644 (file)
index 0000000..33da50f
--- /dev/null
@@ -0,0 +1,42 @@
+function FluidbookPrivacy(fluidbook) {
+    this.fluidbook = fluidbook;
+    this.storageKey = 'cookieConsent';
+    if (location.host == 'workshop.fluidbook.com') {
+        this.storageKey = 'fluidbook.' + fluidbook.datas.id + this.storageKey;
+    }
+    if (!this.fluidbook.datas.cookieConsent) {
+        return;
+    }
+    this.init();
+}
+FluidbookPrivacy.prototype = {
+    init: function () {
+        if (localStorage.getItem(this.storageKey) == '1') {
+            return;
+        }
+
+        var $this = this;
+        $(this.fluidbook).on('fluidbookhidesplash', function () {
+            $this.displayCookieConsent();
+        });
+    },
+    displayCookieConsent: function () {
+        var $this = this;
+        $('body').append('<div id="cookieConsent"><a href="#" class="close"></a><p>' + this.fluidbook.datas.cookieConsentMessage + '</p></div>');
+        if (this.fluidbook.datas.cookieConsentAutoclose > 0) {
+            setTimeout(function () {
+                $this.close();
+            }, this.fluidbook.datas.cookieConsentAutoclose * 1000);
+        }
+        $("#cookieConsent a.close").on('touchend click', function () {
+            $this.close();
+            return false;
+        });
+    },
+    close: function () {
+        // hide
+        $('#cookieConsent').fadeOut();
+        // set the flag to avoid to display it for the next fisit
+        localStorage.setItem(this.storageKey, '1');
+    },
+}
\ No newline at end of file
index 49ac72a0a81ffa5bb3586d66ab78572671e89ffb..8059f5c43f054485fc738ef096967d2e4bd44b27 100644 (file)
@@ -1,3 +1,5 @@
+// Even if the support of this feature is very wide, this polyfill must be kept :\r
+// Safari & Android browsers disable the support of this feature when in private tab\r
 try {\r
     // Test webstorage existence.\r
     if (!window.localStorage || !window.sessionStorage) throw "exception";\r
index 953736f0f27c2856ab94b44b514aceec42e27e62..ee5c8f8f20072dbdae19bb84792dd0a783c08353 100644 (file)
@@ -1466,6 +1466,40 @@ a.button {
   transform-origin: 0 0;
   margin: 20px 0 0 -10px;
 }
+/* Privacy settings */
+#cookieConsent {
+  background-color: rgba(0, 0, 0, 0.8);
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100%;
+  padding: 20px 40px;
+  z-index: 20;
+}
+#cookieConsent a.close {
+  position: absolute;
+  top: 0px;
+  right: 0px;
+  padding: 20px;
+  background-image: url("../images/close.svg");
+  background-size: 16px 16px;
+  background-repeat: no-repeat;
+  background-position: 20px 20px;
+  width: 56px;
+  height: 56px;
+}
+#cookieConsent p {
+  text-align: center;
+  color: #ffffff;
+  font-size: 15px;
+  margin: 0 auto;
+  max-width: 1100px;
+}
+#cookieConsent p a {
+  white-space: nowrap;
+  text-decoration: underline;
+}
+/* Zoom on double tap */
 #zoomguides {
   width: 100%;
   height: 100%;
index f515370456604d1c9424eee78702d7382754b0c3..ad09abcb7e54e24cfdb345dbeb51de34701672b8 100644 (file)
@@ -1722,6 +1722,44 @@ a.button {
        margin: 20px 0 0 -10px;
 }
 
+/* Privacy settings */
+
+#cookieConsent {
+       background-color: rgba(0, 0, 0, 0.8);
+       position: fixed;
+       bottom: 0;
+       left: 0;
+       width: 100%;
+       padding: 20px 40px;
+       z-index: 20;
+       a.close {
+               position: absolute;
+               top: 0px;
+               right: 0px;
+               padding: 20px;
+               background-image: url("../images/close.svg");
+               background-size: 16px 16px;
+               background-repeat: no-repeat;
+               background-position: 20px 20px;
+               width: 56px;
+               height: 56px;
+       }
+       p {
+               text-align: center;
+               color: #ffffff;
+               font-size: 15px;
+               margin: 0 auto;
+               max-width: 1100px;
+               a {
+                       white-space: nowrap;
+                       text-decoration: underline;
+               }
+       }
+
+}
+
+/* Zoom on double tap */
+
 #zoomguides {
        width: 100%;
        height: 100%;