PageSourceSearch

https://www.beautycommunity.co.th/wp-content/plugins/popup-builder…/javascript/sg_popup_frontend.js?ver=2.68

js beautycommunity.co.th collected 2026-10-05 22:10:21 UTC 39,644 bytes, 1,352 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(typeof contentBackgroundColor != 'undefined' && 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}
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.getPreviewPopupId = function(popupId)
471{
472	var currentUrl = window.location.href;
473
474	var classSplitArray = currentUrl.split('sg_popup_preview_id=');
475	var classIdString = classSplitArray['1'];
476
477	if (typeof classIdString == 'undefined') {
478		return false;
479	}
480	/*Get first all number from string*/
481	var urlId = classIdString.match(/^\d+/);
482
483	return urlId;
484};
485
486SGPopup.prototype.currentPopupId = false;
487
488SGPopup.prototype.restrictIfThereIsPreviewPopup = function(popupId)
489{
490	var previewPopupId = this.getPreviewPopupId();
491	if (previewPopupId) {
492		if (popupId != previewPopupId) {
493			return false;
494		}
495
496		if (this.currentPopupId) {
497			return false;
498		}
499	}
500
501	return true;
502};
503
504SGPopup.prototype.showPopup = function (id, isOnLoad) {
505
506	var that = this;
507
508	/*When id does not exist*/
509	if (!id) {
510		return;
511	}
512
513	if (typeof SG_POPUP_DATA[id] == "undefined") {
514		return;
515	}
516
517	if (!this.restrictIfThereIsPreviewPopup(id)) {
518		return false;
519	}
520
521	this.popupData = SG_POPUP_DATA[id];
522	this.popupType = this.popupData['type'];
523	this.isOnLoad = isOnLoad;
524	this.openOnce = this.varToBool(this.popupData['repeatPopup']);
525	this.numberLimit = this.popupData['popup-appear-number-limit'];
526
527	if (typeof that.removeCookie !== 'undefined') {
528		that.removeCookie(this.openOnce);
529	}
530
531	if (!this.canOpenPopup(this.popupData['id'], this.openOnce, isOnLoad)) {
532		return;
533	}
534
535	popupColorboxUrl = SG_APP_POPUP_URL + '/style/sgcolorbox/sgthemes.css';
536	head = document.getElementsByTagName('head')[0];
537	link = document.createElement('link');
538	link.type = "text/css";
539	link.id = "sg_colorbox_theme-css";
540	link.rel = "stylesheet";
541	link.href = popupColorboxUrl;
542	document.getElementsByTagName('head')[0].appendChild(link);
543	var img = document.createElement('img');
544	sgAddEvent(img, "error", function () {
545		that.sgShowColorboxWithOptions();
546	});
547	setTimeout(function () {
548		img.src = popupColorboxUrl;
549	}, 0);
550};
551
552SGPopup.setToPopupsCookiesList = function (cookieName) {
553
554	var currentCookies = SGPopup.getCookie('sgPopupCookieList');
555
556	if (!currentCookies) {
557		currentCookies = [];
558	}
559	else {
560		currentCookies = JSON.parse(currentCookies);
561	}
562
563	if (jQuery.inArray(cookieName, currentCookies) == -1) {
564		cookieName = currentCookies.push(cookieName);
565	}
566
567	SGPopup.deleteCookie('sgPopupCookieList');
568	var currentCookies = JSON.stringify(currentCookies);
569	SGPopup.setCookie('sgPopupCookieList', currentCookies, 365, true);
570};
571
572SGPopup.prototype.popupThemeDefaultMeasure = function () {
573
574	var themeName = this.popupData['theme'];
575	var defaults = SGPopup.sgColorBoxDeafults;
576	/*return theme id*/
577	var themeId = themeName.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2');
578
579	return defaults[themeId];
580};
581
582SGPopup.prototype.changePopupSettings = function () {
583
584	var popupData = this.popupData;
585	var popupDimensionMode = popupData['popup-dimension-mode'];
586	var maxWidth = popupData['maxWidth'];
587	var screenWidth = jQuery(window).width();
588	var popupResponsiveDimensionMeasure = popupData['popup-responsive-dimension-measure'];
589	var isMaxWidthInPercent = maxWidth.indexOf("%") != -1 ? true: false;
590
591	if(popupDimensionMode == 'responsiveMode') {
592
593		if(popupResponsiveDimensionMeasure == 'auto') {
594			this.popupMaxWidth = '100%';
595
596			/*When max with in px*/
597			if(maxWidth && !isMaxWidthInPercent && parseInt(maxWidth) < screenWidth) {
598				this.popupMaxWidth = parseInt(maxWidth);
599			}
600			else if(isMaxWidthInPercent && parseInt(maxWidth) < 100) { /*For example when max width is 800% */
601				this.popupMaxWidth = maxWidth;
602			}
603
604		}
605	}
606};
607
608SGPopup.prototype.resizePopup = function (settings) {
609
610	var that = this;
611	/*Initial window dimensions*/
612	window.sgpbInitialWindowWith = window.innerWidth;
613	window.sgpbInitialWindowHeight = window.innerHeight;
614
615	function resizeColorBox () {
616		var currentWindow = jQuery(this);
617		var windowWidth = currentWindow.width();
618		var windowHeight = currentWindow.height();
619
620		var maxWidth = that.popupData['maxWidth'];
621		var maxHeight = that.popupData['maxHeight'];
622
623		if(!maxWidth) {
624			maxWidth = '100%';
625		}
626
627		if(!maxHeight) {
628			maxHeight = '100%';
629		}
630
631		if (that.resizeTimer) clearTimeout(that.resizeTimer);
632		that.resizeTimer = setTimeout(function() {
633			if (jQuery('#sgcboxOverlay').is(':visible')) {
634				if (window.sgpbFullScreen === true) {
635					window.sgpbShouldResize = false;
636					window.sgpbFullScreen = false;
637				}
638				else {
639					window.sgpbShouldResize = true;
640				}
641
642				if ((window.innerHeight == screen.height) || (!window.screenTop && !window.screenY)) {
643					window.sgpbShouldResize = false;
644				}
645
646				if (maxWidth.indexOf("%") != -1) {
647					maxWidth = that.percentToPx(maxWidth, windowWidth);
648				}
649				else {
650					maxWidth = parseInt(maxWidth);
651				}
652
653				if (maxHeight.indexOf("%") != -1) {
654					maxHeight = that.percentToPx(maxHeight, windowHeight);
655				}
656				else {
657					maxHeight = parseInt(maxHeight);
658				}
659
660				if(maxWidth > windowWidth) {
661					maxWidth = windowWidth;
662				}
663
664				if(maxHeight > windowHeight) {
665					maxHeight = windowHeight;
666				}
667
668				settings.maxWidth = maxWidth;
669				settings.maxHeight = maxHeight;
670				var hasFocusedInput = false;
671				jQuery('#sgcboxLoadedContent input,#sgcboxLoadedContent textarea').each(function() {
672
673					if(jQuery(this).is(':focus')) {
674						hasFocusedInput = true;
675					}
676				});
677				/*For mobile when has some focused input popup does not resize*/
678				if( /Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && hasFocusedInput ) {
679					window.sgpbShouldResize = false;
680				}
681				/*For just call resize*/
682				if (currentWindow.width() == window.sgpbInitialWindowWith && currentWindow.height() == window.sgpbInitialWindowHeight) {
683					window.sgpbShouldResize = false;
684				}
685
686				if(window.sgpbShouldResize) {
687					jQuery.sgcolorbox(settings);
688					jQuery('#sgcboxLoadingGraphic').css({'display': 'none'});
689				}
690			}
691		}, 500);
692	}
693
694	jQuery(window).resize(resizeColorBox);
695	window.addEventListener("orientationchange", resizeColorBox, false);
696
697	document.addEventListener("fullscreenchange", function() {
698		window.sgpbFullScreen = true;
699	}, false);
700
701	document.addEventListener("msfullscreenchange", function() {
702		window.sgpbFullScreen = true;
703	}, false);
704
705	document.addEventListener("mozfullscreenchange", function() {
706		window.sgpbFullScreen = true;
707	}, false);
708
709	document.addEventListener("webkitfullscreenchange", function() {
710		window.sgpbFullScreen = true;
711	}, false);
712};
713
714SGPopup.prototype.resizeAfterContentResizing = function () {
715
716	var visibilityClasses = [".js-validate-required", ".js-sgpb-visibility"];
717	var maxHeight = this.popupData['maxHeight'];
718	var diffContentHight = jQuery("#sgcboxWrapper").height() - jQuery("#sgcboxLoadedContent").height();
719	for(var index in visibilityClasses) {
720		jQuery(visibilityClasses[index]).visibilityChanged({
721			callback: function(element, visible) {
722				if(maxHeight !== '' && parseInt(maxHeight) < (jQuery("#sgcboxLoadedContent").prop('scrollHeight') + diffContentHight)) {
723					return false;
724				}
725				jQuery.sgcolorbox.resize();
726			},
727			runOnLoad: false,
728			frequency: 2000
729		});
730	}
731
732	new ResizeSensor(jQuery('#sgcboxLoadedContent'), function(){
733		if(maxHeight !== '' && parseInt(maxHeight) < (jQuery("#sgcboxLoadedContent").prop('scrollHeight') + diffContentHight)) {
734			return false;
735		}
736		jQuery.sgcolorbox.resize();
737	});
738
739};
740
741SGPopup.prototype.sgColorboxContentMode = function() {
742
743	var that = this;
744
745	this.sgColorboxContentTypeReset();
746	var popupType = this.popupData['type'];
747	var popupHtml = (this.popupData['html'] == '') ? '&nbsp;' : this.popupData['html'];
748	var popupImage = this.popupData['image'];
749	var popupIframeUrl = this.popupData['iframe'];
750	var popupVideo = this.popupData['video'];
751	var popupId = this.popupData['id'];
752
753	popupImage = (popupImage) ? popupImage : false;
754	popupVideo = (popupVideo) ? popupVideo : false;
755	popupIframeUrl = (popupIframeUrl) ? popupIframeUrl : false;
756
757	if(popupType == 'image') {
758		this.sgColorboxPhoto = true;
759		this.sgColorboxHref = popupImage;
760	}
761
762	if(popupIframeUrl) {
763		this.sgColorboxIframe = true;
764		this.sgColorboxHref = popupIframeUrl;
765	}
766
767	if(popupVideo) {
768		this.sgColorboxIframe = true;
769		this.sgColorboxHref = popupVideo;
770	}
771
772	/*this condition jQuery('#sg-popup-content-wrapper-'+popupId).length != 0 for backward compatibility*/
773	if(popupHtml && jQuery('#sg-popup-content-wrapper-'+popupId).length != 0) {
774		this.sgColorboxInline = true;
775		this.sgColorboxHref = '#sg-popup-content-wrapper-'+popupId;
776	}
777	else {
778		this.sgColorboxHtml = popupHtml;
779	}
780};
781
782SGPopup.prototype.addToCounter = function (popupId) {
783
784	var params = {};
785	params.popupId = popupId;
786
787	var data = {
788		action: 'send_to_open_counter',
789		ajaxNonce: SGPBParams.ajaxNonce,
790		params: params
791	};
792
793	jQuery.post(SGPBParams.ajaxUrl, data, function(response,d) {
794
795	});
796};
797SGPopup.soundValue = 1;
798
799SGPopup.prototype.contentClickRedirect = function () {
800
801	var popupData = this.popupData;
802	var contentClickBehavior = popupData['content-click-behavior'];
803	var clickRedirectToUrl = popupData['click-redirect-to-url'];
804	var redirectToNewTab = popupData['redirect-to-new-tab'];
805
806	/* If has url for redirect */
807	if ((contentClickBehavior !== 'close' || clickRedirectToUrl !== '') && typeof contentClickBehavior !== 'undefined') {
808		jQuery('#sgcolorbox').css({
809			"cursor": 'pointer'
810		});
811	}
812
813	jQuery(".sg-current-popup-" + popupData['id']).bind('click', function () {
814		if (contentClickBehavior == 'close' || clickRedirectToUrl == '' || typeof contentClickBehavior == 'undefined') {
815			jQuery.sgcolorbox.close();
816		}
817		else {
818			if (!redirectToNewTab) {
819				window.location = clickRedirectToUrl;
820			}
821			else {
822				window.open(clickRedirectToUrl);
823			}
824		}
825
826	});
827};
828
829SGPopup.prototype.closeButtonDelay = function (buttonDelayValue) {
830	setTimeout(function(){
831			jQuery('#sgcboxClose').attr('style', 'display: block !important;');
832		},
833		buttonDelayValue * 1000 /* received values covert to seconds */
834	);
835}
836
837SGPopup.prototype.htmlIframeFilterForOpen = function (popupEventName) {
838
839	var popupId = this.popupData['id'];
840	var popupContentWrapper = jQuery('#sg-popup-content-wrapper-'+popupId);
841
842	if(!popupContentWrapper.length || typeof this.popupData['htmlIframeUrl'] == 'undefined') {
843		return;
844	}
845
846	if(!popupContentWrapper.find('iframe').length) {
847		return;
848	}
849
850	if(popupEventName == 'open') {
851		var iframeUrl = this.popupData['htmlIframeUrl'];
852		popupContentWrapper.find('iframe').attr('src', iframeUrl);
853		return;
854	}
855
856	popupContentWrapper.find('iframe').attr('src', ' ');
857	return;
858};
859
860SGPopup.prototype.getSearchDataFromContent = function(content)
861{
862	var pattern = /\[(\[?)(pbvariable)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/gi;
863	var match;
864	var collectedData = [];
865
866	while (match = pattern.exec(content)) {
867		var currentSearchData = [];
868		currentSearchData['replaceString'] = match[0];
869		var parseAttributes = /\s(\w+?)="(.+?)"/g;
870		var attributes;
871		var attributesKeyValue = [];
872		while (attributes = parseAttributes.exec(match[3])) {
873			attributesKeyValue[attributes[1]] = attributes[2];
874		}
875		currentSearchData['searchData'] = attributesKeyValue;
876		collectedData.push(currentSearchData);
877	}
878
879	return collectedData;
880};
881
882SGPopup.prototype.replaceWithCustomShortcode = function(popupId)
883{
884	var currentHtmlContent = jQuery('#sg-popup-content-wrapper-'+popupId).html();
885	var searchData = this.getSearchDataFromContent(currentHtmlContent);
886	var that = this;
887
888	if (!searchData.length) {
889		return false;
890	}
891
892	for (var index in searchData) {
893		var currentSearchData = searchData[index];
894		var searchAttributes = currentSearchData['searchData'];
895
896		if (typeof searchAttributes['selector'] == 'undefined' || typeof searchAttributes['attribute'] == 'undefined') {
897			that.replaceShortCode(currentSearchData['replaceString'], '');
898			continue;
899		}
900
901		try {
902			if (!jQuery(searchAttributes['selector']).length) {
903				that.replaceShortCode(currentSearchData['replaceString'], '');
904				continue;
905			}
906		}
907		catch (e) {
908			that.replaceShortCode(currentSearchData['replaceString'], '');
909			continue;
910		}
911
912		var replaceName = jQuery(searchAttributes['selector']).attr(searchAttributes['attribute']);
913
914		if (typeof replaceName == 'undefined') {
915			that.replaceShortCode(currentSearchData['replaceString'], '');
916			continue;
917		}
918
919		that.replaceShortCode(currentSearchData['replaceString'], replaceName);
920	}
921};
922
923SGPopup.prototype.replaceShortCode = function(shortCode, replaceText)
924{
925	var popupId = parseInt(this.popupData['id']);
926	var popupContentWrapper = jQuery('#sg-popup-content-wrapper-'+popupId);
927
928	if (!popupContentWrapper.length) {
929		return false;
930	}
931
932	var currentHtmlContent = popupContentWrapper.contents();
933
934	if (!currentHtmlContent.length) {
935		return false;
936	}
937
938	for (var index in currentHtmlContent) {
939		var currentChild = currentHtmlContent[index];
940		var currentChildNodeValue = currentChild.nodeValue;
941		var currentChildNodeType = currentChild.nodeType;
942
943		if (currentChildNodeType != Node.TEXT_NODE) {
944			continue;
945		}
946
947		if (currentChildNodeValue.indexOf(shortCode) != -1) {
948			currentChild.nodeValue =  currentChildNodeValue.replace(shortCode, replaceText);
949		}
950	}
951
952	return true;
953};
954
955SGPopup.prototype.colorboxEventsListener = function ()
956{
957	var that = this;
958	var disablePageScrolling = this.varToBool(this.popupData['disable-page-scrolling']);
959	var popupOpenSound = this.varToBool(this.popupData['popupOpenSound']);
960	var popupContentBgImage = this.varToBool(this.popupData['popupContentBgImage']);
961	var popupOpenSoundFile = this.popupData['popupOpenSoundFile'];
962	var popupContentBgImageUrl = this.popupData['popupContentBgImageUrl'];
963	var popupContentBackgroundSize = this.popupData['popupContentBackgroundSize'];
964	var popupContentBackgroundRepeat = this.popupData['popupContentBackgroundRepeat'];
965	var repetitivePopup = this.popupData['repetitivePopup'];
966	var repetitivePopupPeriod = this.popupData['repetitivePopupPeriod'];
967	var buttonDelayValue = this.popupData['buttonDelayValue'];
968	/*this.popupCloseButton*/
969	repetitivePopupPeriod = parseInt(repetitivePopupPeriod)*1000;
970	var repetitiveTimeout = null;
971
972	if(popupOpenSound && popupOpenSoundFile && typeof that.audio == 'undefined') {
973		that.audio = new Audio(popupOpenSoundFile);
974	}
975	jQuery('#sgcolorbox').one("sgColorboxOnOpen", function (e, args) {
976		var popupId = args.popupId;
977		that.replaceWithCustomShortcode(popupId);
978		if(disablePageScrolling) {
979			jQuery('html').addClass('sgpb-disable-page-scrolling');
980		}
981	});
982
983	jQuery('#sgcolorbox').one("sgColorboxOnCompleate", function (e, args) {
984
985		var popupId = args.popupId;
986		that.addToCounter(popupId);
987
988		if(that.popupData['type'] == 'html') {
989			that.htmlIframeFilterForOpen('open');
990		}
991
992		/* if close button is set to be shown and has delay value */
993		if (that.popupCloseButton && buttonDelayValue) {
994			that.closeButtonDelay(buttonDelayValue);
995		}
996
997		if(that.popupContentClick) {
998			that.contentClickRedirect();
999		}
1000
1001		clearInterval(repetitiveTimeout);
1002		if(that.varToBool(that.popupData['popupOpenSound']) && popupOpenSoundFile) {
1003			/*
1004			 * SGPopup.soundValue -> 1 sound should play
1005			 * SGPopup.soundValue -> 2 sound should pause
1006			 * */
1007			if (SGPopup.soundValue == 1) {
1008
1009				that.audio.play();
1010				SGPopup.soundValue = 2;
1011
1012			} else if (SGPopup.soundValue == 2) {
1013				that.audio.pause();
1014				SGPopup.soundValue = 1;
1015			}
1016		}
1017		if(popupContentBgImage) {
1018			jQuery('#sgcboxLoadedContent').css({
1019				'background-image': 'url('+popupContentBgImageUrl+')',
1020				'background-size': popupContentBackgroundSize,
1021				'background-repeat': popupContentBackgroundRepeat
1022			});
1023		}
1024	});
1025
1026	jQuery('#sgcolorbox').one("sgPopupCleanup", function () {
1027		if(repetitivePopup) {
1028			repetitiveTimeout = setTimeout(function() {
1029				var sgPoupFrontendObj = new SGPopup();
1030				sgPoupFrontendObj.popupOpenById(that.popupData['id']);
1031			}, repetitivePopupPeriod);
1032		}
1033		if(that.varToBool(that.popupData['popupOpenSound']) && popupOpenSoundFile) {
1034			if(typeof that.audio != 'undefined') {
1035				that.audio.pause();
1036				delete that.audio;
1037			}
1038
1039			SGPopup.soundValue = 1;
1040		}
1041	});
1042
1043	jQuery('#sgcolorbox').one("sgPopupClose", function () {
1044		if(disablePageScrolling) {
1045			jQuery('html').removeClass('sgpb-disable-page-scrolling');
1046		}
1047		if(that.popupData['type'] == 'html') {
1048			that.htmlIframeFilterForOpen('close');
1049		}
1050	});
1051};
1052
1053SGPopup.prototype.sgShowColorboxWithOptions = function () {
1054
1055	var that = this;
1056	setTimeout(function () {
1057
1058		that.colorboxEventsListener();
1059		var sgPopupFixed = that.varToBool(that.popupData['popupFixed']);
1060		var popupId = that.popupData['id'];
1061		that.popupOverlayClose = that.varToBool(that.popupData['overlayClose']);
1062		that.popupContentClick = that.varToBool(that.popupData['contentClick']);
1063		var popupReposition = that.varToBool(that.popupData['reposition']);
1064		var popupScrolling = that.varToBool(that.popupData['scrolling']);
1065		var popupScaling = that.varToBool(that.popupData['scaling']);
1066		that.popupEscKey = that.varToBool(that.popupData['escKey']);
1067		that.popupCloseButton = that.varToBool(that.popupData['closeButton']);
1068		var countryStatus = that.varToBool(that.popupData['countryStatus']);
1069		var popupForMobile = that.varToBool(that.popupData['forMobile']);
1070		var onlyMobile = that.varToBool(that.popupData['openMobile']);
1071		var popupCantClose = that.varToBool(that.popupData['disablePopup']);
1072		var disablePopupOverlay = that.varToBool(that.popupData['disablePopupOverlay']);
1073		var popupAutoClosePopup = that.varToBool(that.popupData['autoClosePopup']);
1074		var saveCookiePageLevel = that.varToBool(that.popupData['save-cookie-page-level']);
1075		var popupClosingTimer = that.popupData['popupClosingTimer'];
1076
1077		if (popupScaling) {
1078			that.sgPopupScaling();
1079		}
1080		if (popupCantClose) {
1081			that.cantPopupClose();
1082		}
1083		that.popupMaxWidth = (!that.popupData['maxWidth']) ? '100%' : that.popupData['maxWidth'];
1084		var popupPosition = sgPopupFixed ? that.popupData['fixedPostion'] : '';
1085		var popupVideo = that.popupData['video'];
1086		var popupOverlayColor = that.popupData['sgOverlayColor'];
1087		var contentBackgroundColor = that.popupData['sg-content-background-color'];
1088		var popupDimensionMode = that.popupData['popup-dimension-mode'];
1089		var popupResponsiveDimensionMeasure = that.popupData['popup-responsive-dimension-measure'];
1090		var popupWidth = that.popupData['width'];
1091		var popupHeight = that.popupData['height'];
1092		var popupOpacity = that.popupData['opacity'];
1093		var popupMaxHeight = (!that.popupData['maxHeight']) ? '100%' : that.popupData['maxHeight'];
1094		var popupInitialWidth = that.popupData['initialWidth'];
1095		var popupInitialHeight = that.popupData['initialHeight'];
1096		var popupEffectDuration = that.popupData['duration'];
1097		var popupEffect = that.popupData['effect'];
1098		var pushToBottom = that.popupData['pushToBottom'];
1099		var onceExpiresTime = parseInt(that.popupData['onceExpiresTime']);
1100		var sgType = that.popupData['type'];
1101		var overlayCustomClass = that.popupData['sgOverlayCustomClasss'];
1102		var contentCustomClass = that.popupData['sgContentCustomClasss'];
1103		var popupTheme = that.popupData['theme'];
1104		var themeStringLength = popupTheme.length;
1105		var customClassName = popupTheme.substring(0, themeStringLength - 4);
1106		var closeButtonText = that.popupData['theme-close-text'];
1107
1108		that.sgColorboxContentMode();
1109
1110		if(popupDimensionMode == 'responsiveMode') {
1111
1112			popupWidth = '';
1113			if(popupResponsiveDimensionMeasure != 'auto') {
1114				popupWidth = parseInt(popupResponsiveDimensionMeasure)+'%';
1115			}
1116
1117			if(that.popupData['type'] != 'iframe' && that.popupData['type'] != 'video') {
1118				popupHeight = '';
1119			}
1120		}
1121
1122		var sgScreenWidth = jQuery(window).width();
1123		var sgScreenHeight = jQuery(window).height();
1124
1125		var sgIsWidthInPercent = popupWidth.indexOf("%");
1126		var sgIsHeightInPercent = popupHeight.indexOf("%");
1127		var sgPopupHeightPx = popupHeight;
1128		var sgPopupWidthPx = popupWidth;
1129		if (sgIsWidthInPercent != -1) {
1130			sgPopupWidthPx = that.percentToPx(popupWidth, sgScreenWidth);
1131		}
1132		if (sgIsHeightInPercent != -1) {
1133			sgPopupHeightPx = that.percentToPx(popupHeight, sgScreenHeight);
1134		}
1135		/*for when width or height in px*/
1136		sgPopupWidthPx = parseInt(sgPopupWidthPx);
1137		sgPopupHeightPx = parseInt(sgPopupHeightPx);
1138
1139		var staticPositionWidth = sgPopupWidthPx;
1140		if(staticPositionWidth > sgScreenWidth) {
1141			staticPositionWidth = sgScreenWidth;
1142		}
1143
1144		var popupPositionTop = that.getPositionPercent("50%", sgScreenHeight, sgPopupHeightPx);
1145		var popupPositionLeft = that.getPositionPercent("50%", sgScreenWidth, staticPositionWidth);
1146		var posTopForSettings = popupPositionTop;
1147
1148		if (popupPosition == 1) {
1149			that.setFixedPosition('0%', '3%', false, false, 0, 0);
1150		} else if (popupPosition == 2) {
1151			that.setFixedPosition(popupPositionLeft, '3%', false, false, 0, 50);
1152		} else if (popupPosition == 3) {
1153			that.setFixedPosition(false, '3%', false, '0%', 0, 90);
1154		} else if (popupPosition == 4) {
1155
1156			if(isNaN(popupPositionTop)) {
1157				posTopForSettings = false;
1158			}
1159			that.setFixedPosition('0%', posTopForSettings, false, false, posTopForSettings, 0);
1160		} else if (popupPosition == 5) {
1161			sgPopupFixed = true;
1162			that.setFixedPosition(false, false, false, false, 50, 50);
1163		} else if (popupPosition == 6) {
1164			if(isNaN(popupPositionTop)) {
1165				posTopForSettings = false;
1166			}
1167			that.setFixedPosition('0%', posTopForSettings, false, '0%', 50, 90);
1168		} else if (popupPosition == 7) {
1169			that.setFixedPosition('0%', false, '0%', false, 90, 0);
1170		} else if (popupPosition == 8) {
1171			that.setFixedPosition(popupPositionLeft, false, '0%', false, 90, 50);
1172		} else if (popupPosition == 9) {
1173			that.setFixedPosition(false, false, '0%', '0%', 90, 90);
1174		}
1175		if (!sgPopupFixed) {
1176			that.setFixedPosition(false, false, false, false, 50, 50);
1177		}
1178
1179		var userDevice = false;
1180		if (popupForMobile) {
1181			userDevice = that.forMobile();
1182		}
1183
1184		if (popupAutoClosePopup) {
1185			setTimeout(that.autoClosePopup, popupClosingTimer * 1000);
1186		}
1187
1188		if (disablePopupOverlay) {
1189			that.sgTrapFocus = false;
1190			that.disablePopupOverlay();
1191		}
1192
1193		if (onlyMobile) {
1194			var openOnlyMobile = false;
1195			openOnlyMobile = that.forMobile();
1196			if (openOnlyMobile == false) {
1197				return;
1198			}
1199		}
1200
1201		if (userDevice) {
1202			return;
1203		}
1204		that.changePopupSettings();
1205		SG_POPUP_SETTINGS = {
1206			popupId: popupId,
1207			html: that.sgColorboxHtml,
1208			photo: that.sgColorboxPhoto,
1209			iframe: that.sgColorboxIframe,
1210			href: that.sgColorboxHref,
1211			inline: that.sgColorboxInline,
1212			width: popupWidth,
1213			height: popupHeight,
1214			className: customClassName,
1215			close: closeButtonText,
1216			overlayCutsomClassName: overlayCustomClass,
1217			contentCustomClassName: contentCustomClass,
1218			onOpen: function () {
1219				that.currentPopupId = popupId;
1220				if(that.sgColorboxInline) {
1221					var contentImage = jQuery(that.sgColorboxHref).find('img').first();
1222					if(contentImage.length) {
1223						var height = contentImage.attr('height');
1224						height = parseInt(height);
1225						contentImage.attr('style', 'height: '+height+' !important');
1226					}
1227				}
1228				jQuery('#sgcolorbox').removeAttr('style');
1229				jQuery('#sgcolorbox').removeAttr('left');
1230				jQuery('#sgcolorbox').css('top', '' + that.initialPositionTop + '%');
1231				jQuery('#sgcolorbox').css('left', '' + that.initialPositionLeft + '%');
1232				jQuery('#sgcolorbox').css('animation-duration', popupEffectDuration + "s");
1233				jQuery('#sgcolorbox').css('-webkit-animation-duration', popupEffectDuration + "s");
1234				jQuery("#sgcolorbox").addClass('sg-animated ' + popupEffect + '');
1235				jQuery("#sgcboxOverlay").addClass("sgcboxOverlayBg");
1236				jQuery("#sgcboxOverlay").removeAttr('style');
1237
1238				if (popupOverlayColor) {
1239					jQuery("#sgcboxOverlay").css({'background': 'none', 'background-color': popupOverlayColor});
1240				}
1241				var openArgs = {
1242					popupId: popupId
1243				};
1244
1245				jQuery('#sgcolorbox').trigger("sgColorboxOnOpen", openArgs);
1246
1247			},
1248			onLoad: function () {
1249			},
1250			onComplete: function () {
1251				if (contentBackgroundColor) {
1252					jQuery("#sgcboxLoadedContent").css({'background-color': contentBackgroundColor});
1253				}
1254				jQuery("#sgcboxLoadedContent").addClass("sg-current-popup-" + that.popupData['id']);
1255				var completeArgs = {
1256					pushToBottom: pushToBottom,
1257					popupId: popupId
1258				};
1259
1260				jQuery('#sgcolorbox').trigger("sgColorboxOnCompleate", completeArgs);
1261
1262				var sgpopupInit = new SgPopupInit(that.popupData);
1263				sgpopupInit.overallInit();
1264				/* For specific popup Like Countdown AgeRestcion popups */
1265				sgpopupInit.initByPopupType();
1266				that.sgCustomizeThemes(that.popupData['id']);
1267				if(popupDimensionMode == 'responsiveMode') {
1268					/* it's temporary deactivated  for colorbox resize good work that.resizeAfterContentResizing(); */
1269					that.resizePopup(SG_POPUP_SETTINGS);
1270					jQuery('#sgcboxLoadingGraphic').remove()
1271				}
1272			},
1273			onCleanup: function () {
1274				jQuery('#sgcolorbox').trigger("sgPopupCleanup", []);
1275			},
1276			onClosed: function () {
1277				that.currentPopupId = false;
1278				jQuery("#sgcboxLoadedContent").removeClass("sg-current-popup-" + that.popupData['id']);
1279				jQuery('#sgcolorbox').trigger("sgPopupClose", []);
1280			},
1281			trapFocus: that.sgTrapFocus,
1282			opacity: popupOpacity,
1283			escKey: that.popupEscKey,
1284			closeButton: that.popupCloseButton,
1285			fixed: sgPopupFixed,
1286			top: that.positionTop,
1287			bottom: that.positionBottom,
1288			left: that.positionLeft,
1289			right: that.positionRight,
1290			scrolling: popupScrolling,
1291			reposition: popupReposition,
1292			overlayClose: that.popupOverlayClose,
1293			maxWidth: that.popupMaxWidth,
1294			maxHeight: popupMaxHeight,
1295			initialWidth: popupInitialWidth,
1296			initialHeight: popupInitialHeight
1297		};
1298
1299		if(popupDimensionMode == 'responsiveMode') {
1300			/*colorbox open speed*/
1301			SG_POPUP_SETTINGS.speed = 10;
1302		}
1303		if (!that.currentPopupId) {
1304			jQuery.sgcolorbox(SG_POPUP_SETTINGS);
1305		}
1306
1307		if (countryStatus == true && typeof SgUserData != "undefined") {
1308			jQuery.cookie("SG_POPUP_USER_COUNTRY_NAME", SgUserData.countryIsoName, {expires: 365});
1309		}
1310		/* Cookie can't be set here as it's set in Age Restriction popup when the user clicks "yes" */
1311		if (that.popupData['id'] && that.isOnLoad == true && that.openOnce != '' && that.popupData['type'] != "ageRestriction") {
1312			var sgCookieData = '';
1313
1314			var currentCookie = SGPopup.getCookie('sgPopupDetails' + that.popupData['id']);
1315
1316			if (!currentCookie) {
1317				var openCounter = 1;
1318			}
1319			else {
1320				var currentCookie = JSON.parse(currentCookie);
1321				var openCounter = currentCookie.openCounter += 1;
1322			}
1323			sgCookieData = {
1324				'popupId': that.popupData['id'],
1325				'openCounter': openCounter,
1326				'openLimit': that.numberLimit
1327			};
1328
1329			/*!saveCookiePageLevel it's mean for all site level*/
1330			SGPopup.setCookie("sgPopupDetails"+that.popupData['id'],JSON.stringify(sgCookieData), onceExpiresTime, !saveCookiePageLevel);
1331		}
1332
1333
1334		jQuery('#sgcolorbox').bind('sgPopupClose', function (e) {
1335			/* reset event execute count for popup open */
1336			that.sgEventExecuteCount = 0;
1337			that.eventExecuteCountByClass = 0;
1338			jQuery('#sgcolorbox').removeClass(customClassName);
1339			/* Remove custom class for another popup */
1340			jQuery('#sgcboxOverlay').removeClass(customClassName);
1341			jQuery('#sgcolorbox').removeClass(popupEffect);
1342			/* Remove animated effect for another popup */
1343		});
1344
1345	}, this.popupData['delay'] * 1000);
1346};
1347
1348jQuery(document).ready(function ($) {
1349
1350	var popupObj = new SGPopup();
1351	popupObj.init();
1352});

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.