Warning: Undefined variable $title in /var/www/vhosts/hostspacer.com/httpdocs/pages/blogs/index.php on line 13
Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /var/www/vhosts/hostspacer.com/httpdocs/includes/functions/sbfuncs.php on line 203
CookieAlert JQuery Plugin for Cookie Policy
June 1, 2020, 04:59 PM
/*
* cookieAlert Plugin v1.0.
* Copyright(c) 2009 Host Spacer Pvt. Ltd.
* Contact us at info@hostspacer.com
* Author: Shivasis Biswal (Krushna)
* Usage:
* $(document).ready(function(){
* $('body').cookieAlert();
* });
* Themes: dark, green, light
* Example:
* $(document).ready(function(){
* $('body').cookieAlert({ theme: 'green'});
* });
* Width: custom width as you wish
* Example:
* $(document).ready(function(){
* $('body').cookieAlert({ theme: 'green', width: '500'});
* });
*
* Position / Place: top-left, top-right, bottom-left, bottom-right
* Example:
* $(document).ready(function(){
* $('body').cookieAlert({ theme: 'green', width: '500', place: 'top-left'});
* });
*
*/
;(function ($) {
"use strict";
$.fn.cookieAlert = function(opts) {
var hsTitle = 'Accept Cookie Policy';
var hsContent = 'We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you accept and understand our Privacy Policy and our Terms of Service.';
var defaults = {
theme: 'dark',
width: '400',
place: 'b0ttom-left',
title: hsTitle,
content: hsContent,
overlay: true,
action: ''
};
var settings = $.extend({}, defaults, opts);
var hsCook = {
init: function(){
if (hsCook.getCookie("cookiesAccepted")) {
hsCook.removeAlert();
} else {
hsCook.renderAlert();
hsCook.showAlert();
}
var el_cookie_alert = document.querySelector(".cookie_alert");
if(el_cookie_alert){
el_cookie_alert.offsetHeight;
}
$(document).on("click", '.cookie_accept', function (e) {
if($(e.target) && $(e.target).parent().hasClass('cookie_accept')) {
hsCook.setCookie("cookiesAccepted", true, 180);
hsCook.removeAlert();
}
});
$(document).on("click", '.cookie_close', function (e) {
if($(e.target) && $(e.target).parent().hasClass('cookie_close')) {
//hsCook.setCookie("cookiesAccepted", true, 180);
hsCook.removeAlert();
}
});
},
renderAlert: function() {
var alertTitle = settings.title;
var alertContent = settings.content;
var alertHtml = '
$(document).ready(function(){
var mytitle = 'Cookie Policy';
var mycontent = 'We use cookies to ensure that we give you the best experience on our website.';
$('body').cookieAlert({
theme: 'green',
width: '500',
place: 'top-left',
overlay: true,
title: mytitle,
content: mycontent
});
});