1( function ( $ ) { 2 3 // set Cookie Notice 4 $.fn.setCookieNotice = function ( cookie_value ) { 5 var cnTime = new Date(), 6 cnLater = new Date(), 7 cnDomNode = $( '#cookie-notice' ), 8 cnSelf = this; 9 10 // set expiry time in seconds 11 cnLater.setTime( parseInt( cnTime.getTime() ) + parseInt( cnArgs.cookieTime ) * 1000 ); 12 13 // set cookie 14 cookie_value = cookie_value === 'accept' ? true : false; 15 document.cookie = cnArgs.cookieName + '=' + cookie_value + ';expires=' + cnLater.toGMTString() + ';' + ( cnArgs.cookieDomain !== undefined && cnArgs.cookieDomain !== '' ? 'domain=' + cnArgs.cookieDomain + ';' : '' ) + ( cnArgs.cookiePath !== undefined && cnArgs.cookiePath !== '' ? 'path=' + cnArgs.cookiePath + ';' : '' ); 16 17 // trigger custom event 18 $.event.trigger( { 19 type: "setCookieNotice", 20 value: cookie_value, 21 time: cnTime, 22 expires: cnLater 23 } ); 24 25 // hide message container 26 if ( cnArgs.hideEffect === 'fade' ) { 27 cnDomNode.fadeOut( 300, function () { 28 cnSelf.removeCookieNotice(); 29 } ); 30 } else if ( cnArgs.hideEffect === 'slide' ) { 31 cnDomNode.slideUp( 300, function () { 32 cnSelf.removeCookieNotice(); 33 } ); 34 } else { 35 cnSelf.removeCookieNotice(); 36 } 37 38 if ( cookie_value && cnArgs.redirection === '1' ) { 39 var url = window.location.protocol + '//', 40 hostname = window.location.host + '/' + window.location.pathname; 41 42 if ( cnArgs.cache === '1' ) { 43 url = url + hostname.replace( '//', '/' ) + ( window.location.search === '' ? '?' : window.location.search + '&' ) + 'cn-reloaded=1' + window.location.hash; 44 45 window.location.href = url; 46 } else { 47 url = url + hostname.replace( '//', '/' ) + window.location.search + window.location.hash; 48 49 window.location.reload( true ); 50 } 51 52 return; 53 } 54 }; 55 56 // remove Cookie Notice 57 $.fn.removeCookieNotice = function ( cookie_value ) { 58 $( '#cookie-notice' ).remove(); 59 $( 'body' ).removeClass( 'cookies-not-accepted' ); 60 }; 61 62 $( document ).ready( function () { 63 64 var cnDomNode = $( '#cookie-notice' ); 65 66 // handle set-cookie button click 67 $( document ).on( 'click', '.cn-set-cookie', function ( e ) { 68 e.preventDefault(); 69 $( this ).setCookieNotice( $( this ).data( 'cookie-set' ) ); 70 } ); 71 72 // handle on scroll 73 if ( cnArgs.onScroll == 'yes' ) { 74 var cnHandleScroll = function () { 75 var win = $( this ); 76 if ( win.scrollTop() > parseInt( cnArgs.onScrollOffset ) ) { 77 // If user scrolls at least 100 pixels 78 win.setCookieNotice( 'accept' ); 79 win.off( 'scroll', cnHandleScroll ); //remove itself after cookie accept 80 } 81 }; 82 83 $( window ).on( 'scroll', cnHandleScroll ); 84 } 85 86 // display cookie notice 87 if ( document.cookie.indexOf( 'cookie_notice_accepted' ) === -1 ) { 88 if ( cnArgs.hideEffect === 'fade' ) { 89 cnDomNode.fadeIn( 300 ); 90 } else if ( cnArgs.hideEffect === 'slide' ) { 91 cnDomNode.slideDown( 300 ); 92 } else { 93 cnDomNode.show(); 94 } 95 $( 'body' ).addClass( 'cookies-not-accepted' ); 96 } else { 97 cnDomNode.removeCookieNotice(); 98 } 99 100 } ) 101} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.