window.jQuery = $; $(document).ready(function($) { $(".lndialog").on('click', function () { SetConsent(null) }); $(".lndialoginner").on('click', function (e) { e.stopPropagation(); return false; }); var target = $( $(".navbar-toggler").data("target")); function removeClass(){ target.removeClass("show"); } $(".navbar-toggler").on( "click", function(e){ if( target.hasClass("show") ){ target.removeClass("show"); $(window).off("click", removeClass); } else{ target.addClass("show"); $(window).on("click", removeClass); } e.stopPropagation(); return false; } ); HandleGoogleAnalytics(); }); function HandleGoogleAnalytics() { var cookie = Cookies.get("lngoogle"); if (cookie === "true") { AddGoogle(); } if (cookie == null) { SetUpConsentDialog(cookie); } } function AddGoogle() { (function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments); }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); ga('create', 'UA-145250887-1', 'auto'); ga('set', 'allowAdFeatures', false); ga('send', 'pageview'); } function SetUpConsentDialog(cookie) { cookie = cookie || Cookies.get("lngoogle"); $("#consentNo, #consentYes").hide(); if (cookie == "false") { $("#consentNo").show(); } if (cookie == "true") { $("#consentYes").show(); } $("body").addClass("showDialog"); } function SetConsent(choice) { $("body").removeClass("showDialog"); if( !choice ){ return; } var prevChoice = Cookies.get("lngoogle"); if (prevChoice === choice) { return; } Cookies.set("lngoogle", choice, { expires: 14 /* days */ }); if ((!prevChoice || prevChoice === "false") && choice == "true") { AddGoogle(); } else if (prevChoice === "true" && choice === "false") { window.location.reload(); } }