This is an automated email from the ASF dual-hosted git repository.

adityasharma pushed a commit to branch release17.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git

commit cea914ad86f8e8dde4dd256fead3f2996bacfa63
Author: Aditya Sharma <adityasha...@apache.org>
AuthorDate: Mon Feb 10 11:46:58 2020 +0530

    Implemented: Cookie Consent In E-Commerce
    (OFBIZ-11333)
    The Cookie Law is a piece of privacy legislation that requires websites to 
get consent from visitors to store or retrieve any information on their 
computer, smartphone or tablet. It was designed to protect online privacy, by 
making consumers aware of how information about them is collected and used 
online, and give them a choice to allow it or not.
    
    The EU Cookie Legislation began as a directive from the European Union. 
Some variation on the policy has since been adopted by all countries within the 
EU.
    
    The EU Cookie Legislation requires 4 actions from website owners who use 
cookies:
    1. When someone visits your website, you need to let them know that your 
site uses cookies.
    2. You need to provide detailed information regarding how that cookie data 
will be utilized.
    3. You need to provide visitors with some means of accepting or refusing 
the use of cookies in your site.
    4. If they refuse, you need to ensure that cookies will not be placed on 
their machine.
    
    Used bsgdprcookies plugin to implement the feature. Thanks Deepak Nigam for 
initiating and providing initial patch. Thanks Deepak Nigam, Pierre Smits, 
Michael Brohl, Jacques Le Roux and Swapnil M Mane for inputs.
---
 ecommerce/data/DemoWebSitePublishPointData.xml     |  20 ++
 ecommerce/webapp/ecommerce/WEB-INF/controller.xml  |   6 +
 .../webapp/ecommerce/js/bsgdprcookies/.gitignore   |   1 +
 .../webapp/ecommerce/js/bsgdprcookies/LICENSE      |  21 ++
 .../webapp/ecommerce/js/bsgdprcookies/README.MD    | 139 ++++++++++
 .../ecommerce/js/bsgdprcookies/demo_advanced.html  |  66 +++++
 .../ecommerce/js/bsgdprcookies/demo_simple.html    |  53 ++++
 .../js/bsgdprcookies/jquery.bs.gdpr.cookies.js     | 289 +++++++++++++++++++++
 .../js/bsgdprcookies/jquery.bs.gdpr.cookies.min.js |  18 ++
 ecommerce/widget/CommonScreens.xml                 |  12 +
 ecommerce/widget/Theme.xml                         |   1 +
 11 files changed, 626 insertions(+)

diff --git a/ecommerce/data/DemoWebSitePublishPointData.xml 
b/ecommerce/data/DemoWebSitePublishPointData.xml
index 587a0f4..edc0419 100644
--- a/ecommerce/data/DemoWebSitePublishPointData.xml
+++ b/ecommerce/data/DemoWebSitePublishPointData.xml
@@ -98,4 +98,24 @@ under the License.
         contentName="Store Policies 2" description="Store Policies 2 
Description" mimeTypeId="text/html" localeString="en_US" 
createdDate="2001-05-13 12:00:00.000" createdByUserLogin="admin"/>
     <ContentAssoc contentId="WebStoreCONTENT" contentIdTo="STORE_POLICIES2" 
mapKey="policies2" contentAssocTypeId="SUB_CONTENT"
         fromDate="2001-05-13 12:00:00.000" createdDate="2001-05-13 
12:00:00.000" createdByUserLogin="admin"/>
+
+    <DataResource dataResourceId="COOKIE_POLICY" 
dataResourceTypeId="ELECTRONIC_TEXT" mimeTypeId="text/html" 
localeString="en_US" isPublic="Y" dataResourceName="Store Policies"/>
+    <ElectronicText dataResourceId="COOKIE_POLICY">
+        <textData><![CDATA[
+            <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed 
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+                Ut enim ad minim veniam, quis nostrud exercitation ullamco 
laboris nisi ut aliquip ex ea commodo consequat.
+                Duis aute irure dolor in reprehenderit in voluptate velit esse 
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+            </p>
+            <p>
+                Sed ut perspiciatis unde omnis iste natus error sit voluptatem 
accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo 
inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
+                Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut 
odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem 
sequi nesciunt.
+                Neque porro quisquam est, qui dolorem ipsum quia dolor sit 
amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora 
incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
+                Ut enim ad minima veniam, quis nostrum exercitationem ullam 
corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis 
autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil 
molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla 
pariatur?
+            </p>
+        ]]></textData>
+    </ElectronicText>
+    <Content contentId="COOKIE_POLICY" contentTypeId="DOCUMENT" 
ownerContentId="WebStoreCONTENT" dataResourceId="COOKIE_POLICY"
+            contentName="Cookie Policy" description="Cookie Policy 
Description" mimeTypeId="text/html" localeString="en_US" 
createdDate="2001-05-13 12:00:00.000" createdByUserLogin="admin"/>
+    <ContentAssoc contentId="WebStoreCONTENT" contentIdTo="COOKIE_POLICY" 
mapKey="cookiePolicy" contentAssocTypeId="SUB_CONTENT"
+                fromDate="2001-05-13 12:00:00.000" createdDate="2001-05-13 
12:00:00.000" createdByUserLogin="admin"/>
 </entity-engine-xml>
