Popup Builder – Responsive WordPress Pop up - Version 2.5.8

Version Description

Current Version of Popup Builder is 2.5.8

Download this release

Release Info

Developer Sygnoos
Plugin Icon 128x128 Popup Builder – Responsive WordPress Pop up
Version 2.5.8
Comparing to
See all releases

Code changes from version 2.5.7 to 2.5.8

config.php CHANGED
@@ -24,8 +24,8 @@ if(!class_exists('SgPopupBuilderConfig')) {
24
  define('SG_APP_POPUP_JS', SG_APP_POPUP_PATH . '/javascript');
25
  define('SG_APP_POPUP_HELPERS', SG_APP_POPUP_PATH . '/helpers/');
26
  define('SG_APP_POPUP_TABLE_LIMIT', 15);
27
- define('SG_POPUP_VERSION', 2.57);
28
- define('SG_POPUP_PRO_VERSION', 3.27);
29
  define('SG_POPUP_PRO_URL', 'http://popup-builder.com/');
30
  define('SG_POPUP_EXTENSION_URL', 'http://popup-builder.com/extensions');
31
  define('SG_MAILCHIMP_EXTENSION_URL', 'http://popup-builder.com/downloads/mailchimp/');
24
  define('SG_APP_POPUP_JS', SG_APP_POPUP_PATH . '/javascript');
25
  define('SG_APP_POPUP_HELPERS', SG_APP_POPUP_PATH . '/helpers/');
26
  define('SG_APP_POPUP_TABLE_LIMIT', 15);
27
+ define('SG_POPUP_VERSION', 2.58);
28
+ define('SG_POPUP_PRO_VERSION', 3.28);
29
  define('SG_POPUP_PRO_URL', 'http://popup-builder.com/');
30
  define('SG_POPUP_EXTENSION_URL', 'http://popup-builder.com/extensions');
31
  define('SG_MAILCHIMP_EXTENSION_URL', 'http://popup-builder.com/downloads/mailchimp/');
files/options_section/pro.php CHANGED
@@ -110,19 +110,6 @@
110
  </div>
111
 
112
  </div>
113
- <?php if(!sgRemoveOption('showOnlyOnce')): ?>
114
- <span class="liquid-width">Show popup this often:</span><input class="input-width-static js-checkbox-acordion" id="js-popup-only-once" type="checkbox" name="repeatPopup" <?php echo $sgRepeatPopup;?>>
115
- <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">Show the popup to a user only once.</span><br>
116
- <div class="acordion-main-div-content js-popup-only-once-content">
117
- <span class="liquid-width">show popup less than </span><input class="before-scroling-percent" type="number" min="1" name="popup-appear-number-limit" value="<?php echo esc_attr(@$sgPopupAppearNumberLimit); ?>">
118
- <span class="span-percent">for same user</span><br>
119
- <span class="liquid-width">expire time</span><input class="before-scroling-percent improveOptionsstyle" type="number" min="1" name="onceExpiresTime" value="<?php echo esc_attr(@$sgOnceExpiresTime); ?>">
120
- <span class="span-percent">days</span><br>
121
- <span class="liquid-width">page level cookie saving</span>
122
- <input type="checkbox" name="save-cookie-page-level" <?php echo $sgPopupCookiePageLevel; ?>>
123
- <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">If this option is checked popup's cookie will be saved for a current page.By default cookie is set for all site.</span>
124
- </div>
125
- <?php endif;?>
126
 
127
  <span class="liquid-width">Show popup by user status:</span><input class="js-checkbox-acordion js-user-seperator" type="checkbox" name="sg-user-status" <?php echo $sgUserSeperate; ?>>
128
  <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">Show Popup if the user is logged in to your site or vice versa.</span><br>
110
  </div>
111
 
112
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  <span class="liquid-width">Show popup by user status:</span><input class="js-checkbox-acordion js-user-seperator" type="checkbox" name="sg-user-status" <?php echo $sgUserSeperate; ?>>
115
  <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">Show Popup if the user is logged in to your site or vice versa.</span><br>
files/sg_popup_create_new.php CHANGED
@@ -1245,7 +1245,9 @@ if (isset($_GET["titleError"])): ?>
1245
  <div class="handlediv dimentionsTitle" title="Click to toggle"><br></div>
1246
  <h3 class="hndle ui-sortable-handle dimentionsTitle" style="cursor: pointer"><span>Dimensions</span></h3>
1247
  <div class="dimensionsContent">
1248
- <?php createRadiobuttons($responsiveMode, 'popup-dimension-mode', true, esc_html($sgPopupDimensionMode), "liquid-width");?>
 
 
1249
  <div class="js-accordion-responsiveMode js-radio-accordion sg-accordion-content">
1250
  <span class="liquid-width">size</span>
1251
  <?php echo sgCreateSelect($sgResponsiveMeasure,'popup-responsive-dimension-measure',esc_html(@$sgPopupResponsiveDimensionMeasure));?>
@@ -1310,8 +1312,21 @@ if (isset($_GET["titleError"])): ?>
1310
 
1311
  <span class="liquid-width">Reopen after form submission:</span><input class="input-width-static" type="checkbox" name="reopenAfterSubmission" <?php echo $sgReopenAfterSubmission;?> />
1312
  <span class="dashicons dashicons-info overlayImg sameImageStyle"></span><span class="infoReopenSubmiting samefontStyle">If checked, the popup will reopen after form submission.</span><br>
1313
-
1314
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1315
  <span class="liquid-width">Change overlay color:</span><div id="color-picker"><input class="sgOverlayColor" id="sgOverlayColor" type="text" name="sgOverlayColor" value="<?php echo esc_attr(@$sgOverlayColor); ?>" /></div><br>
1316
 
1317
  <span class="liquid-width">Change background color:</span><div id="color-picker"><input class="sgOverlayColor" id="sgOverlayColor" type="text" name="sg-content-background-color" value="<?php echo esc_attr(@$sgContentBackgroundColor); ?>" /></div><br>
1245
  <div class="handlediv dimentionsTitle" title="Click to toggle"><br></div>
1246
  <h3 class="hndle ui-sortable-handle dimentionsTitle" style="cursor: pointer"><span>Dimensions</span></h3>
1247
  <div class="dimensionsContent">
1248
+ <div class="sg-radio-option-behavior">
1249
+ <?php createRadiobuttons($responsiveMode, 'popup-dimension-mode', true, esc_html($sgPopupDimensionMode), "liquid-width");?>
1250
+ </div>
1251
  <div class="js-accordion-responsiveMode js-radio-accordion sg-accordion-content">
1252
  <span class="liquid-width">size</span>
1253
  <?php echo sgCreateSelect($sgResponsiveMeasure,'popup-responsive-dimension-measure',esc_html(@$sgPopupResponsiveDimensionMeasure));?>
1312
 
1313
  <span class="liquid-width">Reopen after form submission:</span><input class="input-width-static" type="checkbox" name="reopenAfterSubmission" <?php echo $sgReopenAfterSubmission;?> />
1314
  <span class="dashicons dashicons-info overlayImg sameImageStyle"></span><span class="infoReopenSubmiting samefontStyle">If checked, the popup will reopen after form submission.</span><br>
1315
+
1316
+ <?php if(!sgRemoveOption('showOnlyOnce')): ?>
1317
+ <span class="liquid-width">Show popup this often:</span><input class="input-width-static js-checkbox-acordion" id="js-popup-only-once" type="checkbox" name="repeatPopup" <?php echo $sgRepeatPopup;?>>
1318
+ <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">Show the popup to a user only once.</span><br>
1319
+ <div class="acordion-main-div-content js-popup-only-once-content">
1320
+ <span class="liquid-width">show popup</span><input class="before-scroling-percent" type="number" min="1" name="popup-appear-number-limit" value="<?php echo esc_attr(@$sgPopupAppearNumberLimit); ?>">
1321
+ <span class="span-percent">time(s) for same user</span><br>
1322
+ <span class="liquid-width">expire time</span><input class="before-scroling-percent improveOptionsstyle" type="number" min="1" name="onceExpiresTime" value="<?php echo esc_attr(@$sgOnceExpiresTime); ?>">
1323
+ <span class="span-percent">days</span><br>
1324
+ <span class="liquid-width">page level cookie saving</span>
1325
+ <input type="checkbox" name="save-cookie-page-level" <?php echo $sgPopupCookiePageLevel; ?>>
1326
+ <span class="dashicons dashicons-info repeatPopup same-image-style"></span><span class="infoSelectRepeat samefontStyle">If this option is checked popup's cookie will be saved for a current page.By default cookie is set for all site.</span>
1327
+ </div>
1328
+ <?php endif;?>
1329
+
1330
  <span class="liquid-width">Change overlay color:</span><div id="color-picker"><input class="sgOverlayColor" id="sgOverlayColor" type="text" name="sgOverlayColor" value="<?php echo esc_attr(@$sgOverlayColor); ?>" /></div><br>
1331
 
1332
  <span class="liquid-width">Change background color:</span><div id="color-picker"><input class="sgOverlayColor" id="sgOverlayColor" type="text" name="sg-content-background-color" value="<?php echo esc_attr(@$sgContentBackgroundColor); ?>" /></div><br>
files/sg_popup_media_button.php CHANGED
@@ -115,6 +115,10 @@ function sgPopupMediaButtonThickboxs()
115
  $orderBy = 'id DESC';
116
  $allPopups = SGPopup::findAll($orderBy);
117
  foreach ($allPopups as $popup) :
 
 
 
 
118
  if((isset($_GET['id']) && $popup->getId() == (int)@$_GET['id'] || $popup->getType() == 'exitIntent') && $currentPageParams['id'] == 'popup-builder_page_edit-popup') {
119
  continue;
120
  }
115
  $orderBy = 'id DESC';
116
  $allPopups = SGPopup::findAll($orderBy);
117
  foreach ($allPopups as $popup) :
118
+ if($popup->getType() === false) {
119
+ continue;
120
+ }
121
+
122
  if((isset($_GET['id']) && $popup->getId() == (int)@$_GET['id'] || $popup->getType() == 'exitIntent') && $currentPageParams['id'] == 'popup-builder_page_edit-popup') {
123
  continue;
124
  }
files/sg_popup_save.php CHANGED
@@ -56,16 +56,20 @@ function sgPopupSave()
56
  $allSelectedCustomPosts = "";
57
  $allSelectedCategories = sgSanitize("posts-all-categories", true);
58
 
 
 
 
 
59
  /* if popup check for all pages it is not needed for save all pages all posts */
60
- if($showAllPages !== "all") {
61
- $allSelectedPages = explode(",", sgSanitize('all-selected-page'));
62
  }
63
 
64
- if($showAllPosts !== "all") {
65
- $allSelectedPosts = explode(",", sgSanitize('all-selected-posts'));
66
  }
67
- if($showAllCustomPosts !== "all") {
68
- $allSelectedCustomPosts = explode(",", sgSanitize('all-selected-custom-posts'));
69
  }
70
 
71
  $socialOptions = array(
56
  $allSelectedCustomPosts = "";
57
  $allSelectedCategories = sgSanitize("posts-all-categories", true);
58
 
59
+ $selectedPages = sgSanitize('all-selected-page');
60
+ $selectedPosts = sgSanitize('all-selected-posts');
61
+ $selectedCustomPosts = sgSanitize('all-selected-custom-posts');
62
+
63
  /* if popup check for all pages it is not needed for save all pages all posts */
64
+ if($showAllPages !== "all" && !empty($selectedPages)) {
65
+ $allSelectedPages = explode(",", $selectedPages);
66
  }
67
 
68
+ if($showAllPosts !== "all" && !empty($selectedPosts)) {
69
+ $allSelectedPosts = explode(",", $selectedPosts);
70
  }
71
+ if($showAllCustomPosts !== "all" && !empty($selectedCustomPosts)) {
72
+ $allSelectedCustomPosts = explode(",", $selectedCustomPosts);
73
  }
74
 
75
  $socialOptions = array(
helpers/SgPopupGetData.php CHANGED
@@ -31,7 +31,7 @@ class SgPopupGetData {
31
  }
32
 
33
  $deafaultValues = self::getDefaultValues();
34
- $deafultSettings = $deafaultValues[$optionType.'Paramas'];
35
 
36
  return $deafultSettings[$optionName];
37
  }
31
  }
32
 
33
  $deafaultValues = self::getDefaultValues();
34
+ $deafultSettings = $deafaultValues[$optionType.'Params'];
35
 
36
  return $deafultSettings[$optionName];
37
  }
