windhamdavid 6 years ago
parent
commit
b120fde692
5 changed files with 369 additions and 3 deletions
  1. 4 0
      footer.php
  2. 27 1
      js/init-o.js
  3. 164 1
      js/script.js
  4. 164 1
      js/scripts.js
  5. 10 0
      style.css

+ 4 - 0
footer.php

@@ -11,6 +11,10 @@
 			</div>
 		</div>
 	</div>
+	<div class="cookie-notification js-cookie-notification">
+		<p>By using this website, you agree to the use of<br />cookies and the <a href="https://davidawindham.com/privacy/">privacy policy</a>.</p>
+		<button class="btn btn-default" type="submit"><a href="#" class="js-cookie-notification-hide">Agree and dismiss</a></button>					
+	</div>
 </div>
 <?php wp_footer(); ?>
 </body>

+ 27 - 1
js/init-o.js

@@ -68,4 +68,30 @@ $('#commentform').validate({
 	errorPlacement: function(error, element) {
 		element.before(error);
 	} 
-});
+});
+
+/*============================================
+		    EU GDPR cookie notification
+==============================================*/
+
+$( document ).ready( function() {
+	cookieNotification();
+});
+var hideCookieNotification = function() {
+	$( '.js-cookie-notification' ).delay(5000).fadeOut( "slow" );
+	Cookies.set('EU-GDPR-Cookie', 'true', { expires: 365 });
+};
+var cookieNotification = function() {
+	var setCookieNotification = function() {	
+	  $( '.js-cookie-notification' ).fadeOut( "slow" );
+	  Cookies.set('EU-GDPR-Cookie', 'true', { expires: 365 });
+	return false;
+};
+	if ( Cookies.get('EU-GDPR-Cookie') === 'true' ) {
+		console.log('EU GDPR cookie notification set');
+	} else {
+		console.log('EU GDPR cookie notification not set');
+		$('.js-cookie-notification').css({ 'display' : 'block'});
+		$('.js-cookie-notification').find('.js-cookie-notification-hide').click( setCookieNotification );
+	};					
+}

+ 164 - 1
js/script.js

@@ -146,6 +146,7 @@ fc.gcalFeed = function(url, sourceOptions) {
 // ============ https://github.com/carhartl/jquery-cookie =================== //
 // ======== https://github.com/imakewebthings/jquery-waypoints ============== //
 // ============= https://github.com/kirbysayshi/ghembedder  ================= //
+// ============== https://github.com/js-cookie/js-cookie ==================== //
 
 
 // ---------------------  Lazy Load 1.9.7 ---------------------------------- //
@@ -2808,4 +2809,166 @@ ghembedder.autoload();
 
 	});
 
