1// ----------------------------------- 2// JQuery Cookies Message Plugin 3// Version 1.0.0 - 28th May 2015 4// http://# 5// 6// Written by Giuseppe Garbin 7// http://www.giuseppegarbin.com/ 8// 9// Released under MIT License 10// http://opensource.org/licenses/MIT 11// 12// --------------------- 13 14 15 16;( function ( $ ) { 17 18 $.CookiesMessage = function ( options ) { 19 20 21 // ---------------- 22 // 001 - Default settings 23 24 var defaults = { 25 messageText: "This website uses cookies to ensure you get the best experience on our website.", 26 messageBg: "#ffffff", // Message box background color 27 messageColor: "#444444", // Message box text color 28 messageLinkColor: "#ffffff", // Message box links color 29 closeEnable: true, // Show the close icon 30 closeColor: "#353f4f", // Close icon color 31 closeBgColor: "transparent", // Close icon background color 32 acceptEnable: true, // Show the Accept button 33 acceptText: "Accept All", // Accept button text 34 infoEnable: true, // Show the More Info button 35 infoText: "More Details", // More Info button text 36 infoUrl: "cookies.html", // More Info button URL 37 cookieExpire: 180 // Cookie expire time (days) 38 }; 39 40 options = $.extend(defaults, options); 41 42 var cookieName = location.host; 43 var cookieValue = "Cookies policy accepted"; 44 var cookiePath = "/"; 45 46 47 48 // ---------------- 49 // 002 - Initialize 50 51 function inizialize(options) { 52 //== Message composition 53 var partClose = ''; 54 if (options.closeEnable == true) { partClose += '<a href="#" id="cookies-close" style="background-color:'+ options.closeBgColor +';"><svg version="1.1" id="cookies-close-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px" viewBox="248.5 248.5 15 15" enable-background="new 248.5 248.5 15 15" xml:space="preserve" ><polygon id="x-mark-icon" points="263.5,260.876 258.621,255.999 263.499,251.121 260.876,248.5 256,253.377 251.122,248.5 248.5,251.121 253.378,255.999 248.5,260.878 251.121,263.5 256,258.62 260.879,263.499" style="fill:'+ options.closeColor +';"/></svg></a>'; }; 55 var partLinks = ''; 56 if (options.acceptEnable == true) { partLinks += '<a href="#" id="cookies-ok">'+ options.acceptText +'</a>'; }; 57 if (options.infoEnable == true) { partLinks += '<a href="'+ options.infoUrl +'" id="cookies-info">'+ options.infoText +'</a>'; }; 58 var displayMessage = '<div id="cookies"><p>'+ options.messageText + '<span>' + partLinks + '</span>' +'</p>'+ partClose +'</div>'; 59 $("body").prepend(displayMessage); 60 $("#cookies").hide().slideDown(); 61 62 //== Custom style 63 $("#cookies").css({ "background-color":options.messageBg, "color":options.messageColor }); 64 $("#cookies p a").css({ "color":options.messageLinkColor }); 65 } 66 67 68 69 // ---------------- 70 // 003 - Check user's technical cookie 71 72 var mycookie = getCookie(cookieName); 73 if(!mycookie) { 74 inizialize(options); 75 } 76 77 78 79 // ---------------- 80 // 004 - Get and Set cookie functions 81 82 function Trim(strValue) { 83 return strValue.replace(/^\s+|\s+$/g, ''); 84 } 85 86 87 function getCookie(cookieName) { 88 var result = false;
89 if(document.cookie) { 90 var mycookieArray = document.cookie.split(';'); 91 for(i=0; i<mycookieArray.length; i++) { 92 var mykeyValue = mycookieArray[i].split('='); 93 if(Trim(mykeyValue[0]) == cookieName) result = mykeyValue[1]; 94 } 95 } 96 return result; 97 } 98 99 100 function setCookie(cname, cvalue, cexpire, cpath) { 101 var d = new Date(); 102 d.setTime(d.getTime() + (cexpire*24*60*60*1000)); 103 var expires = "expires="+d.toUTCString(); 104 document.cookie = cname + "=" + cvalue + "; " + expires + "; path="+ cpath +";"; 105 } 106 107 108 109 // ---------------- 110 // 005 - Accept link event handler 111 112 $('#cookies-ok').on( 'click', function ( event ) { 113 event.preventDefault(); 114 setCookie(cookieName, cookieValue, options.cookieExpire, cookiePath); 115 $("#cookies").slideToggle(); 116 }); 117 118 $('#cookies-reject').on( 'click', function ( event ) { 119 event.preventDefault(); 120 setCookie(cookieName, cookieValue, options.cookieExpire, cookiePath); 121 $("#cookies").slideToggle(); 122 }); 123 124 $('#cookies-close').on( 'click', function ( event ) { 125 event.preventDefault(); 126 $("#cookies").slideToggle(); 127 }); 128 129 130 }; 131 132 133})(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.