From 93f0658e404ee694310da52f838ff879ef47779a Mon Sep 17 00:00:00 2001 From: kovacsv Date: Fri, 18 Jun 2021 13:33:10 +0200 Subject: [PATCH] Cookie dialog with standard dialog style. --- tools/config.json | 1 + website/embed.html | 1 + website/index.html | 1 + website/o3dv/cookiedialog.js | 26 ++++++++++++++++++++++++++ website/o3dv/cookies.js | 2 +- website/o3dv/modal.js | 5 +++++ website/o3dv/website.css | 28 ---------------------------- website/o3dv/website.js | 11 ++++------- 8 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 website/o3dv/cookiedialog.js diff --git a/tools/config.json b/tools/config.json index 9d0488d..38c4f05 100644 --- a/tools/config.json +++ b/tools/config.json @@ -73,6 +73,7 @@ "website/o3dv/sharingdialog.js", "website/o3dv/settingsdialog.js", "website/o3dv/quantitiesdialog.js", + "website/o3dv/cookiedialog.js", "website/o3dv/modeldata.js", "website/o3dv/info.js", "website/o3dv/navigator.js", diff --git a/website/embed.html b/website/embed.html index 2b1feca..0a56b6f 100644 --- a/website/embed.html +++ b/website/embed.html @@ -87,6 +87,7 @@ + diff --git a/website/index.html b/website/index.html index 30015e6..bef4da5 100644 --- a/website/index.html +++ b/website/index.html @@ -87,6 +87,7 @@ + diff --git a/website/o3dv/cookiedialog.js b/website/o3dv/cookiedialog.js new file mode 100644 index 0000000..444a046 --- /dev/null +++ b/website/o3dv/cookiedialog.js @@ -0,0 +1,26 @@ +OV.ShowCookieDialog = function (onOk) +{ + let dialog = new OV.ButtonDialog (); + let contentDiv = dialog.Init ('Cookie Consent', [ + { + name : 'Cancel', + subClass : 'outline', + onClick () { + dialog.Hide (); + } + }, + { + name : 'OK', + onClick () { + dialog.Hide (); + onOk (); + } + } + ]); + + let text = 'This website uses cookies to offer you better user experience. See the details at the Cookies Policy page.'; + $('
').html (text).addClass ('ov_dialog_section').appendTo (contentDiv); + dialog.SetCloseable (false); + dialog.Show (); + return dialog; +}; diff --git a/website/o3dv/cookies.js b/website/o3dv/cookies.js index a7f9f06..ee8dc3a 100644 --- a/website/o3dv/cookies.js +++ b/website/o3dv/cookies.js @@ -2,7 +2,7 @@ OV.CookieHandler = class { constructor () { - this.expirationDays = 30; + this.expirationDays = 365; } ClearVal (key) diff --git a/website/o3dv/modal.js b/website/o3dv/modal.js index 57e565d..9407565 100644 --- a/website/o3dv/modal.js +++ b/website/o3dv/modal.js @@ -165,6 +165,11 @@ OV.ButtonDialog = class return dialogContentDiv; } + SetCloseable (closeable) + { + this.modal.SetCloseable (closeable); + } + SetCloseHandler (closeHandler) { this.modal.SetCloseHandler (closeHandler); diff --git a/website/o3dv/website.css b/website/o3dv/website.css index 2c4291e..f5ac331 100644 --- a/website/o3dv/website.css +++ b/website/o3dv/website.css @@ -714,34 +714,6 @@ div.ov_thin_scrollbar::-webkit-scrollbar-thumb background: #cccccc; } -div.ov_message_popup -{ - padding: 4px 10px; - position: absolute; - bottom: 15px; - right: 10px; - overflow: auto; -} - -div.ov_message_popup div.ov_message_popup_text -{ - padding: 3px; - float: left; -} - -div.ov_message_popup div.ov_message_popup_button -{ - color: #ffffff; - background: #3393bd; - text-align: center; - margin-left: 10px; - padding: 3px; - width: 60px; - border-radius: 5px; - cursor: pointer; - float: right; -} - @media (hover) { diff --git a/website/o3dv/website.js b/website/o3dv/website.js index 3f87fc8..a1995eb 100644 --- a/website/o3dv/website.js +++ b/website/o3dv/website.js @@ -29,7 +29,8 @@ OV.Website = class this.InitDragAndDrop (); this.InitModelLoader (); this.InitNavigator (); - //this.InitCookieConsent (); + // TODO + // this.InitCookieConsent (); this.viewer.SetClickHandler (this.OnModelClicked.bind (this)); this.Resize (); @@ -508,6 +509,7 @@ OV.Website = class InitCookieConsent () { let cookieConsentKey = 'ov_cookie_consent'; + // TODO: remove this.cookieHandler.ClearVal (cookieConsentKey); let accepted = this.cookieHandler.GetBoolVal (cookieConsentKey, false); if (accepted) { @@ -515,13 +517,8 @@ OV.Website = class } let obj = this; - let consentPopup = $('
').addClass ('ov_message_popup').appendTo (document.body); - let consentText = $('
').addClass ('ov_message_popup_text').appendTo (consentPopup); - consentText.html ('This website uses cookies. See the details at the Cookies Policy page.'); - let consentButton = $('
').html ('Accept').addClass ('ov_message_popup_button').appendTo (consentPopup); - consentButton.click (function () { + OV.ShowCookieDialog (function () { obj.cookieHandler.SetBoolVal (cookieConsentKey, true); - consentPopup.remove (); }); } };