blob: b7f8c7dbae8bed3e75e35162ae991a8461b4342f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
( function( $ ) {
var cookieValue = document.cookie.replace( /(?:(?:^|.*;\s*)eucookielaw\s*\=\s*([^;]*).*$)|^.*$/, '$1' ),
overlay = $( '#eu-cookie-law' ),
initialScrollPosition,
scrollFunction;
if ( overlay.hasClass( 'top' ) ) {
$( '.widget_eu_cookie_law_widget' ).addClass( 'top' );
}
if ( overlay.hasClass( 'ads-active' ) ) {
var adsCookieValue = document.cookie.replace( /(?:(?:^|.*;\s*)personalized-ads-consent\s*\=\s*([^;]*).*$)|^.*$/, '$1' );
if ( '' !== cookieValue && '' !== adsCookieValue ) {
overlay.remove();
}
} else if ( '' !== cookieValue ) {
overlay.remove();
}
$( '.widget_eu_cookie_law_widget' ).appendTo( 'body' ).fadeIn();
overlay.find( 'form' ).on( 'submit', accept );
if ( overlay.hasClass( 'hide-on-scroll' ) ) {
initialScrollPosition = $( window ).scrollTop();
scrollFunction = function() {
if ( Math.abs( $( window ).scrollTop() - initialScrollPosition ) > 50 ) {
accept();
}
};
$( window ).on( 'scroll', scrollFunction );
} else if ( overlay.hasClass( 'hide-on-time' ) ) {
setTimeout( accept, overlay.data( 'hide-timeout' ) * 1000 );
}
var accepted = false;
function accept( event ) {
if ( accepted ) {
return;
}
accepted = true;
if ( event && event.preventDefault ) {
event.preventDefault();
}
if ( overlay.hasClass( 'hide-on-scroll' ) ) {
$( window ).off( 'scroll', scrollFunction );
}
var expireTime = new Date();
expireTime.setTime( expireTime.getTime() + ( overlay.data( 'consent-expiration' ) * 24 * 60 * 60 * 1000 ) );
document.cookie = 'eucookielaw=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
if ( overlay.hasClass( 'ads-active' ) && overlay.hasClass( 'hide-on-button' ) ) {
document.cookie = 'personalized-ads-consent=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
}
overlay.fadeOut( 400, function() {
overlay.remove();
} );
}
} )( jQuery );
|