javascript/sg_popup_backend.js CHANGED
@@ -1 +1 @@
1
- function beckend() {
2
  this.titleNotEmpty(); /* Check title is Empty */
3
  this.showThemePicture(); /* Show themes pictures */
4
  this.showEffects(); /* Show effect type */
5
  this.pageAcordion(); /* For page accordion divs */
6
  this.fixedPostionSelection(); /* Functionality for selected position */
7
  this.showInfo(); /* Show description options */
8
  this.opacityRange();
9
  this.subOptionContents();
10
  this.addCountries();
11
  this.showCloseTextFieldForTheme();
12
  this.popupReview();
13
  this.colorPicekr(); /* Color picker */
14
  this.switchPopupActive();
15
  this.initAccordions();
16
  });
17
  jQuery('.sg-info-close').on('click', function() {
18
  jQuery( ".sg-info-panel-wrapper" ).hide(300);
19
  });
20
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"showMessage", jQuery('.js-subs-success-message-content'));
21
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"redirectToUrl", jQuery('.js-subs-success-redirect-content'));
22
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"openPopup", jQuery('.js-subs-success-popups-list-content'));
23
  checkedElement.after(toggleContnet.css({'display':'inline-block'}));
 
24
  this.titleNotEmpty(); /* Check title is Empty */
25
  this.showThemePicture(); /* Show themes pictures */
26
  this.showEffects(); /* Show effect type */
27
  this.pageAcordion(); /* For page accordion divs */
28
  this.fixedPostionSelection(); /* Functionality for selected position */
29
  this.showInfo(); /* Show description options */
30
  this.opacityRange();
31
  this.subOptionContents();
32
  this.addCountries();
33
  this.showCloseTextFieldForTheme();
34
  this.popupReview();
35
  this.colorPicekr(); /* Color picker */
36
  this.switchPopupActive();
37
  this.initAccordions();
38
  });
39
  jQuery('.sg-info-close').on('click', function() {
40
  jQuery( ".sg-info-panel-wrapper" ).hide(300);
41
  });
42
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"showMessage", jQuery('.js-subs-success-message-content'));
43
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"redirectToUrl", jQuery('.js-subs-success-redirect-content'));
44
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"openPopup", jQuery('.js-subs-success-popups-list-content'));
45
  checkedElement.after(toggleContnet.css({'display':'inline-block'}));
 
1
  this.titleNotEmpty(); /* Check title is Empty */
2
  this.showThemePicture(); /* Show themes pictures */
3
  this.showEffects(); /* Show effect type */
4
  this.pageAcordion(); /* For page accordion divs */
5
  this.fixedPostionSelection(); /* Functionality for selected position */
6
  this.showInfo(); /* Show description options */
7
  this.opacityRange();
8
  this.subOptionContents();
9
  this.addCountries();
10
  this.showCloseTextFieldForTheme();
11
  this.popupReview();
12
  this.colorPicekr(); /* Color picker */
13
  this.switchPopupActive();
14
  this.initAccordions();
15
  });
16
  jQuery('.sg-info-close').on('click', function() {
17
  jQuery( ".sg-info-panel-wrapper" ).hide(300);
18
  });
19
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"showMessage", jQuery('.js-subs-success-message-content'));
20
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"redirectToUrl", jQuery('.js-subs-success-redirect-content'));
21
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"openPopup", jQuery('.js-subs-success-popups-list-content'));
22
  checkedElement.after(toggleContnet.css({'display':'inline-block'}));
23
+ function beckend() {
24
  this.titleNotEmpty(); /* Check title is Empty */
25
  this.showThemePicture(); /* Show themes pictures */
26
  this.showEffects(); /* Show effect type */
27
  this.pageAcordion(); /* For page accordion divs */
28
  this.fixedPostionSelection(); /* Functionality for selected position */
29
  this.showInfo(); /* Show description options */
30
  this.opacityRange();
31
  this.subOptionContents();
32
  this.addCountries();
33
  this.showCloseTextFieldForTheme();
34
  this.popupReview();
35
  this.colorPicekr(); /* Color picker */
36
  this.switchPopupActive();
37
  this.initAccordions();
38
  });
39
  jQuery('.sg-info-close').on('click', function() {
40
  jQuery( ".sg-info-panel-wrapper" ).hide(300);
41
  });
42
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"showMessage", jQuery('.js-subs-success-message-content'));
43
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"redirectToUrl", jQuery('.js-subs-success-redirect-content'));
44
  this.radioButtonAcordion(jQuery("[name='subs-success-behavior']"),jQuery("[name='subs-success-behavior']:checked"),"openPopup", jQuery('.js-subs-success-popups-list-content'));
45
  checkedElement.after(toggleContnet.css({'display':'inline-block'}));