diff --git a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml 
b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
index 23a5e9c..b193392 100644
--- a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
+++ b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
@@ -125,6 +125,11 @@ under the License.
     <request-map uri="main"><security https="false" auth="false"/><response 
name="success" type="view" value="main" save-current-view="true"/></request-map>
     <request-map uri="policies"><security https="false" 
auth="false"/><response name="success" type="view" 
value="policies"/></request-map>
 
+    <request-map uri="CookiePolicy">
+        <security https="false" auth="false"/>
+        <response name="success" type="view" value="CookiePolicy"/>
+    </request-map>
+
     <!-- Session Setting Requests -->
     <request-map uri="setSessionLocale">
         <security https="false" auth="false"/>
@@ -1875,6 +1880,7 @@ under the License.
     <view-map name="error" page="/error/error.jsp"/>
     <view-map name="main" type="screen" 
page="component://ecommerce/widget/CommonScreens.xml#main"/>
     <view-map name="policies" type="screen" 
page="component://ecommerce/widget/CommonScreens.xml#policies"/>
+    <view-map name="CookiePolicy" type="screen" 
page="component://ecommerce/widget/CommonScreens.xml#CookiePolicy"/>
     <view-map name="login" type="screen" 
page="component://ecommerce/widget/CommonScreens.xml#login"/>
     <view-map name="requirePasswordChange" type="screen" 
page="component://ecommerce/widget/CommonScreens.xml#requirePasswordChange"/>
 
