// ----------------------------------- // JQuery Cookies Message Plugin // Version 1.0.0 - 28th May 2015 // http://# // // Written by Giuseppe Garbin // http://www.giuseppegarbin.com/ // // Released under MIT License // http://opensource.org/licenses/MIT // // --------------------- ;( function ( $ ) { $.CookiesMessage = function ( options ) { // ---------------- // 001 - Default settings var defaults = { messageText: "This website uses cookies to ensure you get the best experience on our website.", messageBg: "#ffffff", // Message box background color messageColor: "#444444", // Message box text color messageLinkColor: "#ffffff", // Message box links color closeEnable: true, // Show the close icon closeColor: "#353f4f", // Close icon color closeBgColor: "transparent", // Close icon background color acceptEnable: true, // Show the Accept button acceptText: "Accept All", // Accept button text infoEnable: true, // Show the More Info button infoText: "More Details", // More Info button text infoUrl: "cookies.html", // More Info button URL cookieExpire: 180 // Cookie expire time (days) }; options = $.extend(defaults, options); var cookieName = location.host; var cookieValue = "Cookies policy accepted"; var cookiePath = "/"; // ---------------- // 002 - Initialize function inizialize(options) { //== Message composition var partClose = ''; if (options.closeEnable == true) { partClose += ''; }; var partLinks = ''; if (options.acceptEnable == true) { partLinks += ''+ options.acceptText +''; }; if (options.infoEnable == true) { partLinks += ''+ options.infoText +''; }; var displayMessage = '

'+ options.messageText + '' + partLinks + '' +'

'+ partClose +'
'; $("body").prepend(displayMessage); $("#cookies").hide().slideDown(); //== Custom style $("#cookies").css({ "background-color":options.messageBg, "color":options.messageColor }); $("#cookies p a").css({ "color":options.messageLinkColor }); } // ---------------- // 003 - Check user's technical cookie var mycookie = getCookie(cookieName); if(!mycookie) { inizialize(options); } // ---------------- // 004 - Get and Set cookie functions function Trim(strValue) { return strValue.replace(/^\s+|\s+$/g, ''); } function getCookie(cookieName) { var result = false; if(document.cookie) { var mycookieArray = document.cookie.split(';'); for(i=0; i