@@ -5,7 +5,7 @@ class="<?php
55 ?> hide-on-<?php echo esc_attr ( $ instance ['hide ' ] ); ?> "
66 data-hide-timeout="<?php echo intval ( $ instance ['hide-timeout ' ] ) ; ?> "
77>
8- <form action=" <?php echo esc_attr ( $ blog_url ); ?> " method="post">
8+ <form method="post">
99 <?php wp_nonce_field ( 'eucookielaw ' ); ?>
1010 <input type="hidden" name="eucookielaw" value="accept" />
1111 <input type="hidden" name="redirect_url" value="<?php echo esc_attr ( $ _SERVER ['REQUEST_URI ' ] ) ?> " />
@@ -29,13 +29,11 @@ class="<?php
2929<script type="text/javascript">
3030jQuery(function( $ ) {
3131 var overlay = $( '#eu-cookie-law' ), initialScrollPosition, scrollFunction;
32- if ( overlay.hasClass( 'hide-on-button' ) ) {
33- overlay.find( 'input.accept' ).on( 'click', accept );
34- } else if ( overlay.hasClass( 'hide-on-scroll' ) ) {
32+ overlay.find( 'form' ).on( 'submit', accept );
33+ if ( overlay.hasClass( 'hide-on-scroll' ) ) {
3534 initialScrollPosition = $( window ).scrollTop();
3635 scrollFunction = function() {
3736 if ( Math.abs( $( window ).scrollTop() - initialScrollPosition ) > 50 ) {
38- console.log($( window ).scrollTop() - initialScrollPosition);
3937 accept();
4038 }
4139 };
@@ -45,18 +43,22 @@ class="<?php
4543 }
4644
4745 var accepted = false;
48- function accept() {
46+ function accept( event ) {
4947 if ( accepted ) {
5048 return;
5149 }
5250 accepted = true;
5351
52+ if ( event && event.preventDefault ) {
53+ event.preventDefault();
54+ }
55+
5456 if ( overlay.hasClass( 'hide-on-scroll' ) ) {
5557 $( window ).off( 'scroll', scrollFunction );
5658 }
5759
5860 var expireTime = new Date();
59- expireTime.setTime( expireTime.getTime() + <?php echo $ cookie_validity ; ?> ); // 30 days
61+ expireTime.setTime( expireTime.getTime() + <?php echo $ cookie_validity ; ?> );
6062
6163 document.cookie = '<?php echo $ cookie_name ; ?> =' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
6264
0 commit comments