File tree 2 files changed +40
-13
lines changed
2 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,7 @@ define([
21
21
"use strict" ;
22
22
23
23
return Component . extend ( {
24
- showPopUp : ko . observable ( null ) ,
25
- popupText : ko . observable ( null ) ,
26
- popupLink : ko . observable ( null ) ,
24
+ showPopUp : ko . observable ( false ) ,
27
25
28
26
defaults : {
29
27
template : "Opengento_Gdpr/message"
@@ -33,16 +31,45 @@ define([
33
31
* Initialize component
34
32
*/
35
33
initialize ( ) {
34
+ var self = this ,
35
+ isBot = navigator . userAgent . toLowerCase ( ) . match ( / .+ ?(?: b o t | l i g h t h o u s e ) / ) ;
36
+
36
37
this . _super ( ) ;
37
38
38
- this . showPopUp ( ! $ . cookie ( this . cookieName ) ) ;
39
- this . popupText ( this . notificationText ) ;
40
- this . popupLink ( this . learnMore ) ;
39
+ if ( ! window . localStorage . getItem ( self . cookieName ) && ! isBot ) {
40
+ self . showPopUp ( true ) ;
41
+ }
42
+ } ,
43
+
44
+ /**
45
+ * Get Popup Text
46
+ * @returns {string }
47
+ */
48
+ getPopupText ( ) {
49
+ var self = this ;
50
+
51
+ return self . notificationText ;
52
+ } ,
53
+
54
+ /**
55
+ * Get Popup Link
56
+ * @returns {string }
57
+ */
58
+ getPopupLink ( ) {
59
+ var self = this ;
60
+
61
+ return self . learnMore ;
62
+ } ,
63
+
64
+ /**
65
+ * Accept All Cookies
66
+ * @returns {void }
67
+ */
68
+ acceptAllCookies ( ) {
69
+ var self = this ;
41
70
42
- $ ( document ) . on ( "click" , "#enhanced-privacy-popup-agree" , function ( ) {
43
- this . showPopUp ( false ) ;
44
- $ . cookie ( this . cookieName , 1 ) ;
45
- } . bind ( this ) ) ;
71
+ window . localStorage . setItem ( self . cookieName , true , { } ) ;
72
+ self . showPopUp ( false ) ;
46
73
}
47
74
} ) ;
48
75
} ) ;
Original file line number Diff line number Diff line change 18
18
< div class ="popup content ">
19
19
< strong data-bind ="i18n: 'Cookie Disclosure' "> </ strong >
20
20
< div class ="block-content ">
21
- < div data-bind ="html: notificationText "> </ div >
21
+ < div data-bind ="html: getPopupText() "> </ div >
22
22
< div class ="actions-toolbar ">
23
23
< div class ="secondary ">
24
- < a class ="action " data-bind ="attr: {href: learnMore }, i18n: 'Read More' "> </ a >
24
+ < a class ="action " data-bind ="attr: {href: getPopupLink() }, i18n: 'Read More' "> </ a >
25
25
</ div >
26
26
< div class ="primary ">
27
- < button type ="button " class ="action primary " id ="enhanced-privacy-popup-agree " data-bind ="i18n: 'Accept' "> </ button >
27
+ < button type ="button " class ="action primary " id ="enhanced-privacy-popup-agree " data-bind ="i18n: 'Accept', click: acceptAllCookies "> </ button >
28
28
</ div >
29
29
</ div >
30
30
</ div >
You can’t perform that action at this time.
0 commit comments