diff --git a/ecommerce/webapp/ecommerce/js/bsgdprcookies/.gitignore 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/.gitignore
new file mode 100644
index 0000000..6aaee57
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/.gitignore
@@ -0,0 +1 @@
+jquery-3.3.1.min.js
diff --git a/ecommerce/webapp/ecommerce/js/bsgdprcookies/LICENSE 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/LICENSE
new file mode 100644
index 0000000..66f3720
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Aleksander Woźnica
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/ecommerce/webapp/ecommerce/js/bsgdprcookies/README.MD 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/README.MD
new file mode 100644
index 0000000..a6d2e19
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/README.MD
@@ -0,0 +1,139 @@
+# bsgdprcookies by Aleksander Woźnica
+A jQuery based plugin that shows bootstrap modal with cookie info. It is 
GDPR/RODO compatible. The plugin shows the message on the users first visit and 
then every 30 days (by default). 
+
+Here is a demo page hosted by 
[jqueryscript.net](https://www.jqueryscript.net/demo/GDPR-Cookie-Consent-Bootstrap-4-bsgdprcookies/)
+
+You can choose between two options:
+* Simple (message with accept button)
+
+![simple_screenshot](https://user-images.githubusercontent.com/33174446/43984662-3e155618-9d02-11e8-8e89-288c3fb27779.png)
+* Advanced (message, customize and accept button)
+
+![advanced_screenshot](https://user-images.githubusercontent.com/33174446/43984678-4c82dfe0-9d02-11e8-8330-979f46bbd00c.png)
+
+## Usage
+1. Include Bootstrap 
+> Here is how: https://getbootstrap.com/docs/4.1/getting-started/introduction/
+2. Include plugin script __(must be after jQuery)__
+```html
+<script src="jquery.bs.gdpr.cookies.js"></script>
+```
+3. Initialise __bsgdprcookies__
+```javascript
+// Example with default settings
+$(document).ready(function() {
+    $('body').bsgdprcookies();
+});
+```
+```javascript
+// Example with custom settings
+var settings = {
+    message: '(...)',
+    messageMaxHeightPercent: 30,
+    delay: 1000,
+    OnAccept : function() {
+        console.log('Yay! User accepted your cookies window!');
+    }
+}
+
+$(document).ready(function() {
+    $('body').bsgdprcookies(settings);
+});
+```
+
+If you want to give the user possibility to choose again, add html button: 
+```html
+<button id="cookiesBtn" role="button">Choose!</button>
+```
+and javascript code:
+```javascript
+//(...)
+$('#cookiesBtn').on('click', function(){
+    $('body').bsgdprcookies(settings, 'reinit');
+});
+```
+
+More examples can be found in the repository.
+
+## Settings
+Setting | Default Value | Description
+------ | ------------- | -----------
+id | 'bs-gdpr-cookies-modal' | id of the modal
+class | empty | additional modal classes
+title | 'Cookies & Privacy Policy' | modal title
+backdrop | 'static' |  A click area for dismissing shown modals when clicking 
outside the modal
+message | 'Your cookie message...' | Message
+messageScrollBar | false | Attach vertical scroll to the message (requires to 
specify messageMaxHeightPercent)
+messageMaxHeightPercent | 25 | Max message height in %
+delay | 1500 | Delay before showing modal (in ms)
+expireDays | 30 | Days to show the accept modal again
+moreLinkActive | true | Adds more link at the end of the message
+moreLinkLabel | 'More informations..' | More link text
+moreLinkNewTab | true | Open new tab when user clicks more link
+moreLink | 'privacy-policy.php' | More link 
+acceptButtonLabel | 'Accept' | Accept button text
+allowAdvancedOptions | false | Activate advanced options (customize button)
+advancedTitle | 'Select which cookies you want to accept' | Text above 
advanced options checkboxes
+advancedAutoOpenDelay | 1000 | Time (in ms) to automatically show customize 
options (when "reinit" is set)
+advancedButtonLabel | 'Customize' | Customize button text
+OnAccept | function() {} | Specify what to do after acceptance
+advancedCookiesToSelect | | see below
+
+## How to set custom cookies to select (__advancedCookiesToSelect__)
+
+Setting | Description
+------- | -----------
+name | Custom cookie name
+title | Checkbox label
+description | Description displayed when hovering
+isFixed | If __true__ the option will always be selected
+
+```javascript
+// Default values
+advancedCookiesToSelect: [
+    {
+        name: 'necessary',
+        title: 'Necessary',
+        description: 'Required for the site to work properly',
+        isFixed: true
+    },
+    {
+        name: 'preferences',
+        title: 'Site Preferences',
+        description: 'Required for saving your site preferences, e.g. 
remembering your username etc.',
+        isFixed: false
+    },
+    {
+        name: 'analytics',
+        title: 'Analytics',
+        description: 'Required to collect site visits, browser types, etc.',
+        isFixed: false
+    },
+    {
+        name: 'marketing',
+        title: 'Marketing',
+        description: 'Required to marketing, e.g. newsletters, social media, 
etc',
+        isFixed: false
+    }
+],
+```
+
+## Methods
+
+`$.fn.bsgdprcookies.GetUserPreferences` - returns user preferences saved in 
cookie
+
+`$.fn.bsgdprcookies.PreferenceExists` - check if user preference exists in 
cookie (returns true/false)
+
+## Styling
+
+I dont include any css files. Feel free to adapt it to your website design!
+
+## Author
+
+[Aleksander Woźnica](https://github.com/Aleksander98)
+
+## License
+
+This plugin is available under the MIT license.
+
+> The plugin has been inspired by 
[ihavecookies](https://github.com/ketanmistry/ihavecookies)
diff --git a/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_advanced.html 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_advanced.html
new file mode 100644
index 0000000..9d7eca7
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_advanced.html
@@ -0,0 +1,66 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <!-- Required meta tags -->
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, 
shrink-to-fit=no">
+
+    <!-- Bootstrap CSS -->
+    <link rel="stylesheet" 
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
+
+    <title>Hello, world!</title>
+    <style>
+        .jumbotron {
+            margin-top: 50px;
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <div class="row">
+            <div class="col-sm-12">
+                <div class="jumbotron">
+                    <h1 class="display-4">bsgdprcookies by Aleksander 
Woźnica</h1>
+                    <p class="lead">A jQuery based plugin that shows bootstrap 
modal with cookie info. It is GDPR/RODO compatible. The plugin shows the 
message on the users first visit and then every 30 days (by default).</p>
+                    <hr class="my-4">
+                    <button id="cookiesBtn" class="btn btn-primary btn-lg" 
role="button">Advanced Version</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    
+
+    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
+    <script src="jquery-3.3.1.min.js"></script>
+    <script 
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"; 
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
 crossorigin="anonymous"></script>
+    <script 
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"; 
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
 crossorigin="anonymous"></script>
+
+    <!-- Cookies JavaScript -->
+    <script src="jquery.bs.gdpr.cookies.js"></script>
+    <script type="text/javascript">
+        var settings = {
+            message: 'This is your cookies message. Lorem ipsum dolor sit 
amet, consectetur adipiscing elit. Etiam scelerisque, magna quis iaculis 
vulputate, ipsum sem commodo risus, sed egestas ipsum neque ut orci. Nulla 
ultrices dignissim pharetra. Pellentesque nec placerat dui. Mauris porta risus 
vitae nulla rutrum convallis. Aliquam elementum consequat ligula, sed malesuada 
nunc. Nam imperdiet a eros ac imperdiet. <b> Read more  ',
+            moreLinkLabel: 'here.</b>',
+            messageMaxHeightPercent: 30,
+            delay: 1000,
+            allowAdvancedOptions: true,
+            OnAccept : function() {
+                console.log('Yay! User accepted your cookies window!');
+                console.log('User preferences');
+                var preferences = $.fn.bsgdprcookies.GetUserPreferences();
+                console.log(preferences);
+
+            }
+        }
+
+        $(document).ready(function() {
+            $('body').bsgdprcookies(settings);
+
+            $('#cookiesBtn').on('click', function(){
+                $('body').bsgdprcookies(settings, 'reinit');
+            });
+        });
+    </script>
+</body>
+</html>
\ No newline at end of file
diff --git a/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_simple.html 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_simple.html
new file mode 100644
index 0000000..5068be0
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/demo_simple.html
@@ -0,0 +1,53 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <!-- Required meta tags -->
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, 
shrink-to-fit=no">
+
+    <!-- Bootstrap CSS -->
+    <link rel="stylesheet" 
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"; 
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
 crossorigin="anonymous">
+
+    <title>Hello, world!</title>
+</head>
+<body>
+    <div class="container" style="margin-top: 50px;">
+        <div class="row">
+            <div class="col-sm-12">
+                <div class="jumbotron">
+                    <h1 class="display-4">bsgdprcookies by Aleksander 
Woźnica</h1>
+                    <p class="lead">A jQuery based plugin that shows bootstrap 
modal with cookie info. It is GDPR/RODO compatible. The plugin shows the 
message on the users first visit and then every 30 days (by default).</p>
+                    <hr class="my-4">
+                    <button id="cookiesBtn" class="btn btn-primary btn-lg" 
role="button">Simple Version</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
+    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"; 
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
 crossorigin="anonymous"></script>
+    <script 
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"; 
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
 crossorigin="anonymous"></script>
+    <script 
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"; 
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
 crossorigin="anonymous"></script>
+    <!-- Cookies JavaScript -->
+    <script src="jquery.bs.gdpr.cookies.js"></script>
+    <script type="text/javascript">
+        var settings = {
+            message: 'This is your cookies message. Lorem ipsum dolor sit 
amet, consectetur adipiscing elit. Etiam scelerisque, magna quis iaculis 
vulputate, ipsum sem commodo risus, sed egestas ipsum neque ut orci. Nulla 
ultrices dignissim pharetra. Pellentesque nec placerat dui. Mauris porta risus 
vitae nulla rutrum convallis. Aliquam elementum consequat ligula, sed malesuada 
nunc. Nam imperdiet a eros ac imperdiet. <b> Read more  ',
+            moreLinkLabel: 'here.</b>',
+            messageMaxHeightPercent: 30,
+            delay: 1000,
+            OnAccept : function() {
+                console.log('Yay! User accepted your cookies window!');
+            }
+        }
+
+        $(document).ready(function() {
+            $('body').bsgdprcookies(settings);
+
+            $('#cookiesBtn').on('click', function(){
+                $('body').bsgdprcookies(settings, 'reinit');
+            });
+        });
+    </script>
+</body>
+</html>
\ No newline at end of file
diff --git 
a/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.js 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.js
new file mode 100644
index 0000000..f887673
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.js
@@ -0,0 +1,289 @@
+/*!
+ * Name: Bootstrap GDPR Cookies
+ * Description: jQuery based plugin that shows bootstrap modal with cookie info
+ * Version: v1.0
+ *
+ * Copyright (c) 2018 Aleksander Woźnica
+ * Licensed under the MIT license: 
http://www.opensource.org/licenses/mit-license.php
+ * Inspired by: https://github.com/ketanmistry/ihavecookies
+ * Cookies Create/Read/Delete from https://www.quirksmode.org/js/cookies.html
+ */
+
+(function($) {
+
+    $.fn.bsgdprcookies = function(options, event) {
+
+        var $element = $(this);
+        var cookieShow = ReadCookie('CookieShow');
+        var cookiePreferences = ReadCookie('CookiePreferences');
+
+        // Set default settings
+        var settings = $.extend({
+            id: 'bs-gdpr-cookies-modal',
+            class: '',
+            title: 'Cookies & Privacy Policy',
+            backdrop: 'static',
+            message: 'Your cookie message...',
+            messageScrollBar: false,
+            messageMaxHeightPercent: 25,
+            delay: 1500,
+            expireDays: 30,
+            moreLinkActive: true,
+            moreLinkLabel: 'More informations..',
+            moreLinkNewTab: true,
+            moreLink: 'privacy-policy.php',
+            acceptButtonLabel: 'Accept',
+            allowAdvancedOptions: false,
+            advancedTitle: 'Select which cookies you want to accept',
+            advancedAutoOpenDelay: 1000,
+            advancedButtonLabel: 'Customize',
+            advancedCookiesToSelect: [
+                {
+                    name: 'necessary',
+                    title: 'Necessary',
+                    description: 'Required for the site to work properly',
+                    isFixed: true
+                },
+                {
+                    name: 'preferences',
+                    title: 'Site Preferences',
+                    description: 'Required for saving your site preferences, 
e.g. remembering your username etc.',
+                    isFixed: false
+                },
+                {
+                    name: 'analytics',
+                    title: 'Analytics',
+                    description: 'Required to collect site visits, browser 
types, etc.',
+                    isFixed: false
+                },
+                {
+                    name: 'marketing',
+                    title: 'Marketing',
+                    description: 'Required to marketing, e.g. newsletters, 
social media, etc',
+                    isFixed: false
+                }
+            ],
+            OnAccept: function() {}
+        }, options);
+
+        if(!cookieShow || !cookiePreferences || event == 'reinit') {
+
+            // Make sure that other instances are gone
+            DisposeModal(settings.id);
+
+            var modalBody = '';
+            var modalButtons = '';
+            var modalBodyStyle = '';
+            var moreLink = '';
+
+            // Generate more link
+            if(settings.moreLinkActive == true) {
+                if(settings.moreLinkNewTab == true) {
+                    moreLink = '<a href="' + settings.moreLink + '" 
target="_blank" rel="noopener noreferrer" id="' + settings.id + '-more-link">' 
+ settings.moreLinkLabel + '</a>';
+                }
+                else {
+                    moreLink = '<a href="' + settings.moreLink + '" id="' + 
settings.id + '-more-link">' + settings.moreLinkLabel + '</a>';
+                }
+            }
+
+
+            if(settings.allowAdvancedOptions === true) {
+                modalButtons = '<button id="' + settings.id + '-advanced-btn" 
type="button" class="btn btn-secondary">' + settings.advancedButtonLabel + 
'</button><button id="' + settings.id + '-accept-btn" type="button" class="btn 
btn-primary" data-dismiss="modal">' + settings.acceptButtonLabel + '</button>';
+
+                // Generate list of available advanced settings
+                var advancedCookiesToSelectList = '';
+
+                preferences = JSON.parse(cookiePreferences);
+                $.each(settings.advancedCookiesToSelect, function(index, 
field) {
+                    if (field.name !== '' && field.title !== '') {
+
+                        var cookieDisabledText = '';
+                        if(field.isFixed == true) {
+                            cookieDisabledText = ' checked="checked" 
disabled="disabled"';
+                        }       
+
+                        var cookieDescription = '';
+                        if (field.description !== false) {
+                            cookieDescription = ' title="' + field.description 
+ '"';
+                        }
+
+                        var fieldID = settings.id + '-option-' + field.name;
+
+                        advancedCookiesToSelectList += '<li><input 
type="checkbox" id="' + fieldID + '" name="bsgdpr[]" value="' + field.name + '" 
data-auto="on" ' + cookieDisabledText + '> <label name="bsgdpr[]" 
data-toggle="tooltip" data-placement="right" for="' + fieldID + '"' + 
cookieDescription + '>' + field.title + '</label></li>';
+                    }
+                });
+
+                modalBody = '<div id="' + settings.id + '-message">' + 
settings.message + moreLink + '</div>' + '<div id="' + settings.id + 
'-advanced-types" style="display:none; margin-top: 10px;"><h5 id="' + 
settings.id + '-advanced-title">' + settings.advancedTitle + '</h5>' + 
advancedCookiesToSelectList + '</div>';
+            }
+            else {
+                modalButtons = '<button id="' + settings.id + '-accept-btn" 
type="button" class="btn btn-primary" data-dismiss="modal">' + 
settings.acceptButtonLabel + '</button>';
+
+                modalBody ='<div id="' + settings.id + '-message">' + 
settings.message + moreLink + '</div>';
+            }
+            
+            if(settings.messageScrollBar == true) {
+                modalBodyStyle = 'style="overflow-y: scroll; max-height: ' + 
settings.messageMaxHeightPercent + '%"';
+            }
+
+            var modal = '<div class="modal fade ' + settings.class + '" id="' 
+ settings.id + '" tabindex="-1" role="dialog" aria-labelledby="' + settings.id 
+ '-title" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" 
role="document"><div class="modal-content"><div class="modal-header"><h5 
class="modal-title" id="' + settings.id + '-title">' + settings.title + 
'</h5></div><div id="' + settings.id + '-body" class="modal-body" ' + 
modalBodyStyle + '>' + modalBody + '</div [...]
+
+            // Show Modal
+            setTimeout(function() {
+                $($element).append(modal);
+
+                $('#' + settings.id).modal({keyboard: false, backdrop: 
settings.backdrop});
+
+                if (event === 'reinit' && settings.allowAdvancedOptions === 
true) {
+
+                    setTimeout(function(){
+                        $('#' + settings.id + 
'-advanced-btn').trigger('click');
+                        $.each(preferences, function(index, field) {
+                            $('#' + settings.id + '-option-' + 
field).prop('checked', true);
+                        });
+                    }, settings.advancedAutoOpenDelay)
+                }
+            }, settings.delay);
+
+            // When user clicks accept set cookie and close modal
+            $('body').on('click','#' + settings.id + '-accept-btn', function(){
+
+                // Set show cookie
+                CreateCookie('CookieShow', true, settings.expireDays);
+                DisposeModal(settings.id);
+
+                // If 'data-auto' is set to ON, tick all checkboxes because 
the user has not chosen any option
+                $('input[name="bsgdpr[]"][data-auto="on"]').prop('checked', 
true);
+
+                // Clear user preferences cookie
+                DeleteCookie('CookiePreferences');
+
+                // Set user preferences cookie
+                var preferences = [];
+                $.each($('input[name="bsgdpr[]"]').serializeArray(), 
function(i, field){
+                    preferences.push(field.value);
+                });
+                CreateCookie('CookiePreferences', JSON.stringify(preferences), 
365);
+
+                // Run callback function
+                settings.OnAccept.call(this);
+            });
+
+            // Show advanced options
+            $('body').on('click', '#' + settings.id + '-advanced-btn', 
function(){
+                // Uncheck all checkboxes except for the disabled ones
+                $('input[name="bsgdpr[]"]:not(:disabled)').attr('data-auto', 
'off').prop('checked', false);
+                
+                $('label[name="bsgdpr[]"]').tooltip({offset: '0, 10'});
+
+                // Show advanced checkboxes
+                $('#' + settings.id + '-advanced-types').slideDown('fast', 
function(){
+                    $('#' + settings.id + '-advanced-btn').prop('disabled', 
true);
+                });
+
+                // Scroll content to bottom if scrollbar option is active
+                if(settings.messageScrollBar == true) {
+                    setTimeout(function() {
+                        bodyID = settings.id + '-body';
+                        var div = document.getElementById(bodyID);
+                        $('#' + bodyID).animate({
+                            scrollTop: div.scrollHeight - div.clientHeight
+                        }, 800);
+                    }, 500);
+                }
+            });
+        }
+        else {
+            var cookieValue = true;
+            if (cookieShow == 'false') {
+                cookieValue = false;
+            }
+            CreateCookie('CookieShow', cookieValue, settings.expireDays);
+            DisposeModal(settings.id);
+        }
+    }
+
+    /**
+     * Returns user preferences saved in cookie
+     */
+    $.fn.bsgdprcookies.GetUserPreferences = function() {
+        var preferences = ReadCookie('CookiePreferences');
+        return JSON.parse(preferences);
+    };
+
+    /**
+     * Check if user preference exists in cookie
+     * 
+     * @param {string} pref Preference to check
+     */
+    $.fn.bsgdprcookies.PreferenceExists = function(pref) {
+        var preferences = $.fn.bsgdprcookies.GetUserPreferences();
+
+        if (ReadCookie('CookieShow') === false) {
+            return false;
+        }
+        if (preferences === false || preferences.indexOf(pref) === -1) {
+            return false;
+        }
+
+        return true;
+    };
+
+
+    /**
+     * Hide then delete bs modal
+     * 
+     * @param {string} id Modal ID without '#'
+     */
+    function DisposeModal(id) {
+        id = '#' + id;
+        $(id).modal('hide');
+        $(id).on('hidden.bs.modal', function (e) {
+            $(this).modal('dispose');
+            $(id).remove();
+        });
+    }
+
+    /**
+     * Sets Cookie
+     * 
+     * @param {string} name Name of the cookie which you want to create
+     * @param {boolean} value Value for the created cookie
+     * @param {number} days Expire days
+     */
+    function CreateCookie(name, value, days) {
+        if (days) {
+            var date = new Date();
+            date.setTime(date.getTime() + (days*24*60*60*1000));
+            var expires = "; expires=" + date.toGMTString();
+        }
+        else var expires = "";
+        document.cookie = name + "=" + value + expires + "; path=/";
+    }
+    
+
+    /**
+     * Gets Cookie called 'name'
+     * 
+     * @param {string} name Name of the cookie to read
+     */
+    function ReadCookie(name) {
+        var nameEQ = name + "=";
+        var ca = document.cookie.split(';');
+        for(var i=0; i < ca.length; i++) {
+            var c = ca[i];
+            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
+            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, 
c.length);
+        }
+        return null;
+    }
+    
+    /**
+     * Deletes Cookie called 'name;
+     * 
+     * @param {string} name Name of the cookie which you want to delete
+     */
+    function DeleteCookie(name) {
+        CreateCookie(name, "", -1);
+    }    
+
+}(jQuery));
\ No newline at end of file
diff --git 
a/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.min.js 
b/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.min.js
new file mode 100644
index 0000000..362f031
--- /dev/null
+++ b/ecommerce/webapp/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.min.js
@@ -0,0 +1,18 @@
+(function($){$.fn.bsgdprcookies=function(options,event){var 
$element=$(this);var cookieShow=ReadCookie('CookieShow');var 
cookiePreferences=ReadCookie('CookiePreferences');var 
settings=$.extend({id:'bs-gdpr-cookies-modal',class:'',title:'Cookies & Privacy 
Policy',backdrop:'static',message:'Your cookie 
message...',messageScrollBar:!1,messageMaxHeightPercent:25,delay:1500,expireDays:30,moreLinkActive:!0,moreLinkLabel:'More
 informations..',moreLinkNewTab:!0,moreLink:'privacy-policy.php',acce [...]
+else{moreLink='<a href="'+settings.moreLink+'" 
id="'+settings.id+'-more-link">'+settings.moreLinkLabel+'</a>'}}
+if(settings.allowAdvancedOptions===!0){modalButtons='<button 
id="'+settings.id+'-advanced-btn" type="button" class="btn 
btn-secondary">'+settings.advancedButtonLabel+'</button><button 
id="'+settings.id+'-accept-btn" type="button" class="btn btn-primary" 
data-dismiss="modal">'+settings.acceptButtonLabel+'</button>';var 
advancedCookiesToSelectList='';preferences=JSON.parse(cookiePreferences);$.each(settings.advancedCookiesToSelect,function(index,field){if(field.name!==''&&field.title!=='')
 [...]
+var cookieDescription='';if(field.description!==!1){cookieDescription=' 
title="'+field.description+'"'}
+var 
fieldID=settings.id+'-option-'+field.name;advancedCookiesToSelectList+='<li><input
 type="checkbox" id="'+fieldID+'" name="bsgdpr[]" value="'+field.name+'" 
data-auto="on" '+cookieDisabledText+'> <label name="bsgdpr[]" 
data-toggle="tooltip" data-placement="right" 
for="'+fieldID+'"'+cookieDescription+'>'+field.title+'</label></li>'}});modalBody='<div
 id="'+settings.id+'-message">'+settings.message+moreLink+'</div>'+'<div 
id="'+settings.id+'-advanced-types" style="display:none; margin-to [...]
+else{modalButtons='<button id="'+settings.id+'-accept-btn" type="button" 
class="btn btn-primary" 
data-dismiss="modal">'+settings.acceptButtonLabel+'</button>';modalBody='<div 
id="'+settings.id+'-message">'+settings.message+moreLink+'</div>'}
+if(settings.messageScrollBar==!0){modalBodyStyle='style="overflow-y: scroll; 
max-height: '+settings.messageMaxHeightPercent+'%"'}
+var modal='<div class="modal fade '+settings.class+'" id="'+settings.id+'" 
tabindex="-1" role="dialog" aria-labelledby="'+settings.id+'-title" 
aria-hidden="true"><div class="modal-dialog modal-dialog-centered" 
role="document"><div class="modal-content"><div class="modal-header"><h5 
class="modal-title" 
id="'+settings.id+'-title">'+settings.title+'</h5></div><div 
id="'+settings.id+'-body" class="modal-body" 
'+modalBodyStyle+'>'+modalBody+'</div><div 
class="modal-footer">'+modalButtons+'</d [...]
+else{var cookieValue=!0;if(cookieShow=='false'){cookieValue=!1}
+CreateCookie('CookieShow',cookieValue,settings.expireDays);DisposeModal(settings.id)}}
+$.fn.bsgdprcookies.GetUserPreferences=function(){var 
preferences=ReadCookie('CookiePreferences');return 
JSON.parse(preferences)};$.fn.bsgdprcookies.PreferenceExists=function(pref){var 
preferences=$.fn.bsgdprcookies.GetUserPreferences();if(ReadCookie('CookieShow')===!1){return!1}
+if(preferences===!1||preferences.indexOf(pref)===-1){return!1}
+return!0};function 
DisposeModal(id){id='#'+id;$(id).modal('hide');$(id).on('hidden.bs.modal',function(e){$(this).modal('dispose');$(id).remove()})}
+function CreateCookie(name,value,days){if(days){var date=new 
Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; 
expires="+date.toGMTString()}
+else var expires="";document.cookie=name+"="+value+expires+"; path=/"}
+function ReadCookie(name){var nameEQ=name+"=";var 
ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var 
c=ca[i];while(c.charAt(0)==' 
')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return 
c.substring(nameEQ.length,c.length)}
+return null}
+function DeleteCookie(name){CreateCookie(name,"",-1)}}(jQuery))
\ No newline at end of file
diff --git a/ecommerce/widget/CommonScreens.xml 
b/ecommerce/widget/CommonScreens.xml
index d7dde92..00e5cd8 100644
--- a/ecommerce/widget/CommonScreens.xml
+++ b/ecommerce/widget/CommonScreens.xml
@@ -423,4 +423,16 @@ under the License.
             </widgets>
         </section>
     </screen>
+
+    <screen name="CookiePolicy">
+        <section>
+            <widgets>
+                <decorator-screen name="main-decorator" 
location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <sub-content content-id="WebStoreCONTENT" 
map-key="cookiePolicy"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>
diff --git a/ecommerce/widget/Theme.xml b/ecommerce/widget/Theme.xml
index d4603e1..5a3ec63 100644
--- a/ecommerce/widget/Theme.xml
+++ b/ecommerce/widget/Theme.xml
@@ -37,6 +37,7 @@ under the License.
         <property name="VT_HDR_JAVASCRIPT['add']" 
value="/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" 
value="/ecommerce/js/bootstrap/js/bootstrap-4.3.1.min.js"/>
         <property name="VT_HDR_JAVASCRIPT['add']" 
value="/ecommerce/js/bootstrap/js/bootstrap.bundle-4.3.1.min.js"/>
+        <property name="VT_HDR_JAVASCRIPT['add']" 
value="/ecommerce/js/bsgdprcookies/jquery.bs.gdpr.cookies.min.js"/>
 
         <!--Css style-->
         <property name="VT_STYLESHEET['add']" 
value="/ecommerce/js/bootstrap/css/bootstrap-4.3.1.min.css"/>

Reply via email to