1/** 2 * Copyright (C) 2012 Chris Wharton ([email protected]) 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT 10 * HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, 11 * INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR 12 * FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE 13 * OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, 14 * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT 15 * BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL 16 * DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://gnu.org/licenses/>. 20 21 Documentation available at http://cookiecuttr.com 22 23 */ 24(function ($) { 25 $.cookieCuttr = function (options) { 26 var defaults = { 27 cookieCutter: false, // you'd like to enable the div/section/span etc. hide feature? change this to true 28 cookieCutterDeclineOnly: false, // you'd like the CookieCutter to only hide when someone has clicked declined set this to true 29 cookieAnalytics: true, // just using a simple analytics package? change this to true 30 cookieDeclineButton: false, // this will disable non essential cookies 31 cookieAcceptButton: true, // this will disable non essential cookies 32 cookieResetButton: false, 33 cookieOverlayEnabled: false, // don't want a discreet toolbar? Fine, set this to true 34 cookiePolicyLink: '/privacy/', // if applicable, enter the link to your privacy policy here... 35 cookieMessage: 'We use cookies on this website, you can <a href="{{cookiePolicyLink}}" title="read about our cookies">read about them here</a>. To use the website as intended please...', 36 cookieAnalyticsMessage: 'We use cookies, just to track visits to our website, we store no personal details.', 37 cookieErrorMessage: "We\'re sorry, this feature places cookies in your browser and has been disabled. <br>To continue using this functionality, please", 38 cookieWhatAreTheyLink: "https://en.wikipedia.org/wiki/HTTP_cookie", 39 cookieDisable: '', 40 cookieExpires: 365, 41 cookieAcceptButtonText: "ACCEPT COOKIES", 42 cookieDeclineButtonText: "DECLINE COOKIES", 43 cookieResetButtonText: "RESET COOKIES FOR THIS WEBSITE", 44 cookieWhatAreLinkText: "What are cookies?", 45 cookieNotificationLocationBottom: false, // top or bottom - they are your only options, so true for bottom, false for top 46 cookiePolicyPage: false, 47 cookiePolicyPageMessage: 'Please read the information below and then choose from the following options', 48 cookieDiscreetLink: false, 49 cookieDiscreetReset: false, 50 cookieDiscreetLinkText: "Cookies?", 51 cookieDiscreetPosition: "topleft", //options: topleft, topright, bottomleft, bottomright 52 cookieNoMessage: false, // change to true hide message from all pages apart from your policy page 53 cookieDomain: "", 54 // custom GT 55 customCookieMessage: 'By continuing to use our site and/or clicking on {{cookieAcceptButton}} you\'re agreeing to our use of cookies in accordance with our <a href="/privacy">cookie policy</a>.' 56 }; 57 var options = $.extend(defaults, options); 58 var message = defaults.cookieMessage.replace('{{cookiePolicyLink}}', defaults.cookiePolicyLink); 59 defaults.cookieMessage = 'We use cookies on this website, you can <a href="' + defaults.cookiePolicyLink + '" title="read about our cookies">read about them here</a>. To use the website as intended please...'; 60 //convert options 61 var cookiePolicyLinkIn = options.cookiePolicyLink; 62 var cookieCutter = options.cookieCutter; 63 var cookieCutterDeclineOnly = options.cookieCutterDeclineOnly; 64 var cookieAnalytics = options.cookieAnalytics; 65 var cookieDeclineButton = options.cookieDeclineButton; 66 var cookieAcceptButton = options.cookieAcceptButton; 67 var cookieResetButton = options.cookieResetButton; 68 var cookieOverlayEnabled = options.cookieOverlayEnabled; 69 var cookiePolicyLink = options.cookiePolicyLink; 70 var cookieMessage = message; 71 var cookieAnalyticsMessage = options.cookieAnalyticsMessage; 72 var cookieErrorMessage = options.cookieErrorMessage; 73 var cookieDisable = options.cookieDisable; 74 var cookieWhatAreTheyLink = options.cookieWhatAreTheyLink; 75 var cookieExpires = options.cookieExpires; 76 var cookieAcceptButtonText = options.cookieAcceptButtonText; 77 var cookieDeclineButtonText = options.cookieDeclineButtonText; 78 var cookieResetButtonText = options.cookieResetButtonText; 79 var cookieWhatAreLinkText = options.cookieWhatAreLinkText; 80 var cookieNotificationLocationBottom = options.cookieNotificationLocationBottom; 81 var cookiePolicyPage = options.cookiePolicyPage; 82 var cookiePolicyPageMessage = options.cookiePolicyPageMessage; 83 var cookieDiscreetLink = options.cookieDiscreetLink; 84 var cookieDiscreetReset = options.cookieDiscreetReset; 85 var cookieDiscreetLinkText = options.cookieDiscreetLinkText; 86 var cookieDiscreetPosition = options.cookieDiscreetPosition; 87 var cookieNoMessage = options.cookieNoMessage; 88 // custom GT 89 var customCookieMessage = options.customCookieMessage; 90 91 // cookie identifier 92 var $cookieAccepted = $.cookie('cc_cookie_accept') == "cc_cookie_accept"; 93 $.cookieAccepted = function () { 94 return $cookieAccepted; 95 }; 96 var $cookieDeclined = $.cookie('cc_cookie_decline') == "cc_cookie_decline"; 97 $.cookieDeclined = function () { 98 return $cookieDeclined; 99 }; 100 // write cookie accept button
101 if (cookieAcceptButton) { 102 var cookieAccept = ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> '; 103 } else { 104 var cookieAccept = ""; 105 } 106 // write cookie decline button 107 if (cookieDeclineButton) { 108 var cookieDecline = ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> '; 109 } else { 110 var cookieDecline = ""; 111 } 112 // write extra class for overlay 113 if (cookieOverlayEnabled) { 114 var cookieOverlay = 'cc-overlay'; 115 } else { 116 var cookieOverlay = ""; 117 } 118 // to prepend or append, that is the question? 119 if ((cookieNotificationLocationBottom) || (cookieDiscreetPosition == "bottomright") || (cookieDiscreetPosition == "bottomleft")) { 120 var appOrPre = true; 121 } else { 122 var appOrPre = false; 123 } 124 if (($cookieAccepted) || ($cookieDeclined)) { 125 // write cookie reset button 126 if ((cookieResetButton) && (cookieDiscreetReset)) { 127 if (appOrPre) { 128 $('body').append('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="' + cookieResetButtonText + '">' + cookieResetButtonText + '</a></div>'); 129 } else { 130 $('body').prepend('<div class="cc-cookies cc-discreet"><a class="cc-cookie-reset" href="#" title="' + cookieResetButtonText + '">' + cookieResetButtonText + '</a></div>'); 131 } 132 //add appropriate CSS depending on position chosen 133 if (cookieDiscreetPosition == "topleft") { 134 $('div.cc-cookies').css("top", "0"); 135 $('div.cc-cookies').css("left", "0"); 136 } 137 if (cookieDiscreetPosition == "topright") { 138 $('div.cc-cookies').css("top", "0"); 139 $('div.cc-cookies').css("right", "0"); 140 } 141 if (cookieDiscreetPosition == "bottomleft") { 142 $('div.cc-cookies').css("bottom", "0"); 143 $('div.cc-cookies').css("left", "0"); 144 } 145 if (cookieDiscreetPosition == "bottomright") { 146 $('div.cc-cookies').css("bottom", "0"); 147 $('div.cc-cookies').css("right", "0"); 148 } 149 } else if (cookieResetButton) { 150 if (appOrPre) { 151 $('body').append('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">' + cookieResetButtonText + '</a></div>'); 152 } else { 153 $('body').prepend('<div class="cc-cookies"><a href="#" class="cc-cookie-reset">' + cookieResetButtonText + '</a></div>'); 154 } 155 } else { 156 var cookieResetButton = ""; 157 } 158 } else { 159 // add message to just after opening body tag 160 if ((cookieNoMessage) && (!cookiePolicyPage)) { 161 // show no link on any pages APART from the policy page 162 } else if ((cookieDiscreetLink) && (!cookiePolicyPage)) { // show discreet link 163 if (appOrPre) { 164 $('body').append('<div class="cc-cookies cc-discreet">
164<a href="' + cookiePolicyLinkIn + '" title="' + cookieDiscreetLinkText + '">' + cookieDiscreetLinkText + '</a></div>'); 165 } else { 166 $('body').prepend('<div class="cc-cookies cc-discreet"><a href="' + cookiePolicyLinkIn + '" title="' + cookieDiscreetLinkText + '">' + cookieDiscreetLinkText + '</a></div>'); 167 } 168 //add appropriate CSS depending on position chosen 169 if (cookieDiscreetPosition == "topleft") { 170 $('div.cc-cookies').css("top", "0"); 171 $('div.cc-cookies').css("left", "0"); 172 } 173 if (cookieDiscreetPosition == "topright") { 174 $('div.cc-cookies').css("top", "0"); 175 $('div.cc-cookies').css("right", "0"); 176 } 177 if (cookieDiscreetPosition == "bottomleft") { 178 $('div.cc-cookies').css("bottom", "0"); 179 $('div.cc-cookies').css("left", "0"); 180 } 181 if (cookieDiscreetPosition == "bottomright") { 182 $('div.cc-cookies').css("bottom", "0"); 183 $('div.cc-cookies').css("right", "0"); 184 } 185 } else if (cookieAnalytics) { // show analytics overlay 186 if (appOrPre) { 187 $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookieAnalyticsMessage + cookieAccept + cookieDecline + '<a href="' + co
187okieWhatAreTheyLink + '" title="Visit All about cookies (External link)" target="_blank">' + cookieWhatAreLinkText + '</a></div>'); 188 } else { 189 if (customCookieMessage) { 190 customCookieMessage = customCookieMessage.replace('{{cookieAcceptButton}}', cookieAccept); 191 $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + customCookieMessage + '</div>'); 192 } else { 193 $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookieAnalyticsMessage + cookieAccept + +cookieDecline + '<a href="' + cookieWhatAreTheyLink + '" title="Visit All about cookies (External link)" target="_blank">' + cookieWhatAreLinkText + '</a></div>'); 194 } 195 } 196 } 197 if (cookiePolicyPage) { // show policy page overlay 198 if (appOrPre) { 199 $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookiePolicyPageMessage + " " + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> ' + '</div>'); 200 } else { 201 $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookiePolicyPageMessage + " " + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + ' <a href="#decline" class="cc-cookie-decline">' + cookieDeclineButtonText + '</a> ' + '</div>'); 202 } 203 } else if ((!cookieAnalytics) && (!cookieDiscreetLink)) { // show privacy policy option 204 if (appOrPre) { 205 $('body').append('<div class="cc-cookies ' + cookieOverlay + '">' + cookieMessage + cookieAccept + cookieDecline + '</div>'); 206 } else { 207 $('body').prepend('<div class="cc-cookies ' + cookieOverlay + '">' + cookieMessage + cookieAccept + cookieDecline + '</div>'); 208 } 209 } 210 } 211 if ((cookieCutter) && (!cookieCutterDeclineOnly) && (($cookieDeclined) || (!$cookieAccepted))) { 212 $(cookieDisable).html('<div class="cc-cookies-error">' + cookieErrorMessage + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + '</div>'); 213 } 214 if ((cookieCutter) && (cookieCutterDeclineOnly) && ($cookieDeclined)) { 215 $(cookieDisable).html('<div class="cc-cookies-error">' + cookieErrorMessage + ' <a href="#accept" class="cc-cookie-accept">' + cookieAcceptButtonText + '</a> ' + '</div>'); 216 } 217 // if bottom is true, switch div to bottom if not in discreet mode 218 if ((cookieNotificationLocationBottom) && (!cookieDiscreetLink)) { 219 $('div.cc-cookies').css("top", "auto"); 220 $('div.cc-cookies').css("bottom", "0"); 221 } 222 if ((cookieNotificationLocationBottom) && (cookieDiscreetLink) && (cookiePolicyPage)) { 223 $('div.cc-cookies').css("top", "auto"); 224 $('div.cc-cookies').css("bottom", "0"); 225 } 226 // setting the cookies 227 228 // for top bar 229 $('.cc-cookie-accept, .cc-cookie-decline').click(function (e) { 230 e.preventDefault(); 231 if ($(this).is('[href$=#decline]')) { 232 $.cookie("cc_cookie_accept", null, { 233 path: '/' 234 }); 235 $.cookie("cc_cookie_decline", "cc_cookie_decline", { 236 expires: cookieExpires, 237 path: '/' 238 }); 239 if (options.cookieDomain) { 240 // kill google analytics cookies 241 $.cookie("__utma", null, { 242 domain: '.' + options.cookieDomain, 243 path: '/' 244 }); 245 $.cookie("__utmb", null, { 246 domain: '.' + options.cookieDomain, 247 path: '/' 248 }); 249 $.cookie("__utmc", null, { 250 domain: '.' + options.cookieDomain, 251 path: '/' 252 }); 253 $.cookie("__utmz", null, { 254 domain: '.' + options.cookieDomain, 255 path: '/' 256 }); 257 } 258 } else { 259 $.cookie("cc_cookie_decline", null, { 260 path: '/' 261 }); 262 $.cookie("cc_cookie_accept", "cc_cookie_accept", { 263 expires: cookieExpires, 264 path: '/' 265 }); 266 } 267 $(".cc-cookies").fadeOut(function () { 268 // reload page to activate cookies 269 location.reload(); 270 }); 271 }); 272 //reset cookies 273 $('a.cc-cookie-reset').click(function (f) { 274 f.preventDefault(); 275 $.cookie("cc_cookie_accept", null, { 276 path: '/' 277 }); 278 $.cookie("cc_cookie_decline", null, { 279 path: '/' 280 }); 281 $(".cc-cookies").fadeOut(function () { 282 // reload page to activate cookies 283 location.reload(); 284 }); 285 }); 286 //cookie error accept 287 $('.cc-cookies-error a.cc-cookie-accept').click(function (g) { 288 g.preventDefault(); 289 $.cookie("cc_cookie_accept", "cc_cookie_accept", { 290 expires: cookieExpires, 291 path: '/' 292 }); 293 $.cookie("cc_cookie_decline", null, { 294 path: '/' 295 }); 296 // reload page to activate cookies 297 location.reload(); 298 }); 299 }; 300})(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.