javascript/sg_popup_frontend.js CHANGED
@@ -1,77 +1,943 @@
1
- function SGPopup(){this.positionLeft='';this.positionTop='';this.positionBottom='';this.positionRight='';this.initialPositionTop='';this.initialPositionLeft='';this.isOnLoad='';this.openOnce='';this.numberLimit='';this.popupData=new Array();this.popupEscKey=true;this.popupOverlayClose=true;this.popupContentClick=false;this.popupCloseButton=true;this.sgTrapFocus=true;this.popupType='';this.popupClassEvents=['hover'];this.eventExecuteCountByClass=0;this.sgEventExecuteCount=0;this.sgColorboxContentTypeReset();}
2
- SGPopup.prototype.sgColorboxContentTypeReset=function(){this.sgColorboxHtml=false;this.sgColorboxPhoto=false;this.sgColorboxIframe=false;this.sgColorboxHref=false;this.sgColorboxInline=false;};SGPopup.sgColorBoxDeafults={1:70,2:34,3:30,4:70,5:62,6:70};SGPopup.prototype.popupOpenById=function(popupId){var sgOnScrolling=(SG_POPUP_DATA[popupId]['onScrolling'])?SG_POPUP_DATA[popupId]['onScrolling']:'';var sgInActivity=(SG_POPUP_DATA[popupId]['inActivityStatus'])?SG_POPUP_DATA[popupId]['inActivityStatus']:'';var autoClosePopup=(SG_POPUP_DATA[popupId]['autoClosePopup'])?SG_POPUP_DATA[popupId]['autoClosePopup']:'';if(sgOnScrolling){this.onScrolling(popupId);}
3
- else if(sgInActivity){this.showPopupAfterInactivity(popupId);}
4
- else{this.showPopup(popupId,true);}};SGPopup.getCookie=function(cName){var name=cName+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1);}
5
- if(c.indexOf(name)==0){return c.substring(name.length,c.length);}}
6
- return"";};SGPopup.deleteCookie=function(name){document.cookie=name+'=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';};SGPopup.setCookie=function(cName,cValue,exDays,cPageLevel){var expirationDate=new Date();var cookiePageLevel='';var cookieExpirationData=1;if(!exDays||isNaN(exDays)){exDays=365*50;}
7
- if(typeof cPageLevel=='undefined'){cPageLevel=false;}
8
- expirationDate.setDate(expirationDate.getDate()+exDays);cookieExpirationData=expirationDate.toUTCString();var expires='expires='+cookieExpirationData;if(exDays==-1){expires='';}
9
- if(cPageLevel){cookiePageLevel='path=/;';}
10
- var value=cValue+((exDays==null)?";":"; "+expires+";"+cookiePageLevel);document.cookie=cName+"="+value;};SGPopup.prototype.init=function(){var that=this;this.onCompleate();this.popupOpenByCookie();this.attacheShortCodeEvent();this.attacheClickEvent();this.attacheIframeEvent();this.attacheConfirmEvent();this.popupClassEventsTrigger();};SGPopup.prototype.attacheShortCodeEvent=function(){var that=this;jQuery(".sg-show-popup").each(function(){var popupEvent=jQuery(this).attr("data-popup-event");if(typeof popupEvent=='undefined'){popupEvent='click';}
11
- that.sgEventExecuteCount=0;jQuery(this).bind(popupEvent,function(){that.sgEventExecuteCount+=1;if(that.sgEventExecuteCount>1){return;}
12
- var sgPopupID=jQuery(this).attr("data-sgpopupid");that.showPopup(sgPopupID,false);});});};SGPopup.prototype.attacheConfirmEvent=function(){var that=this;jQuery("[class*='sg-confirm-popup-']").each(function(){jQuery(this).bind("click",function(e){e.preventDefault();var currentLink=jQuery(this);var className=jQuery(this).attr("class");var sgPopupId=that.findPopupIdFromClassNames(className,"sg-confirm-popup-");jQuery('#sgcolorbox').bind("sgPopupClose",function(){var target=currentLink.attr("target");if(typeof target=='undefined'){target="self";}
13
- var href=currentLink.attr("href");if(target=="_blank"){window.open(href);}
14
- else{window.location.href=href;}});that.showPopup(sgPopupId,false);})});};SGPopup.prototype.attacheIframeEvent=function(){var that=this;jQuery("[class*='sg-iframe-popup-']").each(function(){var currentLink=jQuery(this);jQuery(this).bind("click",function(e){e.preventDefault();var className=jQuery(this).attr("class");var sgPopupId=that.findPopupIdFromClassNames(className,"sg-iframe-popup-");var linkUrl=currentLink.attr("href");if(typeof linkUrl=='undefined'){var childLinkTag=currentLink.find('a');linkUrl=childLinkTag.attr("href");}
15
- SG_POPUP_DATA[sgPopupId]['iframe']=linkUrl;that.showPopup(sgPopupId,false);});});};SGPopup.prototype.attacheClickEvent=function(){var that=this;jQuery("[class*='sg-popup-id-']").each(function(){jQuery(this).bind("click",function(e){e.preventDefault();var className=jQuery(this).attr("class");var sgPopupId=that.findPopupIdFromClassNames(className,"sg-popup-id-");that.showPopup(sgPopupId,false);})});};SGPopup.prototype.popupClassEventsTrigger=function(){var popupEvents=this.popupClassEvents;var that=this;if(popupEvents.length>0){for(var i in popupEvents){var eventName=popupEvents[i];that.attacheCustomEvent(eventName);}}};SGPopup.prototype.attacheCustomEvent=function(eventName){if(typeof eventName=='undefined'||eventName==''){return;}
16
- var that=this;jQuery("[class*='sg-popup-"+eventName+"-']").each(function(){var eventCount=that.eventExecuteCountByClass;jQuery(this).bind(eventName,function(){eventCount=++that.eventExecuteCountByClass;if(eventCount>1){return;}
17
- var className=jQuery(this).attr("class");var sgPopupId=that.findPopupIdFromClassNames(className,'sg-popup-'+eventName+'-');that.showPopup(sgPopupId,false);})});};SGPopup.prototype.popupOpenByCookie=function(){var popupId=SGPopup.getCookie("sgSubmitReloadingForm");popupId=parseInt(popupId);if(typeof popupId=='number'){this.showPopup(popupId,false);}};SGPopup.prototype.findPopupIdFromClassNames=function(className,classKey){var classSplitArray=className.split(classKey);var classIdString=classSplitArray['1'];var popupId=classIdString.match(/^\d+/);return popupId;};SGPopup.prototype.hexToRgba=function(hex,opacity){var c;if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){c=hex.substring(1).split('');if(c.length==3){c=[c[0],c[0],c[1],c[1],c[2],c[2]];}
18
- c='0x'+c.join('');return'rgba('+[(c>>16)&255,(c>>8)&255,c&255].join(',')+','+opacity+')';}
19
- throw new Error('Bad Hex');};SGPopup.prototype.sgCustomizeThemes=function(popupId){var popupData=SG_POPUP_DATA[popupId];var borderRadiues=popupData['sg3ThemeBorderRadiues'];var popupContentOpacity=popupData['popup-background-opacity'];var popupContentColor=jQuery('#sgcboxContent').css('background-color');var contentBackgroundColor=popupData['sg-content-background-color'];var changedColor=popupContentColor.replace(')',', '+popupContentOpacity+')').replace('rgb','rgba');if(contentBackgroundColor!=''){changedColor=this.hexToRgba(contentBackgroundColor,popupContentOpacity);}
20
- if(popupData['theme']=="colorbox3.css"){var borderColor=popupData['sgTheme3BorderColor'];var borderRadiues=popupData['sgTheme3BorderRadius'];jQuery("#sgcboxLoadedContent").css({'border-color':borderColor});jQuery("#sgcboxLoadedContent").css({'border-radius':borderRadiues+"%"});jQuery("#sgcboxContent").css({'border-radius':borderRadiues+"%"})}
21
- jQuery('#sgcboxContent').css({'background-color':changedColor});jQuery('#sgcboxLoadedContent').css({'background-color':changedColor})};SGPopup.prototype.onCompleate=function(){jQuery("#sgcolorbox").bind("sgColorboxOnCompleate",function(){jQuery('#sgcboxLoadedContent').isolatedScroll();});this.isolatedScroll();};SGPopup.prototype.isolatedScroll=function(){jQuery.fn.isolatedScroll=function(){this.bind('mousewheel DOMMouseScroll',function(e){var delta=e.wheelDelta||(e.originalEvent&&e.originalEvent.wheelDelta)||-e.detail,bottomOverflow=this.scrollTop+jQuery(this).outerHeight()-this.scrollHeight>=0,topOverflow=this.scrollTop<=0;if((delta<0&&bottomOverflow)||(delta>0&&topOverflow)){e.preventDefault();}});return this;};};SGPopup.prototype.sgPopupScalingDimensions=function(){var popupWrapper=jQuery("#sgcboxWrapper").outerWidth();var screenWidth=jQuery(window).width();if(popupWrapper>screenWidth&&popupWrapper!=9999){var scaleDegree=screenWidth/popupWrapper;jQuery("#sgcboxWrapper").css({"transform-origin":"0 0 !important",'transform':"scale("+scaleDegree+", 1)"});popupWrapper=0;}
22
- else{jQuery("#sgcboxWrapper").css({"transform-origin":"0 0 !important",'transform':"scale(1, 1)"})}};SGPopup.prototype.sgPopupScaling=function(){var that=this;jQuery("#sgcolorbox").bind("sgColorboxOnCompleate",function(){that.sgPopupScalingDimensions();});jQuery(window).resize(function(){setTimeout(function(){that.sgPopupScalingDimensions();},1000);});};SGPopup.prototype.varToBool=function(optionName){var returnValue=(optionName)?true:false;return returnValue;};SGPopup.prototype.canOpenPopup=function(id,openOnce,isOnLoad){if(!isOnLoad){return true;}
23
- var currentCookies=SGPopup.getCookie('sgPopupCookieList');if(currentCookies){currentCookies=JSON.parse(currentCookies);for(var cookieIndex in currentCookies){var cookieName=currentCookies[cookieIndex];var cookieData=SGPopup.getCookie(cookieName+id);if(cookieData){return false;}}}
24
- var popupCookie=SGPopup.getCookie('sgPopupDetails'+id);var popupType=this.popupType;if(openOnce&&popupCookie!=''){return this.canOpenOnce(id);}
25
- return true;};SGPopup.prototype.setFixedPosition=function(sgPositionLeft,sgPositionTop,sgPositionBottom,sgPositionRight,sgFixedPositionTop,sgFixedPositionLeft){this.positionLeft=sgPositionLeft;this.positionTop=sgPositionTop;this.positionBottom=sgPositionBottom;this.positionRight=sgPositionRight;this.initialPositionTop=sgFixedPositionTop;this.initialPositionLeft=sgFixedPositionLeft;};SGPopup.prototype.percentToPx=function(percentDimention,screenDimension){var dimension=parseInt(percentDimention)*screenDimension/100;return dimension;};SGPopup.prototype.getPositionPercent=function(needPercent,screenDimension,dimension){var sgPosition=(((this.percentToPx(needPercent,screenDimension)-dimension/2)/screenDimension)*100)+"%";return sgPosition;};SGPopup.prototype.showPopup=function(id,isOnLoad){var that=this;if(!id){return;}
26
- this.popupData=SG_POPUP_DATA[id];if(typeof this.popupData=="undefined"){return;}
27
- this.popupType=this.popupData['type'];this.isOnLoad=isOnLoad;this.openOnce=this.varToBool(this.popupData['repeatPopup']);this.numberLimit=this.popupData['popup-appear-number-limit'];if(typeof that.removeCookie!=='undefined'){that.removeCookie(this.openOnce);}
28
- if(!this.canOpenPopup(this.popupData['id'],this.openOnce,isOnLoad)){return;}
29
- popupColorboxUrl=SG_APP_POPUP_URL+'/style/sgcolorbox/sgthemes.css';head=document.getElementsByTagName('head')[0];link=document.createElement('link');link.type="text/css";link.id="sg_colorbox_theme-css";link.rel="stylesheet";link.href=popupColorboxUrl;document.getElementsByTagName('head')[0].appendChild(link);var img=document.createElement('img');sgAddEvent(img,"error",function(){that.sgShowColorboxWithOptions();});setTimeout(function(){img.src=popupColorboxUrl;},0);};SGPopup.setToPopupsCookiesList=function(cookieName){var currentCookies=SGPopup.getCookie('sgPopupCookieList');if(!currentCookies){currentCookies=[];}
30
- else{currentCookies=JSON.parse(currentCookies);}
31
- if(jQuery.inArray(cookieName,currentCookies)==-1){cookieName=currentCookies.push(cookieName);}
32
- SGPopup.deleteCookie('sgPopupCookieList');var currentCookies=JSON.stringify(currentCookies);SGPopup.setCookie('sgPopupCookieList',currentCookies,365,true);};SGPopup.prototype.popupThemeDefaultMeasure=function(){var themeName=this.popupData['theme'];var defaults=SGPopup.sgColorBoxDeafults;var themeId=themeName.replace(/(^.+\D)(\d+)(\D.+$)/i,'$2');return defaults[themeId];};SGPopup.prototype.changePopupSettings=function(){var popupData=this.popupData;var popupDimensionMode=popupData['popup-dimension-mode'];var maxWidth=popupData['maxWidth'];var popupResponsiveDimensionMeasure=popupData['popup-responsive-dimension-measure'];if(popupDimensionMode=='responsiveMode'){if(popupResponsiveDimensionMeasure=='auto'){if(!maxWidth){this.popupMaxWidth='100%';}}}};SGPopup.prototype.resizeDimension=function(){var resizeTimer;var themeDefault=this.popupThemeDefaultMeasure();var responsiveMeasure=this.popupData['popup-responsive-dimension-measure'];var windowWidth=jQuery(window).width();var popupWidth=jQuery("#sgcolorbox").width();function resizeColorBox(){var sgColorBoxWidth=jQuery("#sgcolorbox").width();var isPopupLargerThanWindow=sgColorBoxWidth>windowWidth;jQuery(window).unbind('resize.sgcbox');if(resizeTimer)clearTimeout(resizeTimer);resizeTimer=setTimeout(function(){if(jQuery('#sgcboxOverlay').is(':visible')){var width=jQuery(window).width();var contentHeight=jQuery('#sgcboxLoadedContent')[0].scrollHeight+themeDefault;var contentWidth=jQuery.sgcolorbox.settings.width;if(width>=768&&width<=959&&isPopupLargerThanWindow){contentWidth='82%';}
33
- else if(width>=480&&width<=767&&isPopupLargerThanWindow){contentWidth='88%';}
34
- else if(width<=479&&isPopupLargerThanWindow){contentWidth='94%';}
35
- else{contentWidth=responsiveMeasure+'%';}
36
- if(responsiveMeasure=='auto'&&!isPopupLargerThanWindow){jQuery.sgcolorbox.resize();return;}
37
- jQuery.sgcolorbox.settings.width=contentWidth;jQuery.sgcolorbox.sgpbResize({'width':contentWidth,'height':contentHeight});}},350)}
38
- jQuery(window).resize(resizeColorBox);window.addEventListener("orientationchange",resizeColorBox,false);};SGPopup.prototype.sgColorboxContentMode=function(){var that=this;this.sgColorboxContentTypeReset();var popupType=this.popupData['type'];var popupHtml=(this.popupData['html']=='')?'&nbsp;':this.popupData['html'];var popupImage=this.popupData['image'];var popupIframeUrl=this.popupData['iframe'];var popupVideo=this.popupData['video'];var popupId=this.popupData['id'];popupImage=(popupImage)?popupImage:false;popupVideo=(popupVideo)?popupVideo:false;popupIframeUrl=(popupIframeUrl)?popupIframeUrl:false;if(popupType=='image'){this.sgColorboxPhoto=true;this.sgColorboxHref=popupImage;}
39
- if(popupIframeUrl){this.sgColorboxIframe=true;this.sgColorboxHref=popupIframeUrl;}
40
- if(popupVideo){this.sgColorboxIframe=true;this.sgColorboxHref=popupVideo;}
41
- if(popupHtml&&jQuery('#sg-popup-content-wrapper-'+popupId).length!=0){this.sgColorboxInline=true;this.sgColorboxHref='#sg-popup-content-wrapper-'+popupId;}
42
- else{this.sgColorboxHtml=popupHtml;}};SGPopup.prototype.sgShowColorboxWithOptions=function(){var that=this;setTimeout(function(){var sgPopupFixed=that.varToBool(that.popupData['popupFixed']);var popupId=that.popupData['id'];that.popupOverlayClose=that.varToBool(that.popupData['overlayClose']);that.popupContentClick=that.varToBool(that.popupData['contentClick']);var popupReposition=that.varToBool(that.popupData['reposition']);var popupScrolling=that.varToBool(that.popupData['scrolling']);var popupScaling=that.varToBool(that.popupData['scaling']);that.popupEscKey=that.varToBool(that.popupData['escKey']);that.popupCloseButton=that.varToBool(that.popupData['closeButton']);var countryStatus=that.varToBool(that.popupData['countryStatus']);var popupForMobile=that.varToBool(that.popupData['forMobile']);var onlyMobile=that.varToBool(that.popupData['openMobile']);var popupCantClose=that.varToBool(that.popupData['disablePopup']);var disablePopupOverlay=that.varToBool(that.popupData['disablePopupOverlay']);var popupAutoClosePopup=that.varToBool(that.popupData['autoClosePopup']);var saveCookiePageLevel=that.varToBool(that.popupData['save-cookie-page-level']);var popupClosingTimer=that.popupData['popupClosingTimer'];if(popupScaling){that.sgPopupScaling();}
43
- if(popupCantClose){that.cantPopupClose();}
44
- that.popupMaxWidth=that.popupData['maxWidth'];var popupPosition=that.popupData['fixedPostion'];var popupVideo=that.popupData['video'];var popupOverlayColor=that.popupData['sgOverlayColor'];var contentBackgroundColor=that.popupData['sg-content-background-color'];var popupDimensionMode=that.popupData['popup-dimension-mode'];var popupResponsiveDimensionMeasure=that.popupData['popup-responsive-dimension-measure'];var popupWidth=that.popupData['width'];var popupHeight=that.popupData['height'];var popupOpacity=that.popupData['opacity'];var popupMaxHeight=that.popupData['maxHeight'];var popupInitialWidth=that.popupData['initialWidth'];var popupInitialHeight=that.popupData['initialHeight'];var popupEffectDuration=that.popupData['duration'];var popupEffect=that.popupData['effect'];var contentClickBehavior=that.popupData['content-click-behavior'];var clickRedirectToUrl=that.popupData['click-redirect-to-url'];var redirectToNewTab=that.popupData['redirect-to-new-tab'];var pushToBottom=that.popupData['pushToBottom'];var onceExpiresTime=parseInt(that.popupData['onceExpiresTime']);var sgType=that.popupData['type'];var overlayCustomClass=that.popupData['sgOverlayCustomClasss'];var contentCustomClass=that.popupData['sgContentCustomClasss'];var popupTheme=that.popupData['theme'];var themeStringLength=popupTheme.length;var customClassName=popupTheme.substring(0,themeStringLength-4);var closeButtonText=that.popupData['theme-close-text'];that.sgColorboxContentMode();if(popupDimensionMode=='responsiveMode'){popupWidth='';if(popupResponsiveDimensionMeasure!='auto'){popupWidth=parseInt(popupResponsiveDimensionMeasure)+'%';}
45
- popupHeight='';}
46
- if(popupVideo){if(popupWidth==''){popupWidth='50%';}
47
- if(popupHeight==''){popupHeight='50%';}}
48
- var sgScreenWidth=jQuery(window).width();var sgScreenHeight=jQuery(window).height();var sgIsWidthInPercent=popupWidth.indexOf("%");var sgIsHeightInPercent=popupHeight.indexOf("%");var sgPopupHeightPx=popupHeight;var sgPopupWidthPx=popupWidth;if(sgIsWidthInPercent!=-1){sgPopupWidthPx=that.percentToPx(popupWidth,sgScreenWidth);}
49
- if(sgIsHeightInPercent!=-1){sgPopupHeightPx=that.percentToPx(popupHeight,sgScreenHeight);}
50
- sgPopupWidthPx=parseInt(sgPopupWidthPx);sgPopupHeightPx=parseInt(sgPopupHeightPx);var popupPositionTop=that.getPositionPercent("50%",sgScreenHeight,sgPopupHeightPx);var popupPositionLeft=that.getPositionPercent("50%",sgScreenWidth,sgPopupWidthPx);if(popupPosition==1){that.setFixedPosition('0%','3%',false,false,0,0);}
51
- else if(popupPosition==2){that.setFixedPosition(popupPositionLeft,'3%',false,false,0,50);}
52
- else if(popupPosition==3){that.setFixedPosition(false,'3%',false,'0%',0,90);}
53
- else if(popupPosition==4){that.setFixedPosition('0%',popupPositionTop,false,false,popupPositionTop,0);}
54
- else if(popupPosition==5){sgPopupFixed=true;that.setFixedPosition(false,false,false,false,50,50);}
55
- else if(popupPosition==6){that.setFixedPosition('0%',popupPositionTop,false,'0%',50,90);}
56
- else if(popupPosition==7){that.setFixedPosition('0%',false,'0%',false,90,0);}
57
- else if(popupPosition==8){that.setFixedPosition(popupPositionLeft,false,'0%',false,90,50);}
58
- else if(popupPosition==9){that.setFixedPosition(false,false,'0%','0%',90,90);}
59
- if(!sgPopupFixed){that.setFixedPosition(false,false,false,false,50,50);}
60
- var userDevice=false;if(popupForMobile){userDevice=that.forMobile();}
61
- if(popupAutoClosePopup){setTimeout(that.autoClosePopup,popupClosingTimer*1000);}
62
- if(disablePopupOverlay){that.sgTrapFocus=false;that.disablePopupOverlay();}
63
- if(onlyMobile){var openOnlyMobile=false;openOnlyMobile=that.forMobile();if(openOnlyMobile==false){return;}}
64
- if(userDevice){return;}
65
- that.changePopupSettings();SG_POPUP_SETTINGS={popupId:popupId,html:that.sgColorboxHtml,photo:that.sgColorboxPhoto,iframe:that.sgColorboxIframe,href:that.sgColorboxHref,inline:that.sgColorboxInline,width:popupWidth,height:popupHeight,className:customClassName,close:closeButtonText,overlayCutsomClassName:overlayCustomClass,contentCustomClassName:contentCustomClass,onOpen:function(){jQuery('#sgcolorbox').removeAttr('style');jQuery('#sgcolorbox').removeAttr('left');jQuery('#sgcolorbox').css('top',''+that.initialPositionTop+'%');jQuery('#sgcolorbox').css('left',''+that.initialPositionLeft+'%');jQuery('#sgcolorbox').css('animation-duration',popupEffectDuration+"s");jQuery('#sgcolorbox').css('-webkit-animation-duration',popupEffectDuration+"s");jQuery("#sgcolorbox").addClass('sg-animated '+popupEffect+'');jQuery("#sgcboxOverlay").addClass("sgcboxOverlayBg");jQuery("#sgcboxOverlay").removeAttr('style');if(popupOverlayColor){jQuery("#sgcboxOverlay").css({'background':'none','background-color':popupOverlayColor});}
66
- jQuery('#sgcolorbox').trigger("sgColorboxOnOpen",[]);},onLoad:function(){},onComplete:function(){if(contentBackgroundColor){jQuery("#sgcboxLoadedContent").css({'background-color':contentBackgroundColor});}
67
- jQuery("#sgcboxLoadedContent").addClass("sg-current-popup-"+that.popupData['id']);jQuery('#sgcolorbox').trigger("sgColorboxOnCompleate",[pushToBottom]);var sgpopupInit=new SgPopupInit(that.popupData);sgpopupInit.overallInit();sgpopupInit.initByPopupType();that.sgCustomizeThemes(that.popupData['id']);if(popupDimensionMode=='responsiveMode'){that.resizeDimension();}},onCleanup:function(){jQuery('#sgcolorbox').trigger("sgPopupCleanup",[]);},onClosed:function(){jQuery("#sgcboxLoadedContent").removeClass("sg-current-popup-"+that.popupData['id']);jQuery('#sgcolorbox').trigger("sgPopupClose",[]);},trapFocus:that.sgTrapFocus,opacity:popupOpacity,escKey:that.popupEscKey,closeButton:that.popupCloseButton,fixed:sgPopupFixed,top:that.positionTop,bottom:that.positionBottom,left:that.positionLeft,right:that.positionRight,scrolling:popupScrolling,reposition:popupReposition,overlayClose:that.popupOverlayClose,maxWidth:that.popupMaxWidth,maxHeight:popupMaxHeight,initialWidth:popupInitialWidth,initialHeight:popupInitialHeight};if(popupDimensionMode=='responsiveMode'){SG_POPUP_SETTINGS.speed=10;}
68
- jQuery.sgcolorbox(SG_POPUP_SETTINGS);if(countryStatus==true&&typeof SgUserData!="undefined"){jQuery.cookie("SG_POPUP_USER_COUNTRY_NAME",SgUserData.countryIsoName,{expires:365});}
69
- if(that.popupData['id']&&that.isOnLoad==true&&that.openOnce!=''&&that.popupData['type']!="ageRestriction"){var sgCookieData='';if(!saveCookiePageLevel){jQuery.cookie.defaults={path:'/'};}
70
- var currentCookie=jQuery.cookie('sgPopupDetails'+that.popupData['id']);if(typeof currentCookie=='undefined'){var openCounter=1;}
71
- else{var currentCookie=JSON.parse(jQuery.cookie('sgPopupDetails'+that.popupData['id']));var openCounter=currentCookie.openCounter+=1;}
72
- sgCookieData={'popupId':that.popupData['id'],'openCounter':openCounter,'openLimit':that.numberLimit};jQuery.cookie("sgPopupDetails"+that.popupData['id'],JSON.stringify(sgCookieData),{expires:onceExpiresTime});}
73
- if(that.popupContentClick){jQuery("#sgcolorbox").bind("sgColorboxOnCompleate",function(){if((contentClickBehavior!=='close'||clickRedirectToUrl!=='')&&typeof contentClickBehavior!=='undefined'){jQuery('#sgcolorbox').css({"cursor":'pointer'});}
74
- jQuery(".sg-current-popup-"+that.popupData['id']).bind('click',function(){if(contentClickBehavior=='close'||clickRedirectToUrl==''||typeof contentClickBehavior=='undefined'){jQuery.sgcolorbox.close();}
75
- else{if(!redirectToNewTab){window.location=clickRedirectToUrl;}
76
- else{window.open(clickRedirectToUrl);}}});});}
77
- jQuery('#sgcolorbox').bind('sgPopupClose',function(e){that.sgEventExecuteCount=0;that.eventExecuteCountByClass=0;jQuery('#sgcolorbox').removeClass(customClassName);jQuery('#sgcboxOverlay').removeClass(customClassName);jQuery('#sgcolorbox').removeClass(popupEffect);});},this.popupData['delay']*1000);};jQuery(document).ready(function($){var popupObj=new SGPopup();popupObj.init();});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function 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
+
23
+ this.sgColorboxContentTypeReset();
24
+ }
25
+
26
+ SGPopup.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*/
37
+ SGPopup.sgColorBoxDeafults = {1 : 70, 2: 34, 3: 30, 4 : 70, 5 : 62, 6: 70};
38
+
39
+ SGPopup.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
+
56
+ SGPopup.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
+
72
+ SGPopup.deleteCookie = function (name) {
73
+
74
+ document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
75
+ };
76
+
77
+ SGPopup.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.toUTCString();
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
+
104
+ SGPopup.prototype.init = function () {
105
+
106
+ var that = this;
107
+
108
+ this.onCompleate();
109
+ this.popupOpenByCookie();
110
+ this.attacheShortCodeEvent();
111
+ this.attacheClickEvent();
112
+ this.attacheIframeEvent();
113
+ this.attacheConfirmEvent();
114
+ this.popupClassEventsTrigger();
115
+ };
116
+
117
+ SGPopup.prototype.attacheShortCodeEvent = function () {
118
+
119
+ var that = this;
120
+
121
+ jQuery(".sg-show-popup").each(function () {
122
+ var popupEvent = jQuery(this).attr("data-popup-event");
123
+ if (typeof popupEvent == 'undefined') {
124
+ popupEvent = 'click';
125
+ }
126
+ /* For counting execute and did it one time for popup open */
127
+ that.sgEventExecuteCount = 0;
128
+ jQuery(this).bind(popupEvent, function () {
129
+ that.sgEventExecuteCount += 1;
130
+ if (that.sgEventExecuteCount > 1) {
131
+ return;
132
+ }
133
+ var sgPopupID = jQuery(this).attr("data-sgpopupid");
134
+ that.showPopup(sgPopupID, false);
135
+ });
136
+ });
137
+ };
138
+
139
+ SGPopup.prototype.attacheConfirmEvent = function () {
140
+
141
+ var that = this;
142
+
143
+ jQuery("[class*='sg-confirm-popup-']").each(function () {
144
+ jQuery(this).bind("click", function (e) {
145
+ e.preventDefault();
146
+ var currentLink = jQuery(this);
147
+ var className = jQuery(this).attr("class");
148
+
149
+ var sgPopupId = that.findPopupIdFromClassNames(className, "sg-confirm-popup-");
150
+
151
+ jQuery('#sgcolorbox').bind("sgPopupClose", function () {
152
+ var target = currentLink.attr("target");
153
+
154
+ if (typeof target == 'undefined') {
155
+ target = "self";
156
+ }
157
+ var href = currentLink.attr("href");
158
+
159
+ if (target == "_blank") {
160
+ window.open(href);
161
+ }
162
+ else {
163
+ window.location.href = href;
164
+ }
165
+ });
166
+ that.showPopup(sgPopupId, false);
167
+ })
168
+ });
169
+ };
170
+
171
+ SGPopup.prototype.attacheIframeEvent = function () {
172
+
173
+ var that = this;
174
+ /* When user set popup by class name */
175
+ jQuery("[class*='sg-iframe-popup-']").each(function () {
176
+ var currentLink = jQuery(this);
177
+ jQuery(this).bind("click", function (e) {
178
+ e.preventDefault();
179
+ var className = jQuery(this).attr("class");
180
+
181
+ var sgPopupId = that.findPopupIdFromClassNames(className, "sg-iframe-popup-");
182
+
183
+ /*This update for dynamic open iframe url for same popup*/
184
+ var linkUrl = currentLink.attr("href");
185
+
186
+ if (typeof linkUrl == 'undefined') {
187
+ var childLinkTag = currentLink.find('a');
188
+ linkUrl = childLinkTag.attr("href");
189
+ }
190
+
191
+ SG_POPUP_DATA[sgPopupId]['iframe'] = linkUrl;
192
+
193
+ that.showPopup(sgPopupId, false);
194
+ });
195
+ });
196
+ };
197
+
198
+ SGPopup.prototype.attacheClickEvent = function () {
199
+
200
+ var that = this;
201
+ /* When user set popup by class name */
202
+ jQuery("[class*='sg-popup-id-']").each(function () {
203
+ jQuery(this).bind("click", function (e) {
204
+ e.preventDefault();
205
+ var className = jQuery(this).attr("class");
206
+ var sgPopupId = that.findPopupIdFromClassNames(className, "sg-popup-id-");
207
+
208
+ that.showPopup(sgPopupId, false);
209
+ })
210
+ });
211
+ };
212
+
213
+ SGPopup.prototype.popupClassEventsTrigger = function () {
214
+
215
+ var popupEvents = this.popupClassEvents;
216
+ var that = this;
217
+
218
+ if(popupEvents.length > 0) {
219
+
220
+ for (var i in popupEvents) {
221
+ var eventName = popupEvents[i];
222
+
223
+ that.attacheCustomEvent(eventName);
224
+ }
225
+ }
226
+ };
227
+
228
+ SGPopup.prototype.attacheCustomEvent = function (eventName) {
229
+
230
+ if(typeof eventName == 'undefined' || eventName == '' ) {
231
+ return;
232
+ }
233
+ var that = this;
234
+
235
+ jQuery("[class*='sg-popup-"+eventName+"-']").each(function () {
236
+ var eventCount = that.eventExecuteCountByClass;
237
+ jQuery(this).bind(eventName, function () {
238
+ eventCount = ++that.eventExecuteCountByClass;
239
+ if (eventCount > 1) {
240
+ return;
241
+ }
242
+ var className = jQuery(this).attr("class");
243
+ var sgPopupId = that.findPopupIdFromClassNames(className, 'sg-popup-'+eventName+'-');
244
+
245
+ that.showPopup(sgPopupId, false);
246
+ })
247
+ });
248
+ };
249
+
250
+ SGPopup.prototype.popupOpenByCookie = function () {
251
+
252
+ var popupId = SGPopup.getCookie("sgSubmitReloadingForm");
253
+ popupId = parseInt(popupId);
254
+
255
+ if (typeof popupId == 'number') {
256
+ this.showPopup(popupId, false);
257
+ }
258
+ };
259
+
260
+ SGPopup.prototype.findPopupIdFromClassNames = function (className, classKey) {
261
+
262
+ var classSplitArray = className.split(classKey);
263
+ var classIdString = classSplitArray['1'];
264
+ /*Get first all number from string*/
265
+ var popupId = classIdString.match(/^\d+/);
266
+
267
+ return popupId;
268
+ };
269
+
270
+ SGPopup.prototype.hexToRgba = function (hex, opacity){
271
+
272
+ var c;
273
+ if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
274
+ c = hex.substring(1).split('');
275
+
276
+ if(c.length == 3){
277
+ c= [c[0], c[0], c[1], c[1], c[2], c[2]];
278
+ }
279
+ c = '0x'+c.join('');
280
+ return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')';
281
+ }
282
+ throw new Error('Bad Hex');
283
+ };
284
+
285
+
286
+ SGPopup.prototype.sgCustomizeThemes = function (popupId) {
287
+
288
+ var popupData = SG_POPUP_DATA[popupId];
289
+ var borderRadiues = popupData['sg3ThemeBorderRadiues'];
290
+ var popupContentOpacity = popupData['popup-background-opacity'];
291
+ var popupContentColor = jQuery('#sgcboxContent').css('background-color');
292
+ var contentBackgroundColor = popupData['sg-content-background-color'];
293
+ var changedColor = popupContentColor.replace(')', ', '+popupContentOpacity+')').replace('rgb', 'rgba');
294
+
295
+ if(contentBackgroundColor != '') {
296
+ changedColor = this.hexToRgba(contentBackgroundColor, popupContentOpacity);
297
+ }
298
+
299
+
300
+ if (popupData['theme'] == "colorbox3.css") {
301
+ var borderColor = popupData['sgTheme3BorderColor'];
302
+ var borderRadiues = popupData['sgTheme3BorderRadius'];
303
+ jQuery("#sgcboxLoadedContent").css({'border-color': borderColor});
304
+ jQuery("#sgcboxLoadedContent").css({'border-radius': borderRadiues + "%"});
305
+ jQuery("#sgcboxContent").css({'border-radius': borderRadiues + "%"})
306
+ }
307
+
308
+ jQuery('#sgcboxContent').css({'background-color': changedColor});
309
+ jQuery('#sgcboxLoadedContent').css({'background-color': changedColor})
310
+
311
+ };
312
+
313
+ SGPopup.prototype.onCompleate = function () {
314
+
315
+ jQuery("#sgcolorbox").bind("sgColorboxOnCompleate", function () {
316
+
317
+ /* Scroll only inside popup */
318
+ jQuery('#sgcboxLoadedContent').isolatedScroll();
319
+ });
320
+ this.isolatedScroll();
321
+ };
322
+
323
+ SGPopup.prototype.isolatedScroll = function () {
324
+
325
+ jQuery.fn.isolatedScroll = function () {
326
+ this.bind('mousewheel DOMMouseScroll', function (e) {
327
+ var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,
328
+ bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,
329
+ topOverflow = this.scrollTop <= 0;
330
+
331
+ if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
332
+ e.preventDefault();
333
+ }
334
+ });
335
+ return this;
336
+ };
337
+ };
338
+
339
+ SGPopup.prototype.sgPopupScalingDimensions = function () {
340
+
341
+ var popupWrapper = jQuery("#sgcboxWrapper").outerWidth();
342
+ var screenWidth = jQuery(window).width();
343
+ /*popupWrapper != 9999 for resizing case when colorbox is calculated popup dimensions*/
344
+ if (popupWrapper > screenWidth && popupWrapper != 9999) {
345
+ var scaleDegree = screenWidth / popupWrapper;
346
+ jQuery("#sgcboxWrapper").css({
347
+ "transform-origin": "0 0 !important",
348
+ 'transform': "scale(" + scaleDegree + ", 1)"
349
+ });
350
+ popupWrapper = 0;
351
+ }
352
+ else {
353
+ jQuery("#sgcboxWrapper").css({
354
+ "transform-origin": "0 0 !important",
355
+ 'transform': "scale(1, 1)"
356
+ })
357
+ }
358
+ };
359
+
360
+ SGPopup.prototype.sgPopupScaling = function () {
361
+
362
+ var that = this;
363
+ jQuery("#sgcolorbox").bind("sgColorboxOnCompleate", function () {
364
+ that.sgPopupScalingDimensions();
365
+ });
366
+ jQuery(window).resize(function () {
367
+ setTimeout(function () {
368
+ that.sgPopupScalingDimensions();
369
+ }, 1000);
370
+ });
371
+ };
372
+
373
+ SGPopup.prototype.varToBool = function (optionName) {
374
+
375
+ var returnValue = (optionName) ? true : false;
376
+ return returnValue;
377
+ };
378
+
379
+ SGPopup.prototype.canOpenPopup = function (id, openOnce, isOnLoad) {
380
+
381
+ if (!isOnLoad) {
382
+ return true;
383
+ }
384
+
385
+ var currentCookies = SGPopup.getCookie('sgPopupCookieList');
386
+ if (currentCookies) {
387
+ currentCookies = JSON.parse(currentCookies);
388
+
389
+ for (var cookieIndex in currentCookies) {
390
+ var cookieName = currentCookies[cookieIndex];
391
+ var cookieData = SGPopup.getCookie(cookieName + id);
392
+
393
+ if (cookieData) {
394
+ return false;
395
+ }
396
+ }
397
+ }
398
+
399
+ var popupCookie = SGPopup.getCookie('sgPopupDetails' + id);
400
+ var popupType = this.popupType;
401
+
402
+ /*for popup this often case */
403
+ if (openOnce && popupCookie != '') {
404
+ return this.canOpenOnce(id);
405
+ }
406
+
407
+ return true;
408
+ };
409
+
410
+ SGPopup.prototype.canOpenOnce = function(id) {
411
+
412
+ var cookieData = SGPopup.getCookie('sgPopupDetails'+id);
413
+ if(!cookieData) {
414
+ return true;
415
+ }
416
+ var cookieData = JSON.parse(cookieData);
417
+
418
+ if(cookieData.popupId == id && cookieData.openCounter >= this.numberLimit) {
419
+ return false;
420
+ }
421
+ else {
422
+ return true
423
+ }
424
+
425
+ };
426
+
427
+
428
+ SGPopup.prototype.setFixedPosition = function (sgPositionLeft, sgPositionTop, sgPositionBottom, sgPositionRight, sgFixedPositionTop, sgFixedPositionLeft) {
429
+
430
+ this.positionLeft = sgPositionLeft;
431
+ this.positionTop = sgPositionTop;
432
+ this.positionBottom = sgPositionBottom;
433
+ this.positionRight = sgPositionRight;
434
+ this.initialPositionTop = sgFixedPositionTop;
435
+ this.initialPositionLeft = sgFixedPositionLeft;
436
+ };
437
+
438
+ SGPopup.prototype.percentToPx = function (percentDimention, screenDimension) {
439
+
440
+ var dimension = parseInt(percentDimention) * screenDimension / 100;
441
+ return dimension;
442
+ };
443
+
444
+ SGPopup.prototype.getPositionPercent = function (needPercent, screenDimension, dimension) {
445
+
446
+ var sgPosition = (((this.percentToPx(needPercent, screenDimension) - dimension / 2) / screenDimension) * 100) + "%";
447
+ return sgPosition;
448
+ };
449
+
450
+ SGPopup.prototype.showPopup = function (id, isOnLoad) {
451
+
452
+ var that = this;
453
+
454
+ /*When id does not exist*/
455
+ if (!id) {
456
+ return;
457
+ }
458
+
459
+ this.popupData = SG_POPUP_DATA[id];
460
+ if (typeof this.popupData == "undefined") {
461
+ return;
462
+ }
463
+ this.popupType = this.popupData['type'];
464
+ this.isOnLoad = isOnLoad;
465
+ this.openOnce = this.varToBool(this.popupData['repeatPopup']);
466
+ this.numberLimit = this.popupData['popup-appear-number-limit'];
467
+
468
+ if (typeof that.removeCookie !== 'undefined') {
469
+ that.removeCookie(this.openOnce);
470
+ }
471
+
472
+ if (!this.canOpenPopup(this.popupData['id'], this.openOnce, isOnLoad)) {
473
+ return;
474
+ }
475
+
476
+ popupColorboxUrl = SG_APP_POPUP_URL + '/style/sgcolorbox/sgthemes.css';
477
+ head = document.getElementsByTagName('head')[0];
478
+ link = document.createElement('link');
479
+ link.type = "text/css";
480
+ link.id = "sg_colorbox_theme-css";
481
+ link.rel = "stylesheet";
482
+ link.href = popupColorboxUrl;
483
+ document.getElementsByTagName('head')[0].appendChild(link);
484
+ var img = document.createElement('img');
485
+ sgAddEvent(img, "error", function () {
486
+ that.sgShowColorboxWithOptions();
487
+ });
488
+ setTimeout(function () {
489
+ img.src = popupColorboxUrl;
490
+ }, 0);
491
+ };
492
+
493
+ SGPopup.setToPopupsCookiesList = function (cookieName) {
494
+
495
+ var currentCookies = SGPopup.getCookie('sgPopupCookieList');
496
+
497
+ if (!currentCookies) {
498
+ currentCookies = [];
499
+ }
500
+ else {
501
+ currentCookies = JSON.parse(currentCookies);
502
+ }
503
+
504
+ if (jQuery.inArray(cookieName, currentCookies) == -1) {
505
+ cookieName = currentCookies.push(cookieName);
506
+ }
507
+
508
+ SGPopup.deleteCookie('sgPopupCookieList');
509
+ var currentCookies = JSON.stringify(currentCookies);
510
+ SGPopup.setCookie('sgPopupCookieList', currentCookies, 365, true);
511
+ };
512
+
513
+ SGPopup.prototype.popupThemeDefaultMeasure = function () {
514
+
515
+ var themeName = this.popupData['theme'];
516
+ var defaults = SGPopup.sgColorBoxDeafults;
517
+ /*return theme id*/
518
+ var themeId = themeName.replace( /(^.+\D)(\d+)(\D.+$)/i,'$2');
519
+
520
+ return defaults[themeId];
521
+ };
522
+
523
+ SGPopup.prototype.changePopupSettings = function () {
524
+
525
+ var popupData = this.popupData;
526
+ var popupDimensionMode = popupData['popup-dimension-mode'];
527
+ var maxWidth = popupData['maxWidth'];
528
+ var popupResponsiveDimensionMeasure = popupData['popup-responsive-dimension-measure'];
529
+ if(popupDimensionMode == 'responsiveMode') {
530
+
531
+ if(popupResponsiveDimensionMeasure == 'auto') {
532
+ if(!maxWidth) {
533
+ this.popupMaxWidth = '100%';
534
+ }
535
+ }
536
+ }
537
+ };
538
+
539
+ SGPopup.prototype.resizeDimension = function () {
540
+
541
+ var resizeTimer;
542
+ var themeDefault = this.popupThemeDefaultMeasure();
543
+ var responsiveMeasure = this.popupData['popup-responsive-dimension-measure'];
544
+ var windowWidth = jQuery(window).width();
545
+ var popupWidth = jQuery("#sgcolorbox").width();
546
+
547
+
548
+
549
+ function resizeColorBox() {
550
+ var sgColorBoxWidth = jQuery("#sgcolorbox").width();
551
+ var isPopupLargerThanWindow = sgColorBoxWidth > windowWidth;
552
+ jQuery(window).unbind('resize.sgcbox');
553
+
554
+ if (resizeTimer) clearTimeout(resizeTimer);
555
+ resizeTimer = setTimeout(function() {
556
+ if (jQuery('#sgcboxOverlay').is(':visible')) {
557
+ var width = jQuery(window).width();
558
+ var contentHeight = jQuery('#sgcboxLoadedContent')[0].scrollHeight+themeDefault;
559
+
560
+ var contentWidth = jQuery.sgcolorbox.settings.width;
561
+
562
+ /*For tablet case*/
563
+ if( width >= 768 && width <= 959 && isPopupLargerThanWindow) {
564
+ contentWidth = '82%';
565
+ }
566
+ else if( width >= 480 && width <= 767 && isPopupLargerThanWindow) {
567
+ /*For >= iphone 5s*/
568
+ contentWidth = '88%';
569
+ }
570
+ else if( width <= 479 && isPopupLargerThanWindow) {
571
+ /*For small devices*/
572
+ contentWidth = '94%';
573
+ }
574
+ else {
575
+ contentWidth = responsiveMeasure+'%';
576
+ }
577
+
578
+ if(responsiveMeasure == 'auto' && !isPopupLargerThanWindow) {
579
+ jQuery.sgcolorbox.resize();
580
+ return;
581
+ }
582
+
583
+ jQuery.sgcolorbox.settings.width = contentWidth;
584
+
585
+ jQuery.sgcolorbox.sgpbResize({
586
+ 'width': contentWidth,
587
+ 'height': contentHeight
588
+ });
589
+ }
590
+ }, 350)
591
+ }
592
+
593
+ jQuery(window).resize(resizeColorBox);
594
+ window.addEventListener("orientationchange", resizeColorBox, false);
595
+ };
596
+
597
+ SGPopup.prototype.sgColorboxContentMode = function() {
598
+
599
+ var that = this;
600
+
601
+ this.sgColorboxContentTypeReset();
602
+ var popupType = this.popupData['type'];
603
+ var popupHtml = (this.popupData['html'] == '') ? '&nbsp;' : this.popupData['html'];
604
+ var popupImage = this.popupData['image'];
605
+ var popupIframeUrl = this.popupData['iframe'];
606
+ var popupVideo = this.popupData['video'];
607
+ var popupId = this.popupData['id'];
608
+
609
+ popupImage = (popupImage) ? popupImage : false;
610
+ popupVideo = (popupVideo) ? popupVideo : false;
611
+ popupIframeUrl = (popupIframeUrl) ? popupIframeUrl : false;
612
+
613
+ if(popupType == 'image') {
614
+ this.sgColorboxPhoto = true;
615
+ this.sgColorboxHref = popupImage;
616
+ }
617
+
618
+ if(popupIframeUrl) {
619
+ this.sgColorboxIframe = true;
620
+ this.sgColorboxHref = popupIframeUrl;
621
+ }
622
+
623
+ if(popupVideo) {
624
+ this.sgColorboxIframe = true;
625
+ this.sgColorboxHref = popupVideo;
626
+ }
627
+
628
+ /*this condition jQuery('#sg-popup-content-wrapper-'+popupId).length != 0 for backward compatibility*/
629
+ if(popupHtml && jQuery('#sg-popup-content-wrapper-'+popupId).length != 0) {
630
+ this.sgColorboxInline = true;
631
+ this.sgColorboxHref = '#sg-popup-content-wrapper-'+popupId;
632
+ }
633
+ else {
634
+ this.sgColorboxHtml = popupHtml;
635
+ }
636
+ };
637
+
638
+ SGPopup.prototype.sgShowColorboxWithOptions = function () {
639
+
640
+ var that = this;
641
+ setTimeout(function () {
642
+
643
+ var sgPopupFixed = that.varToBool(that.popupData['popupFixed']);
644
+ var popupId = that.popupData['id'];
645
+ that.popupOverlayClose = that.varToBool(that.popupData['overlayClose']);
646
+ that.popupContentClick = that.varToBool(that.popupData['contentClick']);
647
+ var popupReposition = that.varToBool(that.popupData['reposition']);
648
+ var popupScrolling = that.varToBool(that.popupData['scrolling']);
649
+ var popupScaling = that.varToBool(that.popupData['scaling']);
650
+ that.popupEscKey = that.varToBool(that.popupData['escKey']);
651
+ that.popupCloseButton = that.varToBool(that.popupData['closeButton']);
652
+ var countryStatus = that.varToBool(that.popupData['countryStatus']);
653
+ var popupForMobile = that.varToBool(that.popupData['forMobile']);
654
+ var onlyMobile = that.varToBool(that.popupData['openMobile']);
655
+ var popupCantClose = that.varToBool(that.popupData['disablePopup']);
656
+ var disablePopupOverlay = that.varToBool(that.popupData['disablePopupOverlay']);
657
+ var popupAutoClosePopup = that.varToBool(that.popupData['autoClosePopup']);
658
+ var saveCookiePageLevel = that.varToBool(that.popupData['save-cookie-page-level']);
659
+ var popupClosingTimer = that.popupData['popupClosingTimer'];
660
+
661
+ if (popupScaling) {
662
+ that.sgPopupScaling();
663
+ }
664
+ if (popupCantClose) {
665
+ that.cantPopupClose();
666
+ }
667
+ that.popupMaxWidth = that.popupData['maxWidth'];
668
+ var popupPosition = that.popupData['fixedPostion'];
669
+ var popupVideo = that.popupData['video'];
670
+ var popupOverlayColor = that.popupData['sgOverlayColor'];
671
+ var contentBackgroundColor = that.popupData['sg-content-background-color'];
672
+ var popupDimensionMode = that.popupData['popup-dimension-mode'];
673
+ var popupResponsiveDimensionMeasure = that.popupData['popup-responsive-dimension-measure'];
674
+ var popupWidth = that.popupData['width'];
675
+ var popupHeight = that.popupData['height'];
676
+ var popupOpacity = that.popupData['opacity'];
677
+ var popupMaxHeight = that.popupData['maxHeight'];
678
+ var popupInitialWidth = that.popupData['initialWidth'];
679
+ var popupInitialHeight = that.popupData['initialHeight'];
680
+ var popupEffectDuration = that.popupData['duration'];
681
+ var popupEffect = that.popupData['effect'];
682
+ var contentClickBehavior = that.popupData['content-click-behavior'];
683
+ var clickRedirectToUrl = that.popupData['click-redirect-to-url'];
684
+ var redirectToNewTab = that.popupData['redirect-to-new-tab'];
685
+ var pushToBottom = that.popupData['pushToBottom'];
686
+ var onceExpiresTime = parseInt(that.popupData['onceExpiresTime']);
687
+ var sgType = that.popupData['type'];
688
+ var overlayCustomClass = that.popupData['sgOverlayCustomClasss'];
689
+ var contentCustomClass = that.popupData['sgContentCustomClasss'];
690
+ var popupTheme = that.popupData['theme'];
691
+ var themeStringLength = popupTheme.length;
692
+ var customClassName = popupTheme.substring(0, themeStringLength - 4);
693
+ var closeButtonText = that.popupData['theme-close-text'];
694
+
695
+ that.sgColorboxContentMode();
696
+
697
+ if(popupDimensionMode == 'responsiveMode') {
698
+
699
+ popupWidth = '';
700
+ if(popupResponsiveDimensionMeasure != 'auto') {
701
+ popupWidth = parseInt(popupResponsiveDimensionMeasure)+'%';
702
+ }
703
+ popupHeight = '';
704
+ }
705
+
706
+ if (popupVideo) {
707
+ if (popupWidth == '') {
708
+ popupWidth = '50%';
709
+ }
710
+ if (popupHeight == '') {
711
+ popupHeight = '50%';
712
+ }
713
+ }
714
+ var sgScreenWidth = jQuery(window).width();
715
+ var sgScreenHeight = jQuery(window).height();
716
+
717
+ var sgIsWidthInPercent = popupWidth.indexOf("%");
718
+ var sgIsHeightInPercent = popupHeight.indexOf("%");
719
+ var sgPopupHeightPx = popupHeight;
720
+ var sgPopupWidthPx = popupWidth;
721
+ if (sgIsWidthInPercent != -1) {
722
+ sgPopupWidthPx = that.percentToPx(popupWidth, sgScreenWidth);
723
+ }
724
+ if (sgIsHeightInPercent != -1) {
725
+ sgPopupHeightPx = that.percentToPx(popupHeight, sgScreenHeight);
726
+ }
727
+ /*for when width or height in px*/
728
+ sgPopupWidthPx = parseInt(sgPopupWidthPx);
729
+ sgPopupHeightPx = parseInt(sgPopupHeightPx);
730
+
731
+ var popupPositionTop = that.getPositionPercent("50%", sgScreenHeight, sgPopupHeightPx);
732
+ var popupPositionLeft = that.getPositionPercent("50%", sgScreenWidth, sgPopupWidthPx);
733
+
734
+ if (popupPosition == 1) { // Left Top
735
+ that.setFixedPosition('0%', '3%', false, false, 0, 0);
736
+ }
737
+ else if (popupPosition == 2) { // Left Top
738
+ that.setFixedPosition(popupPositionLeft, '3%', false, false, 0, 50);
739
+ }
740
+ else if (popupPosition == 3) { //Right Top
741
+ that.setFixedPosition(false, '3%', false, '0%', 0, 90);
742
+ }
743
+ else if (popupPosition == 4) { // Left Center
744
+ that.setFixedPosition('0%', popupPositionTop, false, false, popupPositionTop, 0);
745
+ }
746
+ else if (popupPosition == 5) { // center Center
747
+ sgPopupFixed = true;
748
+ that.setFixedPosition(false, false, false, false, 50, 50);
749
+ }
750
+ else if (popupPosition == 6) { // Right Center
751
+ that.setFixedPosition('0%', popupPositionTop, false, '0%', 50, 90);
752
+ }
753
+ else if (popupPosition == 7) { // Left Bottom
754
+ that.setFixedPosition('0%', false, '0%', false, 90, 0);
755
+ }
756
+ else if (popupPosition == 8) { // Center Bottom
757
+ that.setFixedPosition(popupPositionLeft, false, '0%', false, 90, 50);
758
+ }
759
+ else if (popupPosition == 9) { // Right Bottom
760
+ that.setFixedPosition(false, false, '0%', '0%', 90, 90);
761
+ }
762
+ if (!sgPopupFixed) {
763
+ that.setFixedPosition(false, false, false, false, 50, 50);
764
+ }
765
+
766
+ var userDevice = false;
767
+ if (popupForMobile) {
768
+ userDevice = that.forMobile();
769
+ }
770
+
771
+ if (popupAutoClosePopup) {
772
+ setTimeout(that.autoClosePopup, popupClosingTimer * 1000);
773
+ }
774
+
775
+ if (disablePopupOverlay) {
776
+ that.sgTrapFocus = false;
777
+ that.disablePopupOverlay();
778
+ }
779
+
780
+ if (onlyMobile) {
781
+ var openOnlyMobile = false;
782
+ openOnlyMobile = that.forMobile();
783
+ if (openOnlyMobile == false) {
784
+ return;
785
+ }
786
+ }
787
+
788
+ if (userDevice) {
789
+ return;
790
+ }
791
+ that.changePopupSettings();
792
+ SG_POPUP_SETTINGS = {
793
+ popupId: popupId,
794
+ html: that.sgColorboxHtml,
795
+ photo: that.sgColorboxPhoto,
796
+ iframe: that.sgColorboxIframe,
797
+ href: that.sgColorboxHref,
798
+ inline: that.sgColorboxInline,
799
+ width: popupWidth,
800
+ height: popupHeight,
801
+ className: customClassName,
802
+ close: closeButtonText,
803
+ overlayCutsomClassName: overlayCustomClass,
804
+ contentCustomClassName: contentCustomClass,
805
+ onOpen: function () {
806
+ jQuery('#sgcolorbox').removeAttr('style');
807
+ jQuery('#sgcolorbox').removeAttr('left');
808
+ jQuery('#sgcolorbox').css('top', '' + that.initialPositionTop + '%');
809
+ jQuery('#sgcolorbox').css('left', '' + that.initialPositionLeft + '%');
810
+ jQuery('#sgcolorbox').css('animation-duration', popupEffectDuration + "s");
811
+ jQuery('#sgcolorbox').css('-webkit-animation-duration', popupEffectDuration + "s");
812
+ jQuery("#sgcolorbox").addClass('sg-animated ' + popupEffect + '');
813
+ jQuery("#sgcboxOverlay").addClass("sgcboxOverlayBg");
814
+ jQuery("#sgcboxOverlay").removeAttr('style');
815
+
816
+ if (popupOverlayColor) {
817
+ jQuery("#sgcboxOverlay").css({'background': 'none', 'background-color': popupOverlayColor});
818
+ }
819
+
820
+ jQuery('#sgcolorbox').trigger("sgColorboxOnOpen", []);
821
+
822
+ },
823
+ onLoad: function () {
824
+ },
825
+ onComplete: function () {
826
+ if (contentBackgroundColor) {
827
+ jQuery("#sgcboxLoadedContent").css({'background-color': contentBackgroundColor});
828
+ }
829
+ jQuery("#sgcboxLoadedContent").addClass("sg-current-popup-" + that.popupData['id']);
830
+ jQuery('#sgcolorbox').trigger("sgColorboxOnCompleate", [pushToBottom]);
831
+
832
+ var sgpopupInit = new SgPopupInit(that.popupData);
833
+ sgpopupInit.overallInit();
834
+ /* For specific popup Like Countdown AgeRestcion popups */
835
+ sgpopupInit.initByPopupType();
836
+ that.sgCustomizeThemes(that.popupData['id']);
837
+ if(popupDimensionMode == 'responsiveMode') {
838
+ that.resizeDimension();
839
+ }
840
+ },
841
+ onCleanup: function () {
842
+ jQuery('#sgcolorbox').trigger("sgPopupCleanup", []);
843
+ },
844
+ onClosed: function () {
845
+ jQuery("#sgcboxLoadedContent").removeClass("sg-current-popup-" + that.popupData['id']);
846
+ jQuery('#sgcolorbox').trigger("sgPopupClose", []);
847
+ },
848
+ trapFocus: that.sgTrapFocus,
849
+ opacity: popupOpacity,
850
+ escKey: that.popupEscKey,
851
+ closeButton: that.popupCloseButton,
852
+ fixed: sgPopupFixed,
853
+ top: that.positionTop,
854
+ bottom: that.positionBottom,
855
+ left: that.positionLeft,
856
+ right: that.positionRight,
857
+ scrolling: popupScrolling,
858
+ reposition: popupReposition,
859
+ overlayClose: that.popupOverlayClose,
860
+ maxWidth: that.popupMaxWidth,
861
+ maxHeight: popupMaxHeight,
862
+ initialWidth: popupInitialWidth,
863
+ initialHeight: popupInitialHeight
864
+ };
865
+
866
+ if(popupDimensionMode == 'responsiveMode') {
867
+ /*colorbox open speed*/
868
+ SG_POPUP_SETTINGS.speed = 10;
869
+ }
870
+ jQuery.sgcolorbox(SG_POPUP_SETTINGS);
871
+
872
+
873
+ if (countryStatus == true && typeof SgUserData != "undefined") {
874
+ jQuery.cookie("SG_POPUP_USER_COUNTRY_NAME", SgUserData.countryIsoName, {expires: 365});
875
+ }
876
+ /* Cookie can't be set here as it's set in Age Restriction popup when the user clicks "yes" */
877
+ if (that.popupData['id'] && that.isOnLoad == true && that.openOnce != '' && that.popupData['type'] != "ageRestriction") {
878
+ var sgCookieData = '';
879
+
880
+ var currentCookie = SGPopup.getCookie('sgPopupDetails' + that.popupData['id']);
881
+
882
+ if (!currentCookie) {
883
+ var openCounter = 1;
884
+ }
885
+ else {
886
+ var currentCookie = JSON.parse(currentCookie);
887
+ var openCounter = currentCookie.openCounter += 1;
888
+ }
889
+ sgCookieData = {
890
+ 'popupId': that.popupData['id'],
891
+ 'openCounter': openCounter,
892
+ 'openLimit': that.numberLimit
893
+ };
894
+
895
+ /*!saveCookiePageLevel it's mean for all site level*/
896
+ SGPopup.setCookie("sgPopupDetails"+that.popupData['id'],JSON.stringify(sgCookieData), onceExpiresTime, !saveCookiePageLevel);
897
+ }
898
+
899
+ if (that.popupContentClick) {
900
+ jQuery("#sgcolorbox").bind("sgColorboxOnCompleate", function () {
901
+ /* If has url for redirect */
902
+ if ((contentClickBehavior !== 'close' || clickRedirectToUrl !== '') && typeof contentClickBehavior !== 'undefined') {
903
+ jQuery('#sgcolorbox').css({
904
+ "cursor": 'pointer'
905
+ });
906
+ }
907
+
908
+ jQuery(".sg-current-popup-" + that.popupData['id']).bind('click', function () {
909
+ if (contentClickBehavior == 'close' || clickRedirectToUrl == '' || typeof contentClickBehavior == 'undefined') {
910
+ jQuery.sgcolorbox.close();
911
+ }
912
+ else {
913
+ if (!redirectToNewTab) {
914
+ window.location = clickRedirectToUrl;
915
+ }
916
+ else {
917
+ window.open(clickRedirectToUrl);
918
+ }
919
+ }
920
+
921
+ });
922
+ });
923
+ }
924
+
925
+ jQuery('#sgcolorbox').bind('sgPopupClose', function (e) {
926
+ /* reset event execute count for popup open */
927
+ that.sgEventExecuteCount = 0;
928
+ that.eventExecuteCountByClass = 0;
929
+ jQuery('#sgcolorbox').removeClass(customClassName);
930
+ /* Remove custom class for another popup */
931
+ jQuery('#sgcboxOverlay').removeClass(customClassName);
932
+ jQuery('#sgcolorbox').removeClass(popupEffect);
933
+ /* Remove animated effect for another popup */
934
+ });
935
+
936
+ }, this.popupData['delay'] * 1000);
937
+ };
938
+
939
+ jQuery(document).ready(function ($) {
940
+
941
+ var popupObj = new SGPopup();
942
+ popupObj.init();
943
+ });
popup-builder.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: http://sygnoos.com
5
  * Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
