PageSourceSearch

https://www.intherooms.com/home/wp-content/plugins/easy-gdpr-consent-mailchimp/js/main.js?ver=1.0.1

js intherooms.com collected 2026-10-03 21:21:51 UTC 12,371 bytes, 260 lines download raw bytes

1/**
2 * EGCF Form class - API likely to change
3 */
4var EGCF_Form = function($) {
5	"use strict";
6
7	var formEle,
8		form,
9		modal,
10		origSubmit,
11		template,
12		configs;
13
14	var self = {
15
16		hasConsent: false,
17
18		init: function(theForm, conf) 
19		{
20			formEle = $(theForm);
21			form = formEle.get(0);
22			template = conf.tpl,
23			configs  = conf;
24
25			// Clone old handler - if any - into origSubmit
26			var origSubmit = function() {};
27			if (typeof form.onsubmit == 'function') {
28				origSubmit = form.onsubmit.bind(form);
29			}
30			
31			var submit = function(e) {
32
33				if (this.hasConsent) {
34					origSubmit.call(form);
35				}
36				else {
37					e.preventDefault();
38					e.stopImmediatePropagation();
39
40					this.openModal();
41
42					// Also used in jQuery events
43					return false;
44				}
45			};
46
47			form.target   = '';
48			form.onsubmit = submit.bind(this);
49
50			// Some devs bind to click handlers for submit instead of submit event 
51			formEle.find('[type=submit], [name=submit]').on('click', submit.bind(this));
52		},
53
54		/**
55		 * Simulate a click for a submit button first for buggy/wrong implementations
56		 */
57		submitForm: function() 
58		{
59			var submitBtn = formEle.find('[type=submit], [name=submit]').first();
60			
61			// Doesn't trigger sometimes for AJAX forms - give it a little delay
62			setTimeout(function() {
63				if (submitBtn.length) {
64					submitBtn.click();
65				}
66				else {
67					formEle.submit();
68				}
69
70			}, 1);	
71		},
72
73		/**
74		 * Setup, process and display modal
75		 */
76		openModal: function() 
77		{
78			this.setupModal();
79
80			// Test via AJAX if form should be shown
81			if (configs.showTest) {
82				
83				var postData = {
84					action: 'egcf_should_show_form', 
85					egcf_form_id: configs.id
86				};
87
88				this.toggleSubmitLabel();
89
90				$.post(EGCF_Plugin.ajax_url, postData, function(resp) {
91					if (resp.data.show) {
92						modal.open();
93					}
94					else {
95						self.hasConsent = true;
96						self.submitForm();
97					}
98
99					self.toggleSubmitLabel();
100				});
101			}
102			else {
103				modal.open();
104			}
105		},
106
107		/**
108		 * Swap label for button and enable/disable it 
109		 */
110		toggleSubmitLabel: function(theForm) {
111			
112			theForm = theForm || formEle;
113			var submitBtn = theForm.find('[type=submit], [name=submit]').first();
114			
115			if (submitBtn.length) {
116
117				var method = submitBtn.is('button') ? submitBtn.text : submitBtn.val;
118
119				if (submitBtn.hasClass('egcf-working')) {
120					submitBtn.prop('disabled', 0).removeClass('egcf-working');
121					method.call(submitBtn, submitBtn.data('origLabel'));
122				}
123				else {
124					submitBtn.prop('disabled', 1)
125						.addClass('egcf-working')
126						.data('origLabel', method.call(submitBtn));
127
128					method.call(submitBtn, configs.processLabel);
129				}
130			}
131		},
132
133		/**
134		 * Initialize modal
135		 */
136		setupModal: function() 
137		{
138			modal = new tingle.modal({
139				footer: false,
140				cssClass: ['egcf-modal'],
141				closeMethods: ['escape'],
142			});
143
144			// Make it available in modal
145			formEle.data('modal', modal);
146
147			modal.setContent(template.html());
148
149			var inner = $(modal.getContent()),
150				modalForm = inner.find('form');
151
152			$(modal.modalBox)
153				.removeClass('.tingle-modal-box')
154				.addClass('egcf-modal-box');
155
156			$(modal.modalBoxContent).addClass('egcf-modal-box-content');
157
158			inner.find('.egcf-modal-close, .egcf-modal-submit .cancel')
159				.on('click', function() {
160					modal.close();
161					return false;
162				});
163				
164			modalForm.on('submit', function(e) {
165				return self.submitModal.call(this, e, modalForm);
166			});
167
168			return modal;
169		},
170
171		/**
172		 * Handle form submitted via Modal
173		 */
174		submitModal: function(e, modalForm) 
175		{
176
177			var postData = modalForm.serializeArray();
178			postData.push({name: 'action', value: 'egcf_submit_consent'});
179
180			// Email field
181			var emailField = modalForm.data('email'),
182				email = formEle.find('[name="' + emailField + '"]');
183			
184			if (email.length) {
185				email = email.val();
186			}
187			else {
188				email = '';
189			}
190
191			postData.push({name: 'email', value: email});
192
193			self.toggleSubmitLabel(modalForm);
194
195			// Submit the modal form
196			$.post(EGCF_Plugin.ajax_url, postData, function(resp) {
197
198				if (resp.success) {
199					self.hasConsent = true;
200					formEle.data('has-consent', true);
201
202					// Add hidden fields
203					var fields = resp.data.fields;
204					Object.keys(fields).forEach(function(key) {
205
206						var input = formEle.find('[name="' + key + '"]');
207						if (input.length) {
208							input.val(fields[key]);
209						}
210						else {
211							formEle.append($("<input type='hidden' name='" + key + "' value='" + fields[key] + "'>"));
212						}
213					});
214
215					modal.close();
216					self.submitForm();
217
218					self.toggleSubmitLabel(modalForm);
219					//self.toggleSubmitLabel();
220				}
221			});
222
223			e.preventDefault();
224		}
225	};
226
227	return self;
228};
229
230jQuery(function($) {
231
232	// renable forms
233	$('#egcf-disable-submit').remove();
234
235	$('.egcf-consent-tpl').each(function() {
236
237		var tpl      = $(this),
238			selector = tpl.data('selector'),
239			config   = $.extend(tpl.data(), {'tpl': tpl});
240
241		$(selector).each(function() {
242
243			var form = $(this);
244
245			if (!form.is('form')) {
246				form = form.find('form');
247			}
248
249			if (!form.length) {
250				return;
251			}
252
253			var obj = new EGCF_Form($);
254			obj.init(form, config);
255		});
256	});
257});
258
259// Tingle Modal
260!function(t,o){"function"==typeof define&&define.amd?define(o):"object"==typeof exports?module.exports=o():t.tingle=o()}(this,function(){function t(t){var o={onClose:null,onOpen:null,beforeOpen:null,beforeClose:null,stickyFooter:!1,footer:!1,cssClass:[],closeLabel:"Close",closeMethods:["overlay","button","escape"]};this.opts=r({},o,t),this.init()}function o(){this.modalBoxFooter&&(this.modalBoxFooter.style.width=this.modalBox.clientWidth+"px",this.modalBoxFooter.style.left=this.modalBox.offsetLeft+"px")}function e(){this.modal=document.createElement("div"),this.modal.classList.add("tingle-modal"),0!==this.opts.closeMethods.length&&-1!==this.opts.closeMethods.indexOf("overlay")||this.modal.classList.add("tingle-modal--noOverlayClose"),this.modal.style.display="none",this.opts.cssClass.forEach(function(t){"string"==typeof t&&this.modal.classList.add(t)},this),-1!==this.opts.closeMethods.indexOf("button")&&(this.modalCloseBtn=document.createElement("button"),this.modalCloseBtn.classList.add("tingle-modal__close"),this.modalCloseBtnIcon=document.createElement("span"),this.modalCloseBtnIcon.classList.add("tingle-modal__closeIcon"),this.modalCloseBtnIcon.innerHTML="×",this.modalCloseBtnLabel=document.createElement("span"),this.modalCloseBtnLabel.classList.add("tingle-modal__closeLabel"),this.modalCloseBtnLabel.innerHTML=this.opts.closeLabel,this.modalCloseBtn.appendChild(this.modalCloseBtnIcon),this.modalCloseBtn.appendChild(this.modalCloseBtnLabel)),this.modalBox=document.createElement("div"),this.modalBox.classList.add("tingle-modal-box"),this.modalBoxContent=document.createElement("div"),this.modalBoxContent.classList.add("tingle-modal-box__content"),this.modalBox.appendChild(this.modalBoxContent),-1!==this.opts.closeMethods.indexOf("button")&&this.modal.appendChild(this.modalCloseBtn),this.modal.appendChild(this.modalBox)}function s(){this.modalBoxFooter=document.createElement("div"),this.modalBoxFooter.classList.add("tingle-modal-box__footer"),this.modalBox.appendChild(this.modalBoxFooter)}function i(){this._events={clickCloseBtn:this.close.bind(this),clickOverlay:l.bind(this),resize:this.checkOverflow.bind(this),keyboardNav:n.bind(this)},-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.addEventListener("click",this._events.clickCloseBtn),this.modal.addEventListener("mousedown",this._events.clickOverlay),window.addEventListener("resize",this._events.resize),document.addEventListener("keydown",this._events.keyboardNav)}function n(t){-1!==this.opts.closeMethods.indexOf("escape")&&27===t.which&&this.isOpen()&&this.close()}function l(t){-1!==this.opts.closeMethods.indexOf("overlay")&&!d(t.target,"tingle-modal")&&t.clientX<this.modal.clientWidth&&this.close()}function d(t,o){for(;(t=t.parentElement)&&!t.classList.contains(o););return t}function a(){-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.removeEventListener("click",this._events.clickCloseBtn),this.modal.removeEventListener("mousedown",this._events.clickOverlay),window.removeEventListener("resize",this._events.resize),document.removeEventListener("keydown",this._events.keyboardNav)}function r(){for(var t=1;t<arguments.length;t++)for(var o in arguments[t])arguments[t].hasOwnProperty(o)&&(arguments[0][o]=arguments[t][o]
260);return arguments[0]}var h=function(){var t,o=document.createElement("tingle-test-transition"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in e)if(void 0!==o.style[t])return e[t]}();return t.prototype.init=function(){this.modal||(e.call(this),i.call(this),document.body.insertBefore(this.modal,document.body.firstChild),this.opts.footer&&this.addFooter())},t.prototype.destroy=function(){null!==this.modal&&(a.call(this),this.modal.parentNode.removeChild(this.modal),this.modal=null)},t.prototype.open=function(){var t=this;"function"==typeof t.opts.beforeOpen&&t.opts.beforeOpen(),this.modal.style.removeProperty?this.modal.style.removeProperty("display"):this.modal.style.removeAttribute("display"),this._scrollPosition=window.pageYOffset,document.body.classList.add("tingle-enabled"),document.body.style.top=-this._scrollPosition+"px",this.setStickyFooter(this.opts.stickyFooter),this.modal.classList.add("tingle-modal--visible"),h?this.modal.addEventListener(h,function o(){"function"==typeof t.opts.onOpen&&t.opts.onOpen.call(t),t.modal.removeEventListener(h,o,!1)},!1):"function"==typeof t.opts.onOpen&&t.opts.onOpen.call(t),this.checkOverflow()},t.prototype.isOpen=function(){return!!this.modal.classList.contains("tingle-modal--visible")},t.prototype.close=function(){if("function"==typeof this.opts.beforeClose){if(!this.opts.beforeClose.call(this))return}document.body.classList.remove("tingle-enabled"),window.scrollTo(0,this._scrollPosition),document.body.style.top=null,this.modal.classList.remove("tingle-modal--visible");var t=this;h?this.modal.addEventListener(h,function o(){t.modal.removeEventListener(h,o,!1),t.modal.style.display="none","function"==typeof t.opts.onClose&&t.opts.onClose.call(this)},!1):(t.modal.style.display="none","function"==typeof t.opts.onClose&&t.opts.onClose.call(this))},t.prototype.setContent=function(t){"string"==typeof t?this.modalBoxContent.innerHTML=t:(this.modalBoxContent.innerHTML="",this.modalBoxContent.appendChild(t)),this.isOpen()&&this.checkOverflow()},t.prototype.getContent=function(){return this.modalBoxContent},t.prototype.addFooter=function(){s.call(this)},t.prototype.setFooterContent=function(t){this.modalBoxFooter.innerHTML=t},t.prototype.getFooterContent=function(){return this.modalBoxFooter},t.prototype.setStickyFooter=function(t){this.isOverflow()||(t=!1),t?this.modalBox.contains(this.modalBoxFooter)&&(this.modalBox.removeChild(this.modalBoxFooter),this.modal.appendChild(this.modalBoxFooter),this.modalBoxFooter.classList.add("tingle-modal-box__footer--sticky"),o.call(this),this.modalBoxContent.style["padding-bottom"]=this.modalBoxFooter.clientHeight+20+"px"):this.modalBoxFooter&&(this.modalBox.contains(this.modalBoxFooter)||(this.modal.removeChild(this.modalBoxFooter),this.modalBox.appendChild(this.modalBoxFooter),this.modalBoxFooter.style.width="auto",this.modalBoxFooter.style.left="",this.modalBoxContent.style["padding-bottom"]="",this.modalBoxFooter.classList.remove("tingle-modal-box__footer--sticky")))},t.prototype.addFooterBtn=function(t,o,e){var s=document.createElement("button");return s.innerHTML=t,s.addEventListener("click",e),"string"==typeof o&&o.length&&o.split(" ").forEach(function(t){s.classList.add(t)}),this.modalBoxFooter.appendChild(s),s},t.prototype.resize=function(){console.warn("Resize is deprecated and will be removed in version 1.0")},t.prototype.isOverflow=function(){var t=window.innerHeight;return this.modalBox.clientHeight>=t},t.prototype.checkOverflow=function(){this.modal.classList.contains("tingle-modal--visible")&&(this.isOverflow()?this.modal.classList.add("tingle-modal--overflow"):this.modal.classList.remove("tingle-modal--overflow"),!this.isOverflow()&&this.opts.stickyFooter?this.setStickyFooter(!1):this.isOverflow()&&this.opts.stickyFooter&&(o.call(this),this.setStickyFooter(!0)))},{modal:t}});

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.