128 lines
3.5 KiB
PHP
128 lines
3.5 KiB
PHP
<?php
|
|
|
|
|
|
$smarty->assign('cookiesDescriptionNecessary', $cookies_description_necessary);
|
|
$smarty->assign('cookiesDescriptionAnalytics', $cookies_description_analytics);
|
|
$smarty->assign('cookiesDescriptionTargeting', $cookies_description_targeting);
|
|
|
|
$smarty->display('compatibility_ajax_cookie_modal.html');
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function ($) {
|
|
$(document).ready(function() {
|
|
|
|
|
|
// ustaw jeśli niezdefiniowane
|
|
|
|
if ($.cookies.get('cookies_google_analytics') == null ) {
|
|
|
|
var analytics = '<?php echo $default_analytics; ?>';
|
|
|
|
checkbox1(analytics);
|
|
}
|
|
|
|
if ($.cookies.get('cookies_google_targeting') == null ) {
|
|
|
|
var targeting = '<?php echo $default_targeting; ?>';
|
|
|
|
checkbox2(targeting);
|
|
}
|
|
|
|
|
|
checkAndSetCheckbox1();
|
|
checkAndSetCheckbox2();
|
|
|
|
$('#checkbox-1').change(function() {
|
|
|
|
if ($('#checkbox-1').prop('checked')) {
|
|
|
|
console.log("checkbox-1 true");
|
|
checkbox1("true");
|
|
|
|
}else{
|
|
|
|
console.log("checkbox-1 false");
|
|
checkbox1("false");
|
|
|
|
}
|
|
|
|
checkAndSetCheckbox1();
|
|
|
|
});
|
|
|
|
|
|
$('#checkbox-2').change(function() {
|
|
|
|
if ($('#checkbox-2').prop('checked')) {
|
|
|
|
console.log("checkbox-2 true");
|
|
checkbox2("true");
|
|
|
|
}else{
|
|
|
|
console.log("checkbox-2 false");
|
|
checkbox2("false");
|
|
|
|
}
|
|
|
|
checkAndSetCheckbox2();
|
|
|
|
});
|
|
|
|
|
|
function checkAndSetCheckbox1() {
|
|
|
|
checkbox_1_value = $.cookies.get('cookies_google_analytics');
|
|
|
|
if (checkbox_1_value) {
|
|
|
|
$("#checkbox-1").prop( "checked", true );
|
|
|
|
}else{
|
|
|
|
$("#checkbox-1").prop( "checked", false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function checkAndSetCheckbox2() {
|
|
|
|
checkbox_2_value = $.cookies.get('cookies_google_targeting');
|
|
|
|
if (checkbox_2_value) {
|
|
|
|
$("#checkbox-2").prop( "checked", true );
|
|
|
|
} else {
|
|
|
|
$("#checkbox-2").prop( "checked", false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
function checkbox1(value){
|
|
|
|
var expires_at = new Date();
|
|
var years = 20;
|
|
expires_at.setTime(expires_at.getTime() + 1000 * years * 365 * 24 * 60 * 60);
|
|
$.cookies.set('cookies_google_analytics', value, {path: '/', expiresAt: expires_at});
|
|
|
|
}
|
|
|
|
function checkbox2(value){
|
|
|
|
var expires_at = new Date();
|
|
var years = 20;
|
|
expires_at.setTime(expires_at.getTime() + 1000 * years * 365 * 24 * 60 * 60);
|
|
$.cookies.set('cookies_google_targeting', value, {path: '/', expiresAt: expires_at});
|
|
|
|
}
|
|
|
|
});
|
|
});
|
|
</script>
|