6
- * Version: 2.5.7
7
  * Author: Sygnoos
8
  * Author URI: http://www.sygnoos.com
9
  * License: GPLv2
@@ -366,7 +366,6 @@ function sgOnloadPopup()
366
 
367
  /* $popupsId[0] its last selected popup id */
368
  if(isset($popupsId[0])) {
369
- delete_option("SG_MULTIPLE_POPUP");
370
  if(count($popupsId) > 0) {
371
  update_option("SG_MULTIPLE_POPUP",$popupsId);
372
  }
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: http://sygnoos.com
5
  * Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
6
+ * Version: 2.5.8
7
  * Author: Sygnoos
8
  * Author URI: http://www.sygnoos.com
9
  * License: GPLv2
366
 
367
  /* $popupsId[0] its last selected popup id */
368
  if(isset($popupsId[0])) {
 
369
  if(count($popupsId) > 0) {
370
  update_option("SG_MULTIPLE_POPUP",$popupsId);
371
  }
readme.txt CHANGED
@@ -159,6 +159,11 @@ Go to the Popup Builder settings and set your desired options.
159
 
160
  == Changelog ==
161
 
 
 
 
 
 
162
  = Version 2.5.7 =
163
  * Bug fixed connected to popup On/Off switch button.
164
  * PHP notices fixed.
@@ -623,7 +628,7 @@ Leave us a good review :)
623
 
624
  == Upgrade Notice ==
625
 
626
- Current Version of Popup Builder is 2.5.6
627
 
628
  == Other Notes ==
629
 
159
 
160
  == Changelog ==
161
 
162
+ = Version 2.5.8 =
163
+ * Tweak: Added option to control popup opening count.
164
+ * Bug fixed connected to banner `Don’t show again button` button.
165
+ * Code improvements.
166
+
167
  = Version 2.5.7 =
168
  * Bug fixed connected to popup On/Off switch button.
169
  * PHP notices fixed.
628
 
629
  == Upgrade Notice ==
630
 
631
+ Current Version of Popup Builder is 2.5.8
632
 
633
  == Other Notes ==
634