1/* 2 Copyright 2014 Google Inc. All rights reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17(function(window) { 18 19 if (!!window.cookieChoices) { 20 return window.cookieChoices; 21 } 22 23 var document = window.document; 24 // IE8 does not support textContent, so we should fallback to innerText. 25 var supportsTextContent = 'textContent' in document.body; 26 27 var cookieChoices = (function() { 28 29 var cookieName = 'displayCookieConsent'; 30 var cookieConsentId = 'cookieChoiceInfo'; 31 var cookieInnerId = 'cookieConsentInner'; 32 var cookieContentId = 'cookieContentWrap'; 33 var viewLinkId = 'cookiePolicyView'; 34 var dismissLinkId = 'cookieChoiceDismiss'; 35 36 function _createHeaderElement(cookieText, dismissText, linkText, linkHref) { 37 var cookieConsentElement = document.createElement('div'); 38 cookieConsentElement.id = cookieConsentId; 39 40 var cookieConsentInner = document.createElement('div'); 41 cookieConsentInner.id = cookieInnerId; 42 43 var cookieConsentContent = document.createElement('div'); 44 cookieConsentContent.id = cookieContentId; 45 46 cookieConsentElement.appendChild(cookieConsentInner); 47 cookieConsentInner.appendChild(cookieConsentContent); 48 cookieConsentContent.appendChild(_createConsentText(cookieText)); 49 50 cookieConsentContent.appendChild(_createDismissLink(dismissText)); 51 if (!!linkText && !!linkHref) { 52 cookieConsentContent.appendChild(_createInformationLink(linkText, linkHref)); 53 } 54 return cookieConsentElement; 55 } 56 57 function _createDialogElement(cookieText, dismissText, linkText, linkHref) { 58 var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' + 59 'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' + 60 'background-color:#ccc;'; 61 var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%'; 62 var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' + 63 'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;'; 64 65 var cookieConsentElement = document.createElement('div'); 66 cookieConsentElement.id = cookieConsentId; 67 68 var glassPanel = document.createElement('div'); 69 glassPanel.style.cssText = glassStyle; 70 71 var content = document.createElement('div'); 72 content.style.cssText = contentStyle; 73 74 var dialog = document.createElement('div'); 75 dialog.style.cssText = dialogStyle; 76 77 var dismissLink = _createDismissLink(dismissText);
78 dismissLink.style.display = 'block'; 79 dismissLink.style.textAlign = 'right'; 80 dismissLink.style.marginTop = '8px'; 81 82 content.appendChild(_createConsentText(cookieText)); 83 if (!!linkText && !!linkHref) { 84 content.appendChild(_createInformationLink(linkText, linkHref)); 85 } 86 content.appendChild(dismissLink); 87 dialog.appendChild(content); 88 cookieConsentElement.appendChild(glassPanel); 89 cookieConsentElement.appendChild(dialog); 90 return cookieConsentElement; 91 } 92 93 function _setElementText(element, text) { 94 /** 95 if (supportsTextContent) { 96 element.textContent = text; 97 } else { 98 element.innerText = text; 99 } 100 **/ 101 102 element.innerHTML = text; 103 } 104 105 function _createConsentText(cookieText) { 106 var cookieTextId = 'cookieContentText'; 107 var consentText = document.createElement('span'); 108 consentText.id = cookieTextId; 109 _setElementText(consentText, cookieText); 110 return consentText; 111 } 112 113 function _createDismissLink(dismissText) { 114 var dismissLink = document.createElement('a'); 115 _setElementText(dismissLink, dismissText);
116 dismissLink.id = dismissLinkId; 117 dismissLink.href = '#'; 118 return dismissLink; 119 } 120 121 function _createInformationLink(linkText, linkHref) { 122 var infoLink = document.createElement('a'); 123 _setElementText(infoLink, linkText); 124 infoLink.id = viewLinkId; 125 infoLink.href = linkHref; 126 infoLink.target = '_blank'; 127 return infoLink; 128 } 129 130 function _dismissLinkClick() { 131 _saveUserPreference(); 132 _removeCookieConsent(); 133 return false; 134 } 135 136 function _showCookieConsent(cookieText, dismissText, linkText, linkHref, isDialog) { 137 if (_shouldDisplayConsent()) { 138 _removeCookieConsent(); 139 var consentElement = (isDialog) ? 140 _createDialogElement(cookieText, dismissText, linkText, linkHref) : 141 _createHeaderElement(cookieText, dismissText, linkText, linkHref); 142 var fragment = document.createDocumentFragment(); 143 fragment.appendChild(consentElement); 144 document.body.appendChild(fragment.cloneNode(true)); 145 document.getElementById(dismissLinkId).onclick = _dismissLinkClick; 146 } 147 } 148 149 function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) { 150 _showCookieConsent(cookieText, dismissText, linkText, linkHref, false); 151 } 152 153 function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) { 154 _showCookieConsent(cookieText, dismissText, linkText, linkHref, true); 155 } 156 157 function _removeCookieConsent() { 158 var cookieChoiceElement = document.getElementById(cookieConsentId); 159 if (cookieChoiceElement != null) { 160 cookieChoiceElement.parentNode.removeChild(cookieChoiceElement); 161 } 162 } 163 164 function _saveUserPreference() { 165 // Set the cookie expiry to one year after today. 166 var expiryDate = new Date(); 167 expiryDate.setFullYear(expiryDate.getFullYear() + 1); 168 document.cookie = cookieName + '=y; expires=' + expiryDate.toGMTString() + '; path=/'; 169 } 170 171 function _shouldDisplayConsent() { 172 // Display the header only if the cookie has not been set. 173 return !document.cookie.match(new RegExp(cookieName + '=([^;]+)')); 174 } 175 176 var exports = {}; 177 exports.showCookieConsentBar = showCookieConsentBar; 178 exports.showCookieConsentDialog = showCookieConsentDialog; 179 return exports; 180 })(); 181 182 window.cookieChoices = cookieChoices; 183 return cookieChoices; 184})(this); 185 186 187/** Customization Starts **/ 188function loadCookieConsentBar() { 189 cookieChoices.showCookieConsentBar('By using this site, you agree to our use of cookies. You can control and/or delete cookies as you wish - for details, see our <a href="https://www.iubenda.com/privacy-policy/562587/cookie-policy" target="_blank">cookie policy</a>.', 'OK'); 190} 191if (document.addEventListener) { 192 document.addEventListener('DOMContentLoaded', loadCookieConsentBar); 193} 194else { 195 window.attachEvent('onload', loadCookieConsentBar); 196} 197/** Customization Ends **/
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.