| 1 |
( function ( $ ) { |
| 2 |
|
| 3 |
var cookiebot_wpforms = { |
| 4 |
|
| 5 |
init: function () { |
| 6 |
$( document ).ready( cookiebot_wpforms.update_after_consent ); |
| 7 |
}, |
| 8 |
|
| 9 |
/** |
| 10 |
* Async wpfuuid after the visitor clicked on cookie accept |
| 11 |
*/ |
| 12 |
update_after_consent: function () { |
| 13 |
window.addEventListener( 'CookiebotOnAccept', function ( e ) { |
| 14 |
|
| 15 |
if ( Cookiebot |
| 16 |
&& Cookiebot.consent |
| 17 |
&& Cookiebot.consent.preferences |
| 18 |
&& window.wpforms |
| 19 |
&& !window.wpforms.getCookie( '_wpfuuid' ) ) { |
| 20 |
window.wpforms.setUserIndentifier(); |
| 21 |
} |
| 22 |
}, false ); |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
/** |
| 27 |
* Make global hasRequiredConsent function to check cookie consent status |
| 28 |
* |
| 29 |
* @return {boolean} |
| 30 |
*/ |
| 31 |
window.hasRequiredConsent = function hasRequiredConsent() { |
| 32 |
if ( Cookiebot && Cookiebot.consent ) { |
| 33 |
let cookie_types = cookiebot_wpforms_settings.cookie_types; |
| 34 |
let required = cookie_types.length; |
| 35 |
|
| 36 |
const consent_given = cookie_types.filter(function(cookie_type){ |
| 37 |
return Cookiebot.consent[cookie_type]; |
| 38 |
}); |
| 39 |
|
| 40 |
if( required == consent_given.length ) { |
| 41 |
return true; |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
return false; |
| 46 |
}; |
| 47 |
|
| 48 |
cookiebot_wpforms.init(); |
| 49 |
|
| 50 |
|
| 51 |
} )( jQuery ); |
| 52 |
|