From: Vincent Vanwaelscappel Date: Fri, 3 Mar 2017 14:45:05 +0000 (+0100) Subject: done #1185 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=81463b49602a45a3a593d96814055ca6b276fa12;p=fluidbook-html5.git done #1185 @1 --- diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 94d16b5b..6f79b0e4 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -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 index 00000000..33da50fe --- /dev/null +++ b/js/libs/fluidbook/fluidbook.privacy.js @@ -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('

' + this.fluidbook.datas.cookieConsentMessage + '

'); + 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 diff --git a/js/libs/storage.js b/js/libs/storage.js index 49ac72a0..8059f5c4 100644 --- a/js/libs/storage.js +++ b/js/libs/storage.js @@ -1,3 +1,5 @@ +// Even if the support of this feature is very wide, this polyfill must be kept : +// Safari & Android browsers disable the support of this feature when in private tab try { // Test webstorage existence. if (!window.localStorage || !window.sessionStorage) throw "exception"; diff --git a/style/fluidbook.css b/style/fluidbook.css index 953736f0..ee5c8f8f 100644 --- a/style/fluidbook.css +++ b/style/fluidbook.css @@ -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%; diff --git a/style/fluidbook.less b/style/fluidbook.less index f5153704..ad09abcb 100644 --- a/style/fluidbook.less +++ b/style/fluidbook.less @@ -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%;