-});
+});
+
+
+// ----------------- JavaScript Cookie v2.2.0 ----------------------------- //
+// =========== https://github.com/js-cookie/js-cookie =============== //
+// ---------------------------------------------------------------------- //
+
+;(function (factory) {
+var registeredInModuleLoader;
+if (typeof define === 'function' && define.amd) {
+	define(factory);
+	registeredInModuleLoader = true;
+}
+if (typeof exports === 'object') {
+	module.exports = factory();
+	registeredInModuleLoader = true;
+}
+if (!registeredInModuleLoader) {
+	var OldCookies = window.Cookies;
+	var api = window.Cookies = factory();
+	api.noConflict = function () {
+		window.Cookies = OldCookies;
+		return api;
+	};
+}
+}(function () {
+function extend () {
+	var i = 0;
+	var result = {};
+	for (; i < arguments.length; i++) {
+		var attributes = arguments[ i ];
+		for (var key in attributes) {
+			result[key] = attributes[key];
+		}
+	}
+	return result;
+}
+
+function decode (s) {
+	return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
+}
+
+function init (converter) {
+	function api() {}
+
+	function set (key, value, attributes) {
+		if (typeof document === 'undefined') {
+			return;
+		}
+
+		attributes = extend({
+			path: '/'
+		}, api.defaults, attributes);
+
+		if (typeof attributes.expires === 'number') {
+			attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
+		}
+
+		// We're using "expires" because "max-age" is not supported by IE
+		attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
+
+		try {
+			var result = JSON.stringify(value);
+			if (/^[\{\[]/.test(result)) {
+				value = result;
+			}
+		} catch (e) {}
+
+		value = converter.write ?
+			converter.write(value, key) :
+			encodeURIComponent(String(value))
+				.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
+
+		key = encodeURIComponent(String(key))
+			.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
+			.replace(/[\(\)]/g, escape);
+
+		var stringifiedAttributes = '';
+		for (var attributeName in attributes) {
+			if (!attributes[attributeName]) {
+				continue;
+			}
+			stringifiedAttributes += '; ' + attributeName;
+			if (attributes[attributeName] === true) {
+				continue;
+			}
+
+			// Considers RFC 6265 section 5.2:
+			// ...
+			// 3.  If the remaining unparsed-attributes contains a %x3B (";")
+			//     character:
+			// Consume the characters of the unparsed-attributes up to,
+			// not including, the first %x3B (";") character.
+			// ...
+			stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
+		}
+
+		return (document.cookie = key + '=' + value + stringifiedAttributes);
+	}
+
+	function get (key, json) {
+		if (typeof document === 'undefined') {
+			return;
+		}
+
+		var jar = {};
+		// To prevent the for loop in the first place assign an empty array
+		// in case there are no cookies at all.
+		var cookies = document.cookie ? document.cookie.split('; ') : [];
+		var i = 0;
+
+		for (; i < cookies.length; i++) {
+			var parts = cookies[i].split('=');
+			var cookie = parts.slice(1).join('=');
+
+			if (!json && cookie.charAt(0) === '"') {
+				cookie = cookie.slice(1, -1);
+			}
+
+			try {
+				var name = decode(parts[0]);
+				cookie = (converter.read || converter)(cookie, name) ||
+					decode(cookie);
+
+				if (json) {
+					try {
+						cookie = JSON.parse(cookie);
+					} catch (e) {}
+				}
+
+				jar[name] = cookie;
+
+				if (key === name) {
+					break;
+				}
+			} catch (e) {}
+		}
+
+		return key ? jar[key] : jar;
+	}
+
+	api.set = set;
+	api.get = function (key) {
+		return get(key, false /* read as raw */);
+	};
+	api.getJSON = function (key) {
+		return get(key, true /* read as json */);
+	};
+	api.remove = function (key, attributes) {
+		set(key, '', extend(attributes, {
+			expires: -1
+		}));
+	};
+
+	api.defaults = {};
+
+	api.withConverter = init;
+
+	return api;
+}
+
+return init(function () {});
+}));

+ 164 - 1
js/scripts.js

@@ -12,6 +12,7 @@
 // ============ https://github.com/carhartl/jquery-cookie =================== //
 // ======== https://github.com/imakewebthings/jquery-waypoints ============== //
 // ============= https://github.com/kirbysayshi/ghembedder  ================= //
+// ============== https://github.com/js-cookie/js-cookie ==================== //
 
 
 // ---------------------  Lazy Load 1.9.7 ---------------------------------- //
@@ -2674,4 +2675,166 @@ ghembedder.autoload();
 
 	});
 
