PageSourceSearch

https://espritgames.com/wp-content/plugins/popups/public/assets/js/public.js?ver=1.9.3.8&osdk_ver=20270727_11

js espritgames.com collected 2026-09-24 09:12:09 UTC 29,990 bytes, 813 lines download raw bytes

1/*!
2 * imagesLoaded PACKAGED v3.1.8
3 * JavaScript is all like "You images are done yet or what?"
4 * MIT License
5 */
6(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;
6if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
7
8(function($){
9	"use strict";
10
11var SPU_master = function() {
12
13	var windowHeight 	= $(window).height();
14	var isAdmin 		= spuvar.is_admin;
15	var isPreview		= spuvar.is_preview;
16	var $boxes 			= [];
17
18	//remove paddings and margins from first and last items inside box
19	$(".spu-content").children().first().css({
20		"margin-top": 0,
21		"padding-top": 0
22	}).end().last().css({
23		'margin-bottom': 0,
24		'padding-bottom': 0
25	});
26
27	// loop through boxes
28	$(".spu-box").each(function() {
29
30		// vars
31		var $box 			= $(this);
32
33		// move to parent in top bar mode
34		if( $box.hasClass('spu-top-bar') || $box.hasClass('spu-bottom-bar') ){
35
36			$box.prependTo('body');
37			if( $box.hasClass('spu-top-bar') && $('#wpadminbar').length )
38				$box.css( 'top', '32px');
39		}
40
41		var triggerMethod 	= $box.data('trigger');
42		var timer 			= 0;
43		var testMode 		= (parseInt($box.data('test-mode')) === 1);
44		var id 				= $box.data('box-id');
45		var autoHide 		= (parseInt($box.data('auto-hide')) === 1);
46		var secondsClose    = parseInt($box.data('seconds-close'));
47		var triggerSeconds 	= parseInt( $box.data('trigger-number'), 10 );
48		var triggerPercentage = ( triggerMethod == 'percentage' ) ? ( parseInt( $box.data('trigger-number'), 10 ) / 100 ) : 0.8;
49		var triggerHeight 	= ( triggerPercentage * $(document).height() );
50
51		facebookFix( $box );
52		
53		// search for youtube, vimeo videos
54        var iframe = $box.find('iframe');
55        if( iframe && iframe.length) {
56        	iframe.each(function () {
57				$(this).attr('spusrc',$(this).attr('src'));
58				$(this).attr('src','http://#');
59            })
60		}
61        // Custom links conversion
62        $box.on('click', 'a:not(".spu-close-popup, .flp_wrapper a, .spu-not-close, .spu-not-close a")', function(){
63            // hide the popup and track conversion
64            toggleBox( id, false, true);
65        });
66        // Close and convert button
67        $box.on('click', '.spu-close-convert,.spu-close-convert a', function(e){
68        	e.preventDefault();
69            // hide the popup and track conversion
70            toggleBox( id, false, true);
71        });
72		//close with esc
73		$(document).keyup(function(e) {
74			if (e.keyCode == 27) {
75				toggleBox( id, false, false );
76			}
77		});
78		//close on ipads // iphones
79		var ua = navigator.userAgent,
80		event = (ua.match(/iPad/i) || ua.match(/iPhone/i)) ? "touchstart" : "click";
81
82
83		$('body').on(event, function (ev) {
84			var $target = $(ev.target);
85			// for some reason ninja form in ajax mode not working, added this dirty workadound
86			// $.contains( $box, $target ) return false , same for .has .parents, etc
87			// so no popup closing when form is clicked
88			if($target.is('input.nf-element')) {
89                return;
90            }
91
92			// test that event is user triggered and not programatically,
93			// and that it is not fired from input within the box
94			if( ev.originalEvent !== undefined && ! ( $.contains( $box, $target ) && $target.is('input') ) && ! $box.hasClass('spu-top-bar') && ! $box.hasClass('spu-bottom-bar') ) {
95				toggleBox( id, false, false );
96			}
97		});
98		//not on the box
99        $('body' ).on(event,'.spu-box,.spu-clickable', function(event) {
100            event.stopPropagation();
101        });
102		//hide boxes and remove left-99999px we cannot since beggining of facebook won't display
103		$box.hide().css('left','').css('right','');
104
105		// add box to global boxes array
106		$boxes[id] = $box;
107
108		// functions that check % of height
109		var triggerHeightCheck = function()
110		{
111			if(timer) {
112				clearTimeout(timer);
113			}
114
115			timer = window.setTimeout(function() {
116				var scrollY = $(window).scrollTop();
117				var triggered = ((scrollY + windowHeight) >= triggerHeight);
118
119				// show box when criteria for this box is matched
120				if( triggered ) {
121
122					// remove listen event if box shouldn't be hidden again
123					if( ! autoHide ) {
124						$(window).unbind('scroll', triggerHeightCheck);
125					}
126
127					toggleBox( id, true, false );
128				} else {
129					toggleBox( id, false, false );
130				}
131
132			}, 100);
133		}
134
135		// functions that check pixels of height
136		var triggerPixelsCheck = function()
137		{
138			if(timer) {
139				clearTimeout(timer);
140			}
141
142			timer = window.setTimeout(function() {
143				var scrollY = $(window).scrollTop();
144				var triggered = ( scrollY  >= triggerSeconds);//triggerSeconds equals to the number field really
145
146				// show box when criteria for this box is matched
147				if( triggered ) {
148
149					// remove listen event if box shouldn't be hidden again
150					if( ! autoHide ) {
151						$(window).unbind('scroll', triggerPixelsCheck);
152					}
153
154					toggleBox( id, true, false );
155				} else {
156					toggleBox( id, false, false );
157				}
158
159			}, 100);
160		}
161		// function that show popup after X secs
162		var triggerSecondsCheck = function()
163		{
164			if(timer) {
165				clearTimeout(timer);
166			}
167
168			timer = window.setTimeout(function() {
169
170				toggleBox( id, true, false );
171
172			}, triggerSeconds * 1000);
173		}
174
175		// show box if cookie not set or if in test mode
176		//var cookieValue = spuReadCookie( 'spu_box_' + id );
177
178		var nclose_cookie = $box.data('nclose-cookie');
179		var nconvert_cookie = $box.data('nconvert-cookie');
180
181		var cookieValue1 = spuReadCookie( nclose_cookie );
182		var cookieValue2 = spuReadCookie( nconvert_cookie );
183
184		if( (
185				( cookieValue1 == undefined || cookieValue1 == '' ) &&
186				( cookieValue2 == undefined || cookieValue2 == '' )
187			) || ( isAdmin && testMode ) || isPreview ) {
188
189			if(triggerMethod == 'seconds') {
190				triggerSecondsCheck();
191			}
192			if(triggerMethod == 'percentage'){
193				$(window).bind( 'scroll', triggerHeightCheck );
194				// init, check box criteria once
195				triggerHeightCheck();
196			}
197			if(triggerMethod == 'pixels'){
198				$(window).bind( 'scroll', triggerPixelsCheck );
199				// init, check box criteria once
200				triggerPixelsCheck();
201			}
202
203			// shows the box when hash refers to a box
204			if(window.location.hash && window.location.hash.length > 0) {
205
206				var hash = window.location.hash;
207				var $element;
208
209				if( hash.substring(1) === $box.attr( 'id' ) ) {
210					setTimeout(function() {
211						toggleBox( id, true, false );
212					}, 100);
213				}
214			}
215		}	/* end check cookie */
216		//close popup
217		$box.on('click','.spu-close-popup',function() {
218
219			// hide box
220			toggleBox( id, false, false );
221
222			if(triggerMethod == 'percentage') {
223				// unbind
224				$(window).unbind( 'scroll', triggerHeightCheck );
225			}
226
227		});
228
229		// add link listener for this box
230		$(document.body).on('click','a[href="#spu-' + id +'"], .spu-open-' + id ,function(e) {
231			e.preventDefault();
232			toggleBox(id, true, false);
233		});
234		$('a[href="#spu-' + id +'"], .spu-open-' + id).css('cursor','pointer').addClass('spu-clickable');
235
236		// add class to the gravity form if they exist within the box
237		$box.find('.gform_wrapper form').addClass('gravity-form');
238		// same for mc4wp
239		$box.find('.mc4wp-form form').addClass('mc4wp-form');
240		// same for newsletter plugin
241		$box.find('.newsletter form').addClass('newsletter-form');
242
243		// check if we have forms and perform different actions
244		var box_form = $box.find('form');
245		if( box_form.length ) {
246			// Only if form is not a known one disable ajax
247			if( ! box_form.is(".newsletter-form, .wpcf7-form, .gravity-form, .infusion-form, .widget_wysija, .ninja-forms-form") ) {
248				var action = box_form.attr('action'),
249					pattern = new RegExp(spuvar.site_url, "i");
250				if (action && action.length) {
251					if (!pattern.test(action))
252						box_form.addClass('spu-disable-ajax');
253				}
254			}
255			// if spu-disable-ajax is on container add it to form (usp forms for example)
256			if( $('.spu-disable-ajax form').length ) {
257				$('.spu-disable-ajax form').addClass('spu-disable-ajax');
258			}
259			// Disable ajax on form by adding .spu-disable-ajax class to it
260			$box.on('submit','form.spu-disable-ajax:not(".flp_form")', function(){
261
262				$box.trigger('spu.form_submitted', [id]);
263				toggleBox(id, false, true );
264			});
265
266			// Add generic form tracking
267			$box.on('submit','form:not(".newsletter-form, .wpcf7-form, .gravity-form, .infusion-form, .spu-disable-ajax, .widget_wysija, .ninja-forms-form, .flp_form")', function(e){
268				e.preventDefault();
269
270				var submit 	= true,
271					form 		= $(this),
272					button 		= form.find('input[type="submit"]'),
273					tail		= button ? button.attr('name')+'='+button.val() : 'button=send',
274					data 	 	= form.serialize()+"&"+tail,
275					referer 	= form.find('input[name="_wp_http_referer"]'),
276					urlref		= referer && referer.val() !== undefined ? spuvar.site_url+referer.val() : window.location.href,
277					action 		= form.attr('action') ? form.attr('action') : urlref,
278					url  	 	= form.hasClass('mc4wp-form') ? spuvar.site_url +'/' : action,
279					error_cb 	= function (data, error, errorThrown){
280						console.log('Spu Form error: ' + error + ' - ' + errorThrown);
281						//console.log(data);
282					},
283					success_cb 	= function (data){
284
285						var response = $(data).filter('#spu-'+ id ).html();
286						$('#spu-' + id ).html(response);
287
288						// check if an error was returned for m4wp
289						if( ! $('#spu-' + id ).find('.mc4wp-alert').length ) {
290
291							// give 2 seconds for response
292							setTimeout( function(){
293
294								toggleBox(id, false, true );
295
296							}, spuvar.seconds_confirmation_close * 1000);
297
298						} 
299					};
300
301				// Send form by ajax and replace popup with response
302				request(data, url, success_cb, error_cb, 'html');
303
304				$box.trigger('spu.form_submitted', [id]);
305
306				return submit;
307			});
308
309			// CF7 support
310			$(document).on('wpcf7mailsent', function(){
311				$box.trigger('spu.form_submitted', [id]);
312				toggleBox(id, false, true );
313			});
314
315			// Gravity forms support (only AJAX mode)
316			if( box_form.hasClass('gravity-form') ) {
317				box_form.attr('action', window.location.href)
318			}
319			$(document).on('gform_confirmation_loaded', function(){
320				$box.trigger('spu.form_submitted', [id]);
321				toggleBox(id, false, true );
322			});
323
324			// Infusion Software - not ajax
325			$box.on('submit','.infusion-form', function(e){
326				e.preventDefault();
327				$box.trigger('spu.form_submitted', [id]);
328				toggleBox(id, false, true );
329				this.submit();
330			});
331			// The newsletter plugin - not ajax
332			$box.on('submit','.newsletter-form', function(e){
333				e.preventDefault();
334				$box.trigger('spu.form_submitted', [id]);
335				toggleBox(id, false, true );
336				this.submit();
337			});
338			// Ninja form - popup not ajax, ajax on ninja form
339			$('body').on('submitResponse.default', function(){
340				$box.trigger('spu.form_submitted', [id]);
341				toggleBox(id, false, true );
342			});
343		}
344
345		// Ninja Forms 3 does not use a form element
346		var box_nf3 = $box.find('.nf-form-cont');
347		if ( box_nf3.length ) {
348			$(document).on('nfFormSubmitResponse', function(){
349				$box.trigger('spu.form_submitted', [id]);
350
351				// delay box close so user sees submission feedback
352				// should this delay be a config option?
353				setTimeout( function(){
354					toggleBox(id, false, true );
355				}, spuvar.seconds_confirmation_close * 1000);
356			});
357		}
358
359	});
360
361
362
363	//function that center popup on screen
364	function fixSize( id ) {
365		var $box 			= $boxes[id];
366		var windowWidth 	= $(window).width();
367		var windowHeight 	= $(window).height();
368		var popupHeight 	= $box.outerHeight();
369		var popupWidth 		= $box.outerWidth();
370		var intentWidth		= $box.data('width');
371		var left 			= 0;
372		var top 			= windowHeight / 2 - popupHeight / 2;
373		var position 		= 'fixed';
374		var currentScroll   = $(document).scrollTop();
375
376		if( $box.hasClass('spu-centered') ){
377			if( intentWidth < windowWidth ) {
378				left = windowWidth / 2 - popupWidth / 2;
379			}
380			$box.css({
381				"left": 	left,
382				"position": position,
383				"top": 		top,
384			});
385		}
386
387		// if popup is higher than viewport we need to make it absolute
388		if( (popupHeight + 50) > windowHeight ) {
389			position 	= 'absolute';
390			top 		= currentScroll;
391
392			$box.css({
393				"position": position,
394				"top": 		top,
395				"bottom": 	"auto",
396				//"right": 	"auto",
397				//"left": 	"auto",
398			});
399		}
400
401	}
402
403	//facebookBugFix
404	function facebookFix( box ) {
405
406		// Facebook bug that fails to resize
407		var $fbbox = $(box).find('.spu-facebook');
408		if( $fbbox.length ){
409			//if exist and width is 0
410			var $fbwidth = $fbbox.find('.fb-like > span').width();
411			if ( $fbwidth == 0 ) {
412				var $fblayout = $fbbox.find('.fb-like').data('layout');
413				 if( $fblayout == 'box_count' ) {
414
415					$fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>');
416
417				 } else if( $fblayout == 'button_count' ) {
418
419					$fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;min-width: 120px !important;}</style>');
420
421				 } else {
422
423					$fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>');
424
425				 }
426			}
427		}
428	}
429
430	/**
431	 * Check all shortcodes and automatically center them
432	 * @param box
433	 */
434	function centerShortcodes( box ){
435		var $box 	= box;
436		var total = $box.data('total'); //total of shortcodes used
437		if( total ) { //if we have shortcodes
438			//SPU_reload_socials(); //remove 20180515
439
440			//wrap them all
441			//center spu-shortcodes
442			var swidth = 0;
443			var free_width = 0;
444			var boxwidth = $box.outerWidth();
445			var cwidth = $box.find(".spu-content").width();
446			if (!spuvar.disable_style && $(window).width() > boxwidth) {
447				$box.find(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>');
448				//calculate total width of shortcodes all togheter
449				$box.find(".spu-shortcode").each(function () {
450					swidth = swidth + $(this).outerWidth();
451				});
452				//available space to split margins
453				free_width = cwidth - swidth - (total*20);
454
455			}
456			if (free_width > 0) {
457				//leave some margin
458				$box.find(".spu-shortcode").each(function () {
459
460					$(this).css('margin-left', (free_width / 2 ));
461
462				});
463				//remove margin when neccesary
464				if (total == 2) {
465
466					$box.find(".spu-shortcode").last().css('margin-left', 0);
467
468				} else if (total == 3) {
469
470					$box.find(".spu-shortcode").first().css('margin-left', 0);
471
472				}
473			}
474		}
475	}
476	/**
477	 * Main function to show or hide the popup
478	 * @param id int box id
479	 * @param show boolean it's hiding or showing?
480	 * @param conversion boolean - Its a conversion or we are just closing
481	 * @returns {*}
482	 */
483	function toggleBox( id, show, conversion ) {
484		var $box 	= $boxes[id];
485		var $bg	 	= $('#spu-bg-'+id);
486		var $bgopa 	= $box.data('bgopa');
487
488		// don't do anything if box is undergoing an animation
489		if( $box.is( ":animated" ) ) {
490			return false;
491		}
492
493		// is box already at desired visibility?
494		if( ( show === true && $box.is( ":visible" ) ) || ( show === false && $box.is( ":hidden" ) ) ) {
495			return false;
496		}
497
498		//if we are closing , set cookie
499		if( show === false) {
500			// set cookie
501			var tcookie = $box.data('tclose-cookie');
502			var dcookie = parseFloat( $box.data('dclose-cookie') );
503			var ncookie = $box.data('nclose-cookie');
504			
505			if( conversion === true ) {
506				tcookie = $box.data('tconvert-cookie');
507				dcookie = parseFloat( $box.data('dconvert-cookie') );
508				ncookie = $box.data('nconvert-cookie');
509			}
510			
511			if( dcookie > 0 ) {
512				spuCreateCookie( ncookie, true, tcookie, dcookie );
513			}
514			$box.trigger('spu.box_close', [id]);
515			// check for videos inside and destroy it
516            var iframe = $box.find('iframe[src*="vimeo"],iframe[src*="youtube"],iframe[src*="youtu.be"]');
517			if( iframe && iframe.length ){
518				iframe.each(function () {
519					$(this).attr('src','http://#');
520                });
521			}
522		} else {
523			setTimeout(function(){
524				centerShortcodes($box);
525			},1500);
526			$box.trigger('spu.box_open', [id]);
527			//bind for resize
528			$(window).resize(function(){
529
530				fixSize( id );
531
532			});
533			fixSize( id );
534            var iframe = $box.find('iframe');
535            if( iframe && iframe.length ){
536                iframe.each(function () {
537                	if( $(this).attr('spusrc') )
538                    	$(this).attr('src',$(this).attr('spusrc'));
539                });
540            }
541
542		}
543
544		// show box
545		var animation = $box.data('spuanimation'),
546			conversion_close = $box.data('close-on-conversion');
547
548
549		if (animation === 'fade') {
550			if (show === true) {
551				$box.fadeIn('slow');
552			} else if (show === false && ( (conversion_close && conversion ) || !conversion )) {
553				$box.fadeOut('slow');
554			}
555		}else if (animation === 'disable') {
556			if (show === true ) {
557				$box.show();
558			} else if (show === false && ( (conversion_close && conversion ) || !conversion )  ) {
559				$box.hide();
560			}
561		} else {
562			if (show === true ) {
563				$box.slideDown('slow');
564			} else if (show === false && ( (conversion_close && conversion ) || !conversion )  ) {
565				$box.slideUp('slow');
566			}
567		}
568
569		//background
570		if (show === true && $bgopa > 0 && !$box.hasClass('spu-top-bar') && !$box.hasClass('spu-bottom-bar')) {
571			if (animation === 'disable') {
572				$bg.show();
573			} else {
574				$bg.fadeIn();
575			}
576		} else if (show === false && ( (conversion_close && conversion ) || !conversion ) ) {
577			if (animation === 'disable') {
578				$bg.hide();
579			} else {
580				$bg.fadeOut();
581			}
582		}
583
584		return show;
585	}
586
587	return {
588		show: function( box_id ) {
589			return toggleBox( box_id, true, false );
590		},
591		hide: function( box_id, conversion ) {
592			return toggleBox( box_id, false, conversion );
593		},
594		resize: function (box_id) {
595			return fixSize( box_id );
596        },
597		request: function( data, url, success_cb, error_cb ) {
598			return request( data, url, success_cb, error_cb );
599		}
600	}
601
602}
603if( spuvar.ajax_mode ) {
604
605	var data = {
606		pid : spuvar.pid,
607		referrer : document.referrer,
608		current_url : document.documentURI,
609		query_string : document.location.search,
610		is_category : spuvar.is_category,
611		is_archive : spuvar.is_archive,
612		is_preview: spuvar.is_preview
613	}
614	,success_cb = function(response) {
615
616		$('body').append(response);
617		$(".spu-box").imagesLoaded( function() {
618			window.SPU = SPU_master();
619			SPU_reload_forms(); //remove spu_Action from forms
620		});
621	},
622	error_cb 	= function (data, error, errorThrown){
623		console.log('Problem loading popups - error: ' + error + ' - ' + errorThrown);
624	}
625	request(data, spuvar.ajax_mode_url , success_cb, error_cb, 'html');
626} else {
627	$(".spu-box").imagesLoaded( function(){
628		window.SPU = SPU_master();
629	});
630}
631
632	/**
633	 * Ajax requests
634	 * @param data
635	 * @param url
636	 * @param success_cb
637	 * @param error_cb
638	 * @param dataType
639	 */
640	function request(data, url, success_cb, error_cb, dataType){
641		// Prepare variables.
642		var ajax       = {
643				url:      spuvar.ajax_url,
644				data:     data,
645				cache:    false,
646				type:     'POST',
647				dataType: 'json',
648				timeout:  30000
649			},
650			dataType   = dataType || false,
651			success_cb = success_cb || false,
652			error_cb   = error_cb   || false;
653
654		// Set ajax url is supplied
655		if ( url ) {
656			ajax.url = url;
657		}
658		// Set success callback if supplied.
659		if ( success_cb ) {
660			ajax.success = success_cb;
661		}
662
663		// Set error callback if supplied.
664		if ( error_cb ) {
665			ajax.error = error_cb;
666		}
667
668		// Change dataType if supplied.
669		if ( dataType ) {
670			ajax.dataType = dataType;
671		}
672		// Make the ajax request.
673		$.ajax(ajax);
674
675	}
676/**
677 * Cookie functions
678 */
679function spuCreateCookie(name, value, type, duration) {
680	if (duration) {
681		var date = new Date();
682
683		if( type == 'h' )
684			date.setTime(date.getTime() + (duration * 60 * 60 * 1000));
685		else
686			date.setTime(date.getTime() + (duration * 24 * 60 * 60 * 1000));
687
688		var expires = "; expires=" + date.toGMTString();
689	} else var expires = "";
690	document.cookie = name + "=" + value + expires + "; path=/";
691}
692
693function spuReadCookie(name) {
694	var nameEQ = name + "=";
695	var ca = document.cookie.split(';');
696	for (var i = 0; i < ca.length; i++) {
697		var c = ca[i];
698		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
699		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
700	}
701	return null;
702}
703
704/**
705 * Social Callbacks
706 */
707var SPUfb = false;
708
709var FbTimer = setInterval(function(){
710	if( typeof FB !== 'undefined' && ! SPUfb) {
711		subscribeFbEvent();
712
713	}
714},1000);
715
716if ( typeof twttr !== 'undefined') {
717	try{
718		twttr.ready(function(twttr) {
719			twttr.events.bind('tweet', twitterCB);
720			twttr.events.bind('follow', twitterCB);
721		});
722	}catch(ex){}
723}
724
725
726function subscribeFbEvent(){
727	try {
728		FB.Event.subscribe('edge.create', function (href, html_element) {
729			var box_id = $(html_element).parents('.spu-box').data('box-id');
730			if (box_id) {
731				SPU.hide(box_id, false, true);
732			}
733		});
734	}catch(ex){}
735	SPUfb = true;
736	clearInterval(FbTimer);
737}
738function twitterCB(intent_event) {
739
740	var box_id = $(intent_event.target).parents('.spu-box').data('box-id');
741
742	if( box_id) {
743		SPU.hide(box_id, false, true);
744	}
745}
746function googleCB(a) {
747
748	if( "on" == a.state ) {
749
750		var box_id = jQuery('.spu-gogl').data('box-id');
751		if( box_id) {
752			SPU.hide(box_id, false, true);
753		}
754	}
755}
756function closeGoogle(a){
757	if( "confirm" == a.type )
758	{
759		var box_id = jQuery('.spu-gogl').data('box-id');
760		if( box_id) {
761			SPU.hide(box_id, false, true);
762
763		}
764	}
765}
766function SPU_reload_socials(){
767	if( typeof spuvar_social != 'undefined' && spuvar_social.facebook) {
768
769		// reload fb
770		try{
771			FB.XFBML.parse();
772		}catch(ex){}
773	}
774	if( typeof spuvar_social != 'undefined' && spuvar_social.google){
775		try {
776			// reload google
777			gapi.plusone.go();
778		}catch(ex){}
779	}
780	if( typeof spuvar_social != 'undefined' && spuvar_social.twitter ) {
781		try {
782			//reload twitter
783			twttr.widgets.load();
784		}catch(ex){}
785	}
786}
787function SPU_reload_forms(){
788	// Clear actions
789	$('.spu-box form').each( function(){
790		var action = $(this).attr('action');
791		if( action ){
792			$(this).attr('action' , action.replace('?spu_action=spu_load',''));
793		}
794	});
795
796	// CF7 > 4.8
797	if ( typeof wpcf7 !== 'undefined' && wpcf7 !== null && wpcf7.initForm ) {
798
799		$('.spu-box div.wpcf7 > form').each(function () {
800			wpcf7.initForm( $(this) );
801
802			if ( wpcf7.cached ) {
803				wpcf7.refill( $(this) );
804			}
805		});
806	}
807
808	// Old Version CF7
809	if ($.fn.wpcf7InitForm) {
810		$('.spu-box div.wpcf7 > form').wpcf7InitForm();
811	}
812}
813})(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.