File tree Expand file tree Collapse file tree 2 files changed +40
-13
lines changed
Expand file tree Collapse file tree 2 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,7 @@ define([
2121 "use strict" ;
2222
2323 return Component . extend ( {
24- showPopUp : ko . observable ( null ) ,
25- popupText : ko . observable ( null ) ,
26- popupLink : ko . observable ( null ) ,
24+ showPopUp : ko . observable ( false ) ,
2725
2826 defaults : {
2927 template : "Opengento_Gdpr/message"
@@ -33,16 +31,45 @@ define([
3331 * Initialize component
3432 */
3533 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+
3637 this . _super ( ) ;
3738
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 ;
4170
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 ) ;
4673 }
4774 } ) ;
4875} ) ;
Original file line number Diff line number Diff line change 1818 < div class ="popup content ">
1919 < strong data-bind ="i18n: 'Cookie Disclosure' "> </ strong >
2020 < div class ="block-content ">
21- < div data-bind ="html: notificationText "> </ div >
21+ < div data-bind ="html: getPopupText() "> </ div >
2222 < div class ="actions-toolbar ">
2323 < 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 >
2525 </ div >
2626 < 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 >
2828 </ div >
2929 </ div >
3030 </ div >
You can’t perform that action at this time.
0 commit comments