| @@ -1,20 +1,21 @@ | ||
| 1 | 1 | ( function () { |
| 2 | + var overlay = document.getElementById( 'eu-cookie-law' ), | |
| 3 | + widget = document.querySelector( '.widget_eu_cookie_law_widget' ); | |
| 4 | + | |
| 5 | + if ( null === widget || null === overlay ) { | |
| 6 | + return; | |
| 7 | + } | |
| 8 | + | |
| 2 | 9 | var cookieValue = document.cookie.replace( |
| 3 | - /(?:(?:^|.*;\s*)eucookielaw\s*\=\s*([^;]*).*$)|^.*$/, | |
| 10 | + /(?:(?:^|.*;\s*)eucookielaw\s*=\s*([^;]*).*$)|^.*$/, | |
| 4 | 11 | '$1' |
| 5 | 12 | ), |
| 6 | - overlay = document.getElementById( 'eu-cookie-law' ), | |
| 7 | - widget = document.querySelector( '.widget_eu_cookie_law_widget' ), | |
| 8 | 13 | inCustomizer = widget && widget.hasAttribute( 'data-customize-widget-id' ), |
| 9 | 14 | getScrollTop, |
| 10 | 15 | initialScrollPosition, |
| 11 | 16 | scrollFunction; |
| 12 | 17 | |
| 13 | - if ( null === widget || null === overlay ) { | |
| 14 | - return; | |
| 15 | - } | |
| 16 | - | |
| 17 | 18 | /** |
| 18 | 19 | * Gets the amount that the window is scrolled. |
| 19 | 20 | * |
| 20 | 21 | * @return int The distance from the top of the document. |
| @@ -28,9 +29,9 @@ | ||
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | if ( overlay.classList.contains( 'ads-active' ) ) { |
| 31 | 32 | var adsCookieValue = document.cookie.replace( |
| 32 | - /(?:(?:^|.*;\s*)personalized-ads-consent\s*\=\s*([^;]*).*$)|^.*$/, | |
| 33 | + /(?:(?:^|.*;\s*)personalized-ads-consent\s*=\s*([^;]*).*$)|^.*$/, | |
| 33 | 34 | '$1' |
| 34 | 35 | ); |
| 35 | 36 | if ( '' !== cookieValue && '' !== adsCookieValue && ! inCustomizer ) { |
| 36 | 37 | overlay.parentNode.removeChild( overlay ); |
| @@ -89,9 +90,8 @@ | ||
| 89 | 90 | |
| 90 | 91 | overlay.classList.add( 'hide' ); |
| 91 | 92 | setTimeout( function () { |
| 92 | 93 | overlay.parentNode.removeChild( overlay ); |
| 93 | - var widgetSection = document.querySelector( '.widget.widget_eu_cookie_law_widget' ); | |
| 94 | - widgetSection.parentNode.removeChild( widgetSection ); | |
| 94 | + widget.parentNode.removeChild( widget ); | |
| 95 | 95 | }, 400 ); |
| 96 | 96 | } |
| 97 | 97 | } )(); |