PageSourceSearch

https://smpl.co/wp-content/plugins/be-gdpr/public/js/be-gdpr-public.js?ver=1.1.6

js smpl.co collected 2026-09-24 11:02:14 UTC 5,532 bytes, 194 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31
32	$(function () {
33
34		function be_gdpr_trigger_magnific_popup() {
35			if ($('.mfp-popup').length > 0) {
36				$('.mfp-popup').magnificPopup({
37					type: 'inline',
38					midClick: true,
39					closeBtnInside: true,
40				});
41			}
42		}
43
44		window.be_gdpr_magnific_popup_retrigger = be_gdpr_trigger_magnific_popup;
45		be_gdpr_trigger_magnific_popup();
46
47		function readCookie(name) {
48			var nameEQ = name + "=";
49			var ca = document.cookie.split(';');
50			for (var i = 0; i < ca.length; i++) {
51				var c = ca[i];
52				while (c.charAt(0) == ' ') c = c.substring(1, c.length);
53				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
54			}
55			return null;
56		}
57		function createCookie(name, value) {
58
59			var date = new Date();
60			date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000)); //a year
61			var expires = "; expires=" + date.toGMTString();
62
63			document.cookie = name + "=" + value + expires + "; path=/";
64		}
65		var checkBoxes = $('.be-gdpr-switch-input');
66		var privacyPref = readCookie('be_gdpr_privacy') || [];
67		for (var count in checkBoxes) {
68			if (checkBoxes.hasOwnProperty(count)) {
69				var singleCheckBox = checkBoxes[count];
70				if (privacyPref.indexOf(singleCheckBox.value) >= 0) {
71					singleCheckBox.setAttribute('checked', true);
72				}
73			}
74		}
75
76		function hasConcern(concern) {
77			if (window.hasOwnProperty('beGdprConcerns')) {
78				if (!window.beGdprConcerns.hasOwnProperty(concern)) {
79					return true;
80				}
81			}
82			if (privacyPref.indexOf(concern) >= 0) {
83				return true;
84			}
85			return false;
86		}
87
88		window.triggerBeGdpr = function triggerBeGdpr (){
89
90			var itemsWithConcern = $('.be-gdpr-consent-required');
91			itemsWithConcern.each(function (i, e) {
92				var gdprData = $(this).attr('data-gdpr-atts');
93
94				if (isJSON(gdprData)) {
95					gdprData = JSON.parse(gdprData);
96
97					var concern = gdprData.concern,
98						classesToRemove = [],
99						attsToRemove = [],
100						classesToAdd = [],
101						attsToAdd = {};
102					if( !hasConcern( concern ) ) {
103						
104						if (typeof gdprData.remove === 'object') {
105							classesToRemove = gdprData.remove.class ? gdprData.remove.class : [];
106							attsToRemove = gdprData.remove.atts ? gdprData.remove.atts : [];
107						}
108
109						if (typeof gdprData.add === 'object') {
110							classesToAdd = gdprData.add.class ? gdprData.add.class : [];
111							attsToAdd = gdprData.add.atts ? gdprData.add.atts : {};
112						}
113
114						for (var item in classesToRemove) {
115							$(this).removeClass(classesToRemove[item]);
116						}
117
118						for (var item in attsToRemove) {
119							$(this).removeAttr(attsToRemove[item]);
120						}
121
122						for (var item in classesToAdd) {
123							$(this).addClass(classesToAdd[item]);
124						}
125
126						for (var item in attsToAdd) {
127							$(this).attr( item, attsToAdd[item] );
128						}
129						be_gdpr_trigger_magnific_popup();
130					}
131				}
132			});
133
134			var itemsToReplaceContent = $('.be-gdpr-consent-replace');
135			itemsToReplaceContent.each(function (i, e) {
136				var concern = $(this).data('gdpr-concern'),
137					replaceTarget = $(this).data('gdpr-replace');
138
139				if (hasConcern(concern)) {
140					$(this).siblings('.be-gdpr-consent-message ').remove();
141				} else {
142					if( replaceTarget === 'parent' ){
143						var tempChildren = $(this).children(),
144							gdprWrapper = $(this).siblings('.be-gdpr-consent-message ');
145					
146						$(this).wrap( gdprWrapper );
147						$(this).parent().siblings('.be-gdpr-consent-message ').remove();
148						tempChildren.unwrap();
149					}else{
150						var replacingContent = $(this).siblings('.be-gdpr-consent-message ');
151						replacingContent.css( 'display', 'block' );
152						if( replacingContent.length ){
153							$(this).replaceWith(replacingContent);
154						}
155					}
156
157				}
158			});
159
160		}
161
162		triggerBeGdpr();
163
164		function gdprSaveBtnClick(e) {
165			var tempCookies = []
166			var checkBoxes = $(e.target).closest('.be-gdpr-modal').find('.be-gdpr-switch-input');
167			for (var count in checkBoxes) {
168				var singleCheckBox = checkBoxes[count];
169				if (singleCheckBox.checked) {
170					tempCookies.push(singleCheckBox.value)
171				}
172			}
173			createCookie('be_gdpr_privacy', "", -1);
174			createCookie('be_gdpr_privacy', JSON.stringify(tempCookies));
175			window.location.reload();
176		}
177		window.gdprSaveBtnClick = gdprSaveBtnClick;
178
179		if (readCookie('be_gdpr_cookie_accept') !== '1') {
180			$('.be-gdpr-cookie-notice-bar').css('bottom', '0');
181		}
182
183		$('.be-gdpr-cookie-notice-button').click(function () {
184			$('.be-gdpr-cookie-notice-bar').css('bottom', '-100%');
185			createCookie('be_gdpr_cookie_accept', '1');
186		});
187
188		function isJSON(str) {
189			if (!str || typeof str !== 'string') return false;
190			str = str.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
191			return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
192		}
193	});
194})(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.