-});
+});
+
+
+// ----------------- JavaScript Cookie v2.2.0 ----------------------------- //
+// =========== https://github.com/js-cookie/js-cookie =============== //
+// ---------------------------------------------------------------------- //
+
+;(function (factory) {
+var registeredInModuleLoader;
+if (typeof define === 'function' && define.amd) {
+	define(factory);
+	registeredInModuleLoader = true;
+}
+if (typeof exports === 'object') {
+	module.exports = factory();
+	registeredInModuleLoader = true;
+}
+if (!registeredInModuleLoader) {
+	var OldCookies = window.Cookies;
+	var api = window.Cookies = factory();
+	api.noConflict = function () {
+		window.Cookies = OldCookies;
+		return api;
+	};
+}
+}(function () {
+function extend () {
+	var i = 0;
+	var result = {};
+	for (; i < arguments.length; i++) {
+		var attributes = arguments[ i ];
+		for (var key in attributes) {
+			result[key] = attributes[key];
+		}
+	}
+	return result;
+}
+
+function decode (s) {
+	return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
+}
+
+function init (converter) {
+	function api() {}
+
+	function set (key, value, attributes) {
+		if (typeof document === 'undefined') {
+			return;
+		}
+
+		attributes = extend({
+			path: '/'
+		}, api.defaults, attributes);
+
+		if (typeof attributes.expires === 'number') {
+			attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
+		}
+
+		// We're using "expires" because "max-age" is not supported by IE
+		attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
+
+		try {
+			var result = JSON.stringify(value);
+			if (/^[\{\[]/.test(result)) {
+				value = result;
+			}
+		} catch (e) {}
+
+		value = converter.write ?
+			converter.write(value, key) :
+			encodeURIComponent(String(value))
+				.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
+
+		key = encodeURIComponent(String(key))
+			.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
+			.replace(/[\(\)]/g, escape);
+
+		var stringifiedAttributes = '';
+		for (var attributeName in attributes) {
+			if (!attributes[attributeName]) {
+				continue;
+			}
+			stringifiedAttributes += '; ' + attributeName;
+			if (attributes[attributeName] === true) {
+				continue;
+			}
+
+			// Considers RFC 6265 section 5.2:
+			// ...
+			// 3.  If the remaining unparsed-attributes contains a %x3B (";")
+			//     character:
+			// Consume the characters of the unparsed-attributes up to,
+			// not including, the first %x3B (";") character.
+			// ...
+			stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
+		}
+
+		return (document.cookie = key + '=' + value + stringifiedAttributes);
+	}
+
+	function get (key, json) {
+		if (typeof document === 'undefined') {
+			return;
+		}
+
+		var jar = {};
+		// To prevent the for loop in the first place assign an empty array
+		// in case there are no cookies at all.
+		var cookies = document.cookie ? document.cookie.split('; ') : [];
+		var i = 0;
+
+		for (; i < cookies.length; i++) {
+			var parts = cookies[i].split('=');
+			var cookie = parts.slice(1).join('=');
+
+			if (!json && cookie.charAt(0) === '"') {
+				cookie = cookie.slice(1, -1);
+			}
+
+			try {
+				var name = decode(parts[0]);
+				cookie = (converter.read || converter)(cookie, name) ||
+					decode(cookie);
+
+				if (json) {
+					try {
+						cookie = JSON.parse(cookie);
+					} catch (e) {}
+				}
+
+				jar[name] = cookie;
+
+				if (key === name) {
+					break;
+				}
+			} catch (e) {}
+		}
+
+		return key ? jar[key] : jar;
+	}
+
+	api.set = set;
+	api.get = function (key) {
+		return get(key, false /* read as raw */);
+	};
+	api.getJSON = function (key) {
+		return get(key, true /* read as json */);
+	};
+	api.remove = function (key, attributes) {
+		set(key, '', extend(attributes, {
+			expires: -1
+		}));
+	};
+
+	api.defaults = {};
+
+	api.withConverter = init;
+
+	return api;
+}
+
+return init(function () {});
+}));

+ 10 - 0
style.css

@@ -101,6 +101,16 @@ body.contact {
 	}
 }
 
+.cookie-notification {
+	display: none;
+	padding:30px;
+	position: fixed;
+	bottom: 10px;
+	left: 10px;
+	background-color: #fff;
+	opacity: 0.8;
+	border-radius: 15px;
+}
 /*============================================
 		Typography 
 ==============================================*/