PageSourceSearch

https://vahome.loan/wp-content/plugins/popup-builder-silver/javascript/sg_popup_frontend.js?ver=2.66

js vahome.loan collected 2026-10-09 22:11:42 UTC 35,994 bytes, 1,178 lines download raw bytes

1function SGPopup() {
2
3	this.positionLeft = '';
4	this.positionTop = '';
5	this.positionBottom = '';
6	this.positionRight = '';
7	this.initialPositionTop = '';
8	this.initialPositionLeft = '';
9	this.isOnLoad = '';
10	this.openOnce = '';
11	this.numberLimit = '';
12	this.popupData = new Array();
13	this.popupEscKey = true;
14	this.popupOverlayClose = true;
15	this.popupContentClick = false;
16	this.popupCloseButton = true;
17	this.sgTrapFocus = true;
18	this.popupType = '';
19	this.popupClassEvents = ['hover'];
20	this.eventExecuteCountByClass = 0;
21	this.sgEventExecuteCount = 0;
22	this.resizeTimer = null;
23	this.sgColorboxContentTypeReset();
24}
25
26SGPopup.prototype.sgColorboxContentTypeReset = function () {
27
28	/*colorbox settings mode*/
29	this.sgColorboxHtml = false;
30	this.sgColorboxPhoto = false;
31	this.sgColorboxIframe = false;
32	this.sgColorboxHref = false;
33	this.sgColorboxInline = false;
34};
35
36/*Popup thems default paddings where key is theme number value padding*/
37SGPopup.sgColorBoxDeafults = {1 : 70, 2: 34, 3: 30, 4 : 70, 5 : 62, 6: 70};
38
39SGPopup.prototype.popupOpenById = function (popupId) {
40
41	var sgOnScrolling = (SG_POPUP_DATA [popupId]['onScrolling']) ? SG_POPUP_DATA [popupId]['onScrolling'] : '';
42	var sgInActivity = (SG_POPUP_DATA [popupId]['inActivityStatus']) ? SG_POPUP_DATA [popupId]['inActivityStatus'] : '';
43	var autoClosePopup = (SG_POPUP_DATA [popupId]['autoClosePopup']) ? SG_POPUP_DATA [popupId]['autoClosePopup'] : '';
44
45	if (sgOnScrolling) {
46		this.onScrolling(popupId);
47	}
48	else if (sgInActivity) {
49		this.showPopupAfterInactivity(popupId);
50	}
51	else {
52		this.showPopup(popupId, true);
53	}
54};
55
56SGPopup.getCookie = function (cName) {
57
58	var name = cName + "=";
59	var ca = document.cookie.split(';');
60	for (var i = 0; i < ca.length; i++) {
61		var c = ca[i];
62		while (c.charAt(0) == ' ') {
63			c = c.substring(1);
64		}
65		if (c.indexOf(name) == 0) {
66			return c.substring(name.length, c.length);
67		}
68	}
69	return "";
70};
71
72SGPopup.deleteCookie = function (name) {
73
74	document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
75};
76
77SGPopup.setCookie = function (cName, cValue, exDays, cPageLevel) {
78
79	var expirationDate = new Date();
80	var cookiePageLevel = '';
81	var cookieExpirationData = 1;
82	if (!exDays || isNaN(exDays)) {
83		exDays = 365 * 50;
84	}
85	if (typeof cPageLevel == 'undefined') {
86		cPageLevel = false;
87	}
88	expirationDate.setDate(expirationDate.getDate() + exDays);
89	cookieExpirationData = expirationDate.toString();
90	var expires = 'expires='+cookieExpirationData;
91
92	if (exDays == -1) {
93		expires = '';
94	}
95
96	if (cPageLevel) {
97		cookiePageLevel = 'path=/;';
98	}
99
100	var value = cValue + ((exDays == null) ? ";" : "; " + expires + ";" + cookiePageLevel);
101	document.cookie = cName + "=" + value;
102};
103
104SGPopup.prototype.init = function () {
105
106	var that = this;
107
108	this.onCompleate();
109	this.popupOpenByCookie();
110	this.attacheShortCodeEvent();
111	this.attacheClickEvent();
112	this.popupOpenByClickUrl();
113	this.attacheIframeEvent();
114	this.attacheConfirmEvent();
115	this.popupClassEventsTrigger();
116};
117
118SGPopup.prototype.popupOpenByClickUrl = function () {
119
120	var that = this;
121	if(jQuery("a[href*=sg-popup-id-]").length) {
122		jQuery("a[href*=sg-popup-id-]").each(function () {
123			jQuery(this).bind('click', function (e) {
124				e.preventDefault();
125				var href = jQuery(this).attr('href');
126				var splitData = href.split("sg-popup-id-");
127
128				if(typeof splitData[1] != 'undefined') {
129					var popupId = parseInt(splitData[1]);
130					that.showPopup(popupId, false);
131				}
132			})
133		});
134	}
135};
136
137SGPopup.prototype.attacheShortCodeEvent = function () {
138
139	var that = this;
140
141	jQuery(".sg-show-popup").each(function () {
142		var popupEvent = jQuery(this).attr("data-popup-event");
143		if (typeof popupEvent == 'undefined') {
144			popupEvent = 'click';
145		}
146		/* For counting execute and did it one time for popup open */
147		that.sgEventExecuteCount = 0;
148		jQuery(this).bind(popupEvent, function () {
149			that.sgEventExecuteCount += 1;
150			if (that.sgEventExecuteCount > 1) {
151				return;
152			}
153			var sgPopupID = jQuery(this).attr("data-sgpopupid");
154			that.showPopup(sgPopupID, false);
155		});
156	});
157};
158
159SGPopup.prototype.attacheConfirmEvent = function () {
160
161	var that = this;
162
163	jQuery("[class*='sg-confirm-popup-']").each(function () {
164		jQuery(this).bind("click", function (e) {
165			e.preventDefault();
166			var currentLink = jQuery(this);
167			var className = jQuery(this).attr("class");
168
169			var sgPopupId = that.findPopupIdFromClassNames(className, "sg-confirm-popup-");
170
171			jQuery('#sgcolorbox').bind("sgPopupClose", function () {
172				var target = currentLink.attr("target");
173
174				if (typeof target == 'undefined') {
175					target = "self";
176				}
177				var href = currentLink.attr("href");
178
179				if (target == "_blank") {
180					window.open(href);
181				}
182				else {
183					window.location.href = href;
184				}
185			});
186			that.showPopup(sgPopupId, false);
187		})
188	});
189};
190
191SGPopup.prototype.attacheIframeEvent = function () {
192
193	var that = this;
194	/* When user set popup by class name */
195	jQuery("[class*='sg-iframe-popup-']").each(function () {
196		var currentLink = jQuery(this);
197		jQuery(this).bind("click", function (e) {
198			e.preventDefault();
199			var className = jQuery(this).attr("class");
200
201			var sgPopupId = that.findPopupIdFromClassNames(className, "sg-iframe-popup-");
202
203			/*This update for dynamic open iframe url for same popup*/
204			var linkUrl = currentLink.attr("href");
205
206			if (typeof linkUrl == 'undefined') {
207				var childLinkTag = currentLink.find('a');
208				linkUrl = childLinkTag.attr("href");
209			}
210
211			SG_POPUP_DATA[sgPopupId]['iframe'] = linkUrl;
212
213			that.showPopup(sgPopupId, false);
214		});
215	});
216};
217
218SGPopup.prototype.attacheClickEvent = function () {
219
220	var that = this;
221	/* When user set popup by class name */
222	jQuery("[class*='sg-popup-id-']").each(function () {
223		jQuery(this).bind("click", function (e) {
224			e.preventDefault();
225			var className = jQuery(this).attr("class");
226			var sgPopupId = that.findPopupIdFromClassNames(className, "sg-popup-id-");
227
228			that.showPopup(sgPopupId, false);
229		})
230	});
231};
232
233SGPopup.prototype.popupClassEventsTrigger = function () {
234
235	var popupEvents = this.popupClassEvents;
236	var that = this;
237
238	if(popupEvents.length > 0) {
239
240		for (var i in popupEvents) {
241			var eventName = popupEvents[i];
242
243			that.attacheCustomEvent(eventName);
244		}
245	}
246};
247
248SGPopup.prototype.attacheCustomEvent = function (eventName) {
249
250	if(typeof eventName == 'undefined' ||  typeof eventName == 'function' || eventName == '') {
251		return;
252	}
253	var that = this;
254
255	jQuery("[class*='sg-popup-"+eventName+"-']").each(function () {
256		var eventCount = that.eventExecuteCountByClass;
257		jQuery(this).bind(eventName, function () {
258			eventCount = ++that.eventExecuteCountByClass;
259			if (eventCount > 1) {
260				return;
261			}
262			var className = jQuery(this).attr("class");
263			var sgPopupId = that.findPopupIdFromClassNames(className, 'sg-popup-'+eventName+'-');
264
265			that.showPopup(sgPopupId, false);
266		})
267	});
268};
269
270SGPopup.prototype.popupOpenByCookie = function () {
271
272	var popupId = SGPopup.getCookie("sgSubmitReloadingForm");
273	popupId = parseInt(popupId);
274
275	if (typeof popupId == 'number') {
276		this.showPopup(popupId, false);
277	}
278};
279
280SGPopup.prototype.findPopupIdFromClassNames = function (className, classKey) {
281
282	var classSplitArray = className.split(classKey);
283	var classIdString = classSplitArray['1'];
284	/*Get first all number from string*/
285	var popupId = classIdString.match(/^\d+/);
286
287	return popupId;
288};
289
290SGPopup.prototype.hexToRgba = function (hex, opacity){
291
292	var c;
293	if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
294		c = hex.substring(1).split('');
295
296		if(c.length == 3){
297			c= [c[0], c[0], c[1], c[1], c[2], c[2]];
298		}
299		c = '0x'+c.join('');
300		return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')';
301	}
302	throw new Error('Bad Hex');
303};
304
305
306SGPopup.prototype.sgCustomizeThemes = function (popupId) {
307
308	var popupData = SG_POPUP_DATA[popupId];
309	var borderRadiues = popupData['sg3ThemeBorderRadiues'];
310	var popupContentOpacity = popupData['popup-background-opacity'];
311	var popupContentColor = jQuery('#sgcboxContent').css('background-color');
312	var contentBackgroundColor = popupData['sg-content-background-color'];
313	var changedColor = popupContentColor.replace(')', ', '+popupContentOpacity+')').replace('rgb', 'rgba');
314
315	if(contentBackgroundColor != '') {
316		changedColor = this.hexToRgba(contentBackgroundColor, popupContentOpacity);
317	}
318
319
320	if (popupData['theme'] == "colorbox3.css") {
321		var borderColor = popupData['sgTheme3BorderColor'];
322		var borderRadiues = popupData['sgTheme3BorderRadius'];
323		jQuery("#sgcboxLoadedContent").css({'border-color': borderColor});
324		jQuery("#sgcboxLoadedContent").css({'border-radius': borderRadiues + "%"});
325		jQuery("#sgcboxContent").css({'border-radius': borderRadiues + "%"})
326	}
327
328	jQuery('#sgcboxContent').css({'background-color': changedColor});
329	jQuery('#sgcboxLoadedContent').css({'background-color': changedColor})
330
331};
332
333SGPopup.prototype.onCompleate = function () {
334
335	jQuery("#sgcolorbox").bind("sgColorboxOnCompleate", function () {
336
337		/* Scroll only inside popup */
338		jQuery('#sgcboxLoadedContent').isolatedScroll();
339	});
340	this.isolatedScroll();
341};
342
343SGPopup.prototype.isolatedScroll = function () {
344
345	jQuery.fn.isolatedScroll = function () {
346		this.bind('mousewheel DOMMouseScroll', function (e) {
347			var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,
348				bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,
349				topOverflow = this.scrollTop <= 0;
350
351			if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
352				e.preventDefault();
353			}
354		});
355		return this;
356	};
357};
358
359SGPopup.prototype.sgPopupScalingDimensions = function () {
360
361	var popupWrapper = jQuery("#sgcboxWrapper").outerWidth();
362	var screenWidth = jQuery(window).width();
363	/*popupWrapper != 9999  for resizing case when colorbox is calculated popup dimensions*/
364	if (popupWrapper > screenWidth && popupWrapper != 9999) {
365		var scaleDegree = screenWidth / popupWrapper;
366		jQuery("#sgcboxWrapper").css({
367			"transform-origin": "0 0",
368			'transform': "scale(" + scaleDegree + ", 1)"
369		});
370		popupWrapper = 0;
371	}
372	else {
373		jQuery("#sgcboxWrapper").css({
374			"transform-origin": "0 0",
375			'transform': "scale(1, 1)"
376		})
377	}
378};
379
380SGPopup.prototype.sgPopupScaling = function () {
381
382	var that = this;
383	jQuery("#sgcolorbox").bind("sgColorboxOnCompleate", function () {
384		that.sgPopupScalingDimensions();
385	});
386	jQuery(window).resize(function () {
387		setTimeout(function () {
388			that.sgPopupScalingDimensions();
389		}, 1000);
390	});
391};
392
393SGPopup.prototype.varToBool = function (optionName) {
394
395	var returnValue = (optionName) ? true : false;
396	return returnValue;
397};
398
399SGPopup.prototype.canOpenPopup = function (id, openOnce, isOnLoad) {
400
401	if (!isOnLoad) {
402		return true;
403	}
404
405	var currentCookies = SGPopup.getCookie('sgPopupCookieList');
406	if (currentCookies) {
407		currentCookies = JSON.parse(currentCookies);
408
409		for (var cookieIndex in currentCookies) {
410			var cookieName = currentCookies[cookieIndex];
411			var cookieData = SGPopup.getCookie(cookieName + id);
412
413			if (cookieData) {
414				return false;
415			}
416		}
417	}
418
419	var popupCookie = SGPopup.getCookie('sgPopupDetails' + id);
420	var popupType = this.popupType;
421
422	/*for popup this often case */
423	if (openOnce && popupCookie != '') {
424		return this.canOpenOnce(id);
425	}
426
427	return true;
428};
429
430SGPopup.prototype.canOpenOnce = function(id) {
431
432	var cookieData = SGPopup.getCookie('sgPopupDetails'+id);
433	if(!cookieData) {
434		return true;
435	}
436	var cookieData = JSON.parse(cookieData);
437
438	if(cookieData.popupId == id && cookieData.openCounter >= this.numberLimit) {
439		return false;
440	}
441	else {
442		return true
443	}
444
445};
446
447
448SGPopup.prototype.setFixedPosition = function (sgPositionLeft, sgPositionTop, sgPositionBottom, sgPositionRight, sgFixedPositionTop, sgFixedPositionLeft) {
449
450	this.positionLeft = sgPositionLeft;
451	this.positionTop = sgPositionTop;
452	this.positionBottom = sgPositionBottom;
453	this.positionRight = sgPositionRight;
454	this.initialPositionTop = sgFixedPositionTop;
455	this.initialPositionLeft = sgFixedPositionLeft;
456};
457
458SGPopup.prototype.percentToPx = function (percentDimention, screenDimension) {
459
460	var dimension = parseInt(percentDimention) * screenDimension / 100;
461	return dimension;
462};
463
464SGPopup.prototype.getPositionPercent = function (needPercent, screenDimension, dimension) {
465
466	var sgPosition = (((this.percentToPx(needPercent, screenDimension) - dimension / 2) / screenDimension) * 100) + "%";
467	return sgPosition;
468};
469
470SGPopup.prototype.showPopup = function (id, isOnLoad) {
471
472	var that = this;
473
474	/*When id does not exist*/
475	if (!id) {
476		return;
477	}
478
479	if (typeof SG_POPUP_DATA[id] == "undefined") {
480		return;
481	}
482	this.popupData = SG_POPUP_DATA[id];
483	this.popupType = this.popupData['type'];
484	this.isOnLoad = isOnLoad;
485	this.openOnce = this.varToBool(this.popupData['repeatPopup']);
486	this.numberLimit = this.popupData['popup-appear-number-limit'];
487
488	if (typeof that.removeCookie !== 'undefined') {
489		that.removeCookie(this.openOnce);
490	}
491
492	if (!this.canOpenPopup(this.popupData['id'], this.openOnce, isOnLoad)) {
493		return;
494	}
495
496	popupColorboxUrl = SG_APP_POPUP_URL + '/style/sgcolorbox/sgthemes.css';
497	head = document.getElementsByTagName('head')[0];
498	link = document.createElement('link');
499	link.type = "text/css";
500	link.id = "sg_colorbox_theme-css";
501	link.rel = "stylesheet";
502	link.href = popupColorboxUrl;
503	document.getElementsByTagName('head')[0].appendChild(link);
504	var img = document.createElement('img');
505	sgAddEvent(img, "error", function () {
506		that.sgShowColorboxWithOptions();
507	});
508	setTimeout(function () {
509		img.src = popupColorboxUrl;
510	}, 0);
511};
512
513SGPopup.setToPopupsCookiesList = function (cookieName) {
514
515	var currentCookies = SGPopup.getCookie('sgPopupCookieList');
516
517	if (!currentCookies) {
518		currentCookies = [];
519	}
520	else {
521		currentCookies = JSON.parse(currentCookies);
522	}
523
524	if (jQuery.inArray(cookieName, currentCookies) == -1) {
525		cookieName = currentCookies.push(cookieName);
526	}
527
528	SGPopup.deleteCookie('sgPopupCookieList');
529	var currentCookies = JSON.stringify(currentCookies);
530	SGPopup.setCookie('sgPopupCookieList', currentCookies, 365, true);
531};
532
533SGPopup.prototype.popupThemeDefaultMeasure = function () {
534
535	var themeName = this.popupData['theme'];
536	var defaults = SGPopup.sgColorBoxDeafults;
537	/*return theme id*/
538	var themeId = themeName.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2');
539
540	return defaults[themeId];
541};
542
543SGPopup.prototype.changePopupSettings = function () {
544
545	var popupData = this.popupData;
546	var popupDimensionMode = popupData['popup-dimension-mode'];
547	var maxWidth = popupData['maxWidth'];
548	var screenWidth = jQuery(window).width();
549	var popupResponsiveDimensionMeasure = popupData['popup-responsive-dimension-measure'];
550	var isMaxWidthInPercent = maxWidth.indexOf("%") != -1 ? true: false;
551
552	if(popupDimensionMode == 'responsiveMode') {
553
554		if(popupResponsiveDimensionMeasure == 'auto') {
555			this.popupMaxWidth = '100%';
556
557			/*When max with in px*/
558			if(maxWidth && !isMaxWidthInPercent && parseInt(maxWidth) < screenWidth) {
559				this.popupMaxWidth = parseInt(maxWidth);
560			}
561			else if(isMaxWidthInPercent && parseInt(maxWidth) < 100) { /*For example when max width is 800% */
562				this.popupMaxWidth = maxWidth;
563			}
564
565		}
566	}
567};
568
569SGPopup.prototype.resizePopup = function (settings) {
570
571	var that = this;
572
573
574	function resizeColorBox () {
575		var window = jQuery(this);
576		var windowWidth = window.width();
577		var windowHeight = window.height();
578
579		var maxWidth = that.popupData['maxWidth'];
580		var maxHeight = that.popupData['maxHeight'];
581
582		if(!maxWidth) {
583			maxWidth = '100%';
584		}
585
586		if(!maxHeight) {
587			maxHeight = '100%';
588		}
589
590		if (that.resizeTimer) clearTimeout(that.resizeTimer);
591		that.resizeTimer = setTimeout(function() {
592			if (jQuery('#sgcboxOverlay').is(':visible')) {
593				var shouldResize = true;
594				if (maxWidth.indexOf("%") != -1) {
595					maxWidth = that.percentToPx(maxWidth, windowWidth);
596				}
597				else {
598					maxWidth = parseInt(maxWidth);
599				}
600
601				if (maxHeight.indexOf("%") != -1) {
602					maxHeight = that.percentToPx(maxHeight, windowHeight);
603				}
604				else {
605					maxHeight = parseInt(maxHeight);
606				}
607
608				if(maxWidth > windowWidth) {
609					maxWidth = windowWidth;
610				}
611
612				if(maxHeight > windowHeight) {
613					maxHeight = windowHeight;
614				}
615
616				settings.maxWidth = maxWidth;
617				settings.maxHeight = maxHeight;
618				var hasFocusedInput = false;
619				jQuery('#sgcboxLoadedContent input,#sgcboxLoadedContent textarea').each(function() {
620
621					if(jQuery(this).is(':focus')) {
622						hasFocusedInput = true;
623					}
624				});
625				/*For mobile when has some focused input popup does not resize*/
626				if( /Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && hasFocusedInput ) {
627					shouldResize = false;
628				}
629				if(shouldResize) {
630					jQuery.sgcolorbox(settings);
631					jQuery('#sgcboxLoadingGraphic').css({'display': 'none'});
632				}
633			}
634		}, 500);
635	}
636
637	jQuery(window).resize(resizeColorBox);
638	window.addEventListener("orientationchange", resizeColorBox, false);
639};
640
641SGPopup.prototype.resizeAfterContentResizing = function () {
642
643	var visibilityClasses = [".js-validate-required", ".js-sgpb-visibility"];
644	var maxHeight = this.popupData['maxHeight'];
645	var diffContentHight = jQuery("#sgcboxWrapper").height() - jQuery("#sgcboxLoadedContent").height();
646	for(var index in visibilityClasses) {
647		jQuery(visibilityClasses[index]).visibilityChanged({
648			callback: function(element, visible) {
649				if(maxHeight !== '' && parseInt(maxHeight) < (jQuery("#sgcboxLoadedContent").prop('scrollHeight') + diffContentHight)) {
650					return false;
651				}
652				jQuery.sgcolorbox.resize();
653			},
654			runOnLoad: false,
655			frequency: 2000
656		});
657	}
658
659	new ResizeSensor(jQuery('#sgcboxLoadedContent'), function(){
660		if(maxHeight !== '' && parseInt(maxHeight) < (jQuery("#sgcboxLoadedContent").prop('scrollHeight') + diffContentHight)) {
661			return false;
662		}
663		jQuery.sgcolorbox.resize();
664	});
665
666};
667
668SGPopup.prototype.sgColorboxContentMode = function() {
669
670	var that = this;
671
672	this.sgColorboxContentTypeReset();
673	var popupType = this.popupData['type'];
674	var popupHtml = (this.popupData['html'] == '') ? '&nbsp;' : this.popupData['html'];
675	var popupImage = this.popupData['image'];
676	var popupIframeUrl = this.popupData['iframe'];
677	var popupVideo = this.popupData['video'];
678	var popupId = this.popupData['id'];
679
680	popupImage = (popupImage) ? popupImage : false;
681	popupVideo = (popupVideo) ? popupVideo : false;
682	popupIframeUrl = (popupIframeUrl) ? popupIframeUrl : false;
683
684	if(popupType == 'image') {
685		this.sgColorboxPhoto = true;
686		this.sgColorboxHref = popupImage;
687	}
688
689	if(popupIframeUrl) {
690		this.sgColorboxIframe = true;
691		this.sgColorboxHref = popupIframeUrl;
692	}
693
694	if(popupVideo) {
695		this.sgColorboxIframe = true;
696		this.sgColorboxHref = popupVideo;
697	}
698
699	/*this condition jQuery('#sg-popup-content-wrapper-'+popupId).length != 0 for backward compatibility*/
700	if(popupHtml && jQuery('#sg-popup-content-wrapper-'+popupId).length != 0) {
701		this.sgColorboxInline = true;
702		this.sgColorboxHref = '#sg-popup-content-wrapper-'+popupId;
703	}
704	else {
705		this.sgColorboxHtml = popupHtml;
706	}
707};
708
709SGPopup.prototype.addToCounter = function (popupId) {
710
711	var params = {};
712	params.popupId = popupId;
713
714	var data = {
715		action: 'send_to_open_counter',
716		ajaxNonce: SGPBParams.ajaxNonce,
717		params: params
718	};
719
720	jQuery.post(SGPBParams.ajaxUrl, data, function(response,d) {
721
722	});
723};
724SGPopup.soundValue = 1;
725
726SGPopup.prototype.contentClickRedirect = function () {
727
728	var popupData = this.popupData;
729	var contentClickBehavior = popupData['content-click-behavior'];
730	var clickRedirectToUrl = popupData['click-redirect-to-url'];
731	var redirectToNewTab = popupData['redirect-to-new-tab'];
732
733	/* If has url for redirect */
734	if ((contentClickBehavior !== 'close' || clickRedirectToUrl !== '') && typeof contentClickBehavior !== 'undefined') {
735		jQuery('#sgcolorbox').css({
736			"cursor": 'pointer'
737		});
738	}
739
740	jQuery(".sg-current-popup-" + popupData['id']).bind('click', function () {
741		if (contentClickBehavior == 'close' || clickRedirectToUrl == '' || typeof contentClickBehavior == 'undefined') {
742			jQuery.sgcolorbox.close();
743		}
744		else {
745			if (!redirectToNewTab) {
746				window.location = clickRedirectToUrl;
747			}
748			else {
749				window.open(clickRedirectToUrl);
750			}
751		}
752
753	});
754};
755
756SGPopup.prototype.closeButtonDelay = function (buttonDelayValue) {
757	setTimeout(function(){
758		jQuery('#sgcboxClose').attr('style', 'display: block !important;');
759	},
760	buttonDelayValue * 1000 /* received values covert to seconds */
761	);
762}
763
764SGPopup.prototype.htmlIframeFilterForOpen = function (popupEventName) {
765
766	var popupId = this.popupData['id'];
767	var popupContentWrapper = jQuery('#sg-popup-content-wrapper-'+popupId);
768
769	if(!popupContentWrapper.length) {
770		return;
771	}
772
773	if(!popupContentWrapper.find('iframe').length) {
774		return;
775	}
776
777	if(popupEventName == 'open') {
778		var iframeUrl = this.popupData['htmlIframeUrl'];
779		popupContentWrapper.find('iframe').attr('src', iframeUrl);
780		return;
781	}
782
783	popupContentWrapper.find('iframe').attr('src', ' ');
784	return;
785};
786
787SGPopup.prototype.colorboxEventsListener = function () {
788
789	var that = this;
790	var disablePageScrolling = this.varToBool(this.popupData['disable-page-scrolling']);
791	var popupOpenSound = this.varToBool(this.popupData['popupOpenSound']);
792	var popupContentBgImage = this.varToBool(this.popupData['popupContentBgImage']);
793	var popupOpenSoundFile = this.popupData['popupOpenSoundFile'];
794	var popupContentBgImageUrl = this.popupData['popupContentBgImageUrl'];
795	var popupContentBackgroundSize = this.popupData['popupContentBackgroundSize'];
796	var popupContentBackgroundRepeat = this.popupData['popupContentBackgroundRepeat'];
797	var repetitivePopup = this.popupData['repetitivePopup'];
798	var repetitivePopupPeriod = this.popupData['repetitivePopupPeriod'];
799	var buttonDelayValue = this.popupData['buttonDelayValue'];
800	/*this.popupCloseButton*/
801	repetitivePopupPeriod = parseInt(repetitivePopupPeriod)*1000;
802	var repetitiveTimeout = null;
803
804	if(popupOpenSound && popupOpenSoundFile && typeof that.audio == 'undefined') {
805		that.audio = new Audio(popupOpenSoundFile);
806	}
807	jQuery('#sgcolorbox').on("sgColorboxOnOpen", function () {
808		if(disablePageScrolling) {
809			jQuery('body').addClass('sgpb-disable-page-scrolling');
810		}
811	});
812
813	jQuery('#sgcolorbox').unbind("sgColorboxOnCompleate").bind("sgColorboxOnCompleate", function (e, args) {
814
815		var popupId = args.popupId;
816
817		that.addToCounter(popupId);
818
819		if(that.popupData['type'] == 'html') {
820			that.htmlIframeFilterForOpen('open');
821		}
822
823		/* if close button is set to be shown and has delay value */
824		if (that.popupCloseButton && buttonDelayValue) {
825			that.closeButtonDelay(buttonDelayValue);
826		}
827
828		if(that.popupContentClick) {
829			that.contentClickRedirect();
830		}
831
832		clearInterval(repetitiveTimeout);
833		if(that.varToBool(that.popupData['popupOpenSound']) && popupOpenSoundFile) {
834			/*
835			 * SGPopup.soundValue -> 1 sound should play
836			 * SGPopup.soundValue -> 2 sound should pause
837			 * */
838			if (SGPopup.soundValue == 1) {
839
840				that.audio.play();
841				SGPopup.soundValue = 2;
842
843			} else if (SGPopup.soundValue == 2) {
844				that.audio.pause();
845				SGPopup.soundValue = 1;
846			}
847		}
848		if(popupContentBgImage) {
849			jQuery('#sgcboxLoadedContent').css({
850				'background-image': 'url('+popupContentBgImageUrl+')',
851				'background-size': popupContentBackgroundSize,
852				'background-repeat': popupContentBackgroundRepeat
853			});
854		}
855	});
856
857	jQuery('#sgcolorbox').one("sgPopupCleanup", function () {
858		if(repetitivePopup) {
859			repetitiveTimeout = setTimeout(function() {
860				var sgPoupFrontendObj = new SGPopup();
861				sgPoupFrontendObj.popupOpenById(that.popupData['id']);
862			}, repetitivePopupPeriod);
863		}
864		if(that.varToBool(that.popupData['popupOpenSound']) && popupOpenSoundFile) {
865			if(typeof that.audio != 'undefined') {
866				that.audio.pause();
867				delete that.audio;
868			}
869
870			SGPopup.soundValue = 1;
871		}
872	});
873
874	jQuery('#sgcolorbox').on("sgPopupClose", function () {
875		if(disablePageScrolling) {
876			jQuery('body').removeClass('sgpb-disable-page-scrolling');
877		}
878		if(that.popupData['type'] == 'html') {
879			that.htmlIframeFilterForOpen('close');
880		}
881	});
882
883};
884
885SGPopup.prototype.sgShowColorboxWithOptions = function () {
886
887	var that = this;
888	setTimeout(function () {
889
890		that.colorboxEventsListener();
891		var sgPopupFixed = that.varToBool(that.popupData['popupFixed']);
892		var popupId = that.popupData['id'];
893		that.popupOverlayClose = that.varToBool(that.popupData['overlayClose']);
894		that.popupContentClick = that.varToBool(that.popupData['contentClick']);
895		var popupReposition = that.varToBool(that.popupData['reposition']);
896		var popupScrolling = that.varToBool(that.popupData['scrolling']);
897		var popupScaling = that.varToBool(that.popupData['scaling']);
898		that.popupEscKey = that.varToBool(that.popupData['escKey']);
899		that.popupCloseButton = that.varToBool(that.popupData['closeButton']);
900		var countryStatus = that.varToBool(that.popupData['countryStatus']);
901		var popupForMobile = that.varToBool(that.popupData['forMobile']);
902		var onlyMobile = that.varToBool(that.popupData['openMobile']);
903		var popupCantClose = that.varToBool(that.popupData['disablePopup']);
904		var disablePopupOverlay = that.varToBool(that.popupData['disablePopupOverlay']);
905		var popupAutoClosePopup = that.varToBool(that.popupData['autoClosePopup']);
906		var saveCookiePageLevel = that.varToBool(that.popupData['save-cookie-page-level']);
907		var popupClosingTimer = that.popupData['popupClosingTimer'];
908
909		if (popupScaling) {
910			that.sgPopupScaling();
911		}
912		if (popupCantClose) {
913			that.cantPopupClose();
914		}
915		that.popupMaxWidth = (!that.popupData['maxWidth']) ? '100%' : that.popupData['maxWidth'];
916		var popupPosition = sgPopupFixed ? that.popupData['fixedPostion'] : '';
917		var popupVideo = that.popupData['video'];
918		var popupOverlayColor = that.popupData['sgOverlayColor'];
919		var contentBackgroundColor = that.popupData['sg-content-background-color'];
920		var popupDimensionMode = that.popupData['popup-dimension-mode'];
921		var popupResponsiveDimensionMeasure = that.popupData['popup-responsive-dimension-measure'];
922		var popupWidth = that.popupData['width'];
923		var popupHeight = that.popupData['height'];
924		var popupOpacity = that.popupData['opacity'];
925		var popupMaxHeight = (!that.popupData['maxHeight']) ? '100%' : that.popupData['maxHeight'];
926		var popupInitialWidth = that.popupData['initialWidth'];
927		var popupInitialHeight = that.popupData['initialHeight'];
928		var popupEffectDuration = that.popupData['duration'];
929		var popupEffect = that.popupData['effect'];
930		var pushToBottom = that.popupData['pushToBottom'];
931		var onceExpiresTime = parseInt(that.popupData['onceExpiresTime']);
932		var sgType = that.popupData['type'];
933		var overlayCustomClass = that.popupData['sgOverlayCustomClasss'];
934		var contentCustomClass = that.popupData['sgContentCustomClasss'];
935		var popupTheme = that.popupData['theme'];
936		var themeStringLength = popupTheme.length;
937		var customClassName = popupTheme.substring(0, themeStringLength - 4);
938		var closeButtonText = that.popupData['theme-close-text'];
939
940		that.sgColorboxContentMode();
941
942		if(popupDimensionMode == 'responsiveMode') {
943
944			popupWidth = '';
945			if(popupResponsiveDimensionMeasure != 'auto') {
946				popupWidth = parseInt(popupResponsiveDimensionMeasure)+'%';
947			}
948
949			if(that.popupData['type'] != 'iframe' && that.popupData['type'] != 'video') {
950				popupHeight = '';
951			}
952		}
953
954		var sgScreenWidth = jQuery(window).width();
955		var sgScreenHeight = jQuery(window).height();
956
957		var sgIsWidthInPercent = popupWidth.indexOf("%");
958		var sgIsHeightInPercent = popupHeight.indexOf("%");
959		var sgPopupHeightPx = popupHeight;
960		var sgPopupWidthPx = popupWidth;
961		if (sgIsWidthInPercent != -1) {
962			sgPopupWidthPx = that.percentToPx(popupWidth, sgScreenWidth);
963		}
964		if (sgIsHeightInPercent != -1) {
965			sgPopupHeightPx = that.percentToPx(popupHeight, sgScreenHeight);
966		}
967		/*for when width or height in px*/
968		sgPopupWidthPx = parseInt(sgPopupWidthPx);
969		sgPopupHeightPx = parseInt(sgPopupHeightPx);
970
971		var staticPositionWidth = sgPopupWidthPx;
972		if(staticPositionWidth > sgScreenWidth) {
973			staticPositionWidth = sgScreenWidth;
974		}
975
976		var popupPositionTop = that.getPositionPercent("50%", sgScreenHeight, sgPopupHeightPx);
977		var popupPositionLeft = that.getPositionPercent("50%", sgScreenWidth, staticPositionWidth);
978		var posTopForSettings = popupPositionTop;
979
980		if (popupPosition == 1) {
981			that.setFixedPosition('0%', '3%', false, false, 0, 0);
982		} else if (popupPosition == 2) {
983			that.setFixedPosition(popupPositionLeft, '3%', false, false, 0, 50);
984		} else if (popupPosition == 3) {
985			that.setFixedPosition(false, '3%', false, '0%', 0, 90);
986		} else if (popupPosition == 4) {
987
988			if(isNaN(popupPositionTop)) {
989				posTopForSettings = false;
990			}
991			that.setFixedPosition('0%', posTopForSettings, false, false, posTopForSettings, 0);
992		} else if (popupPosition == 5) {
993			sgPopupFixed = true;
994			that.setFixedPosition(false, false, false, false, 50, 50);
995		} else if (popupPosition == 6) {
996			if(isNaN(popupPositionTop)) {
997				posTopForSettings = false;
998			}
999			that.setFixedPosition('0%', posTopForSettings, false, '0%', 50, 90);
1000		} else if (popupPosition == 7) {
1001			that.setFixedPosition('0%', false, '0%', false, 90, 0);
1002		} else if (popupPosition == 8) {
1003			that.setFixedPosition(popupPositionLeft, false, '0%', false, 90, 50);
1004		} else if (popupPosition == 9) {
1005			that.setFixedPosition(false, false, '0%', '0%', 90, 90);
1006		}
1007		if (!sgPopupFixed) {
1008			that.setFixedPosition(false, false, false, false, 50, 50);
1009		}
1010
1011		var userDevice = false;
1012		if (popupForMobile) {
1013			userDevice = that.forMobile();
1014		}
1015
1016		if (popupAutoClosePopup) {
1017			setTimeout(that.autoClosePopup, popupClosingTimer * 1000);
1018		}
1019
1020		if (disablePopupOverlay) {
1021			that.sgTrapFocus = false;
1022			that.disablePopupOverlay();
1023		}
1024
1025		if (onlyMobile) {
1026			var openOnlyMobile = false;
1027			openOnlyMobile = that.forMobile();
1028			if (openOnlyMobile == false) {
1029				return;
1030			}
1031		}
1032
1033		if (userDevice) {
1034			return;
1035		}
1036		that.changePopupSettings();
1037		SG_POPUP_SETTINGS = {
1038			popupId: popupId,
1039			html: that.sgColorboxHtml,
1040			photo: that.sgColorboxPhoto,
1041			iframe: that.sgColorboxIframe,
1042			href: that.sgColorboxHref,
1043			inline: that.sgColorboxInline,
1044			width: popupWidth,
1045			height: popupHeight,
1046			className: customClassName,
1047			close: closeButtonText,
1048			overlayCutsomClassName: overlayCustomClass,
1049			contentCustomClassName: contentCustomClass,
1050			onOpen: function () {
1051				if(that.sgColorboxInline) {
1052					var contentImage = jQuery(that.sgColorboxHref).find('img').first();
1053					if(contentImage.length) {
1054						var height = contentImage.attr('height');
1055						height = parseInt(height);
1056						contentImage.attr('style', 'height: '+height+' !important');
1057					}
1058				}
1059				jQuery('#sgcolorbox').removeAttr('style');
1060				jQuery('#sgcolorbox').removeAttr('left');
1061				jQuery('#sgcolorbox').css('top', '' + that.initialPositionTop + '%');
1062				jQuery('#sgcolorbox').css('left', '' + that.initialPositionLeft + '%');
1063				jQuery('#sgcolorbox').css('animation-duration', popupEffectDuration + "s");
1064				jQuery('#sgcolorbox').css('-webkit-animation-duration', popupEffectDuration + "s");
1065				jQuery("#sgcolorbox").addClass('sg-animated ' + popupEffect + '');
1066				jQuery("#sgcboxOverlay").addClass("sgcboxOverlayBg");
1067				jQuery("#sgcboxOverlay").removeAttr('style');
1068
1069				if (popupOverlayColor) {
1070					jQuery("#sgcboxOverlay").css({'background': 'none', 'background-color': popupOverlayColor});
1071				}
1072
1073				jQuery('#sgcolorbox').trigger("sgColorboxOnOpen", []);
1074
1075			},
1076			onLoad: function () {
1077			},
1078			onComplete: function () {
1079				if (contentBackgroundColor) {
1080					jQuery("#sgcboxLoadedContent").css({'background-color': contentBackgroundColor});
1081				}
1082				jQuery("#sgcboxLoadedContent").addClass("sg-current-popup-" + that.popupData['id']);
1083				var completeArgs = {
1084					pushToBottom: pushToBottom,
1085					popupId: popupId
1086				};
1087
1088				jQuery('#sgcolorbox').trigger("sgColorboxOnCompleate", completeArgs);
1089
1090				var sgpopupInit = new SgPopupInit(that.popupData);
1091				sgpopupInit.overallInit();
1092				/* For specific popup Like Countdown AgeRestcion popups */
1093				sgpopupInit.initByPopupType();
1094				that.sgCustomizeThemes(that.popupData['id']);
1095				if(popupDimensionMode == 'responsiveMode') {
1096					/* it's temporary deactivated  for colorbox resize good work that.resizeAfterContentResizing(); */
1097					that.resizePopup(SG_POPUP_SETTINGS);
1098					jQuery('#sgcboxLoadingGraphic').remove()
1099				}
1100			},
1101			onCleanup: function () {
1102				jQuery('#sgcolorbox').trigger("sgPopupCleanup", []);
1103			},
1104			onClosed: function () {
1105				jQuery("#sgcboxLoadedContent").removeClass("sg-current-popup-" + that.popupData['id']);
1106				jQuery('#sgcolorbox').trigger("sgPopupClose", []);
1107			},
1108			trapFocus: that.sgTrapFocus,
1109			opacity: popupOpacity,
1110			escKey: that.popupEscKey,
1111			closeButton: that.popupCloseButton,
1112			fixed: sgPopupFixed,
1113			top: that.positionTop,
1114			bottom: that.positionBottom,
1115			left: that.positionLeft,
1116			right: that.positionRight,
1117			scrolling: popupScrolling,
1118			reposition: popupReposition,
1119			overlayClose: that.popupOverlayClose,
1120			maxWidth: that.popupMaxWidth,
1121			maxHeight: popupMaxHeight,
1122			initialWidth: popupInitialWidth,
1123			initialHeight: popupInitialHeight
1124		};
1125
1126		if(popupDimensionMode == 'responsiveMode') {
1127			/*colorbox open speed*/
1128			SG_POPUP_SETTINGS.speed = 10;
1129		}
1130		jQuery.sgcolorbox(SG_POPUP_SETTINGS);
1131
1132
1133		if (countryStatus == true && typeof SgUserData != "undefined") {
1134			jQuery.cookie("SG_POPUP_USER_COUNTRY_NAME", SgUserData.countryIsoName, {expires: 365});
1135		}
1136		/* Cookie can't be set here as it's set in Age Restriction popup when the user clicks "yes" */
1137		if (that.popupData['id'] && that.isOnLoad == true && that.openOnce != '' && that.popupData['type'] != "ageRestriction") {
1138			var sgCookieData = '';
1139
1140			var currentCookie = SGPopup.getCookie('sgPopupDetails' + that.popupData['id']);
1141
1142			if (!currentCookie) {
1143				var openCounter = 1;
1144			}
1145			else {
1146				var currentCookie = JSON.parse(currentCookie);
1147				var openCounter = currentCookie.openCounter += 1;
1148			}
1149			sgCookieData = {
1150				'popupId': that.popupData['id'],
1151				'openCounter': openCounter,
1152				'openLimit': that.numberLimit
1153			};
1154
1155			/*!saveCookiePageLevel it's mean for all site level*/
1156			SGPopup.setCookie("sgPopupDetails"+that.popupData['id'],JSON.stringify(sgCookieData), onceExpiresTime, !saveCookiePageLevel);
1157		}
1158
1159
1160		jQuery('#sgcolorbox').bind('sgPopupClose', function (e) {
1161			/* reset event execute count for popup open */
1162			that.sgEventExecuteCount = 0;
1163			that.eventExecuteCountByClass = 0;
1164			jQuery('#sgcolorbox').removeClass(customClassName);
1165			/* Remove custom class for another popup */
1166			jQuery('#sgcboxOverlay').removeClass(customClassName);
1167			jQuery('#sgcolorbox').removeClass(popupEffect);
1168			/* Remove animated effect for another popup */
1169		});
1170
1171	}, this.popupData['delay'] * 1000);
1172};
1173
1174jQuery(document).ready(function ($) {
1175
1176	var popupObj = new SGPopup();
1177	popupObj.init();
1178});

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.