Popup Builder – Responsive WordPress Pop up - Version 3.0.3

Version Description

Current Version of Popup Builder is 2.6.7

Download this release

Release Info

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

Code changes from version 3.0.2 to 3.0.3

com/classes/PopupLoader.php CHANGED
@@ -89,7 +89,7 @@ class PopupLoader
89
  }
90
  if (!empty($foundPopup)) {
91
  global $SGPB_DATA_CONFIG_ARRAY;
92
- if ($post->post_type == SG_POPUP_POST_TYPE) {
93
  $targets = array($SGPB_DATA_CONFIG_ARRAY['target']['initialData']);
94
 
95
  // for any targets preview popup should open
@@ -102,7 +102,7 @@ class PopupLoader
102
  $popup->setTarget($targets);
103
  }
104
  }
105
- if ($foundPopup->post_type == SG_POPUP_POST_TYPE) {
106
  $popup = SGPopup::find($foundPopup, $popupPreviewArgs);
107
 
108
  $popup->setEvents($SGPB_DATA_CONFIG_ARRAY['events']['initialData'][0]);
89
  }
90
  if (!empty($foundPopup)) {
91
  global $SGPB_DATA_CONFIG_ARRAY;
92
+ if (@$post->post_type == SG_POPUP_POST_TYPE) {
93
  $targets = array($SGPB_DATA_CONFIG_ARRAY['target']['initialData']);
94
 
95
  // for any targets preview popup should open
102
  $popup->setTarget($targets);
103
  }
104
  }
105
+ if (@$foundPopup->post_type == SG_POPUP_POST_TYPE) {
106
  $popup = SGPopup::find($foundPopup, $popupPreviewArgs);
107
 
108
  $popup->setEvents($SGPB_DATA_CONFIG_ARRAY['events']['initialData'][0]);
com/classes/RegisterPostType.php CHANGED
@@ -58,20 +58,21 @@ class RegisterPostType
58
  $labels = $this->getPostTypeLabels();
59
 
60
  $args = array(
61
- 'labels' => $labels,
62
- 'description' => __('Description.', 'your-plugin-textdomain'),
63
  // Exclude_from_search
64
- 'public' => true,
65
- 'has_archive' => true,
 
66
  // Where to show the post type in the admin menu
67
- 'show_ui' => true,
68
- 'query_var' => false,
69
- 'rewrite' => array('slug' => SG_POPUP_POST_TYPE),
70
- 'map_meta_cap' => true,
71
- 'capability_type' => array('sgpb_popup', 'sgpb_popups'),
72
- 'menu_position' => 10,
73
- 'supports' => apply_filters('sgpbPostTypeSupport', array('title', 'editor')),
74
- 'menu_icon' => 'dashicons-menu-icon-sgpb'
75
  );
76
 
77
  if (is_admin()) {
58
  $labels = $this->getPostTypeLabels();
59
 
60
  $args = array(
61
+ 'labels' => $labels,
62
+ 'description' => __('Description.', 'your-plugin-textdomain'),
63
  // Exclude_from_search
64
+ 'exclude_from_search' => true,
65
+ 'public' => true,
66
+ 'has_archive' => true,
67
  // Where to show the post type in the admin menu
68
+ 'show_ui' => true,
69
+ 'query_var' => false,
70
+ 'rewrite' => array('slug' => SG_POPUP_POST_TYPE),
71
+ 'map_meta_cap' => true,
72
+ 'capability_type' => array('sgpb_popup', 'sgpb_popups'),
73
+ 'menu_position' => 10,
74
+ 'supports' => apply_filters('sgpbPostTypeSupport', array('title', 'editor')),
75
+ 'menu_icon' => 'dashicons-menu-icon-sgpb'
76
  );
77
 
78
  if (is_admin()) {
com/classes/ScriptsLoader.php CHANGED
@@ -29,6 +29,30 @@ class ScriptsLoader
29
  return $this->isAdmin;
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  // load popup scripts and styles and add popup data to the footer
33
  public function loadToFooter()
34
  {
@@ -52,18 +76,11 @@ class ScriptsLoader
52
  foreach ($popups as $popup) {
53
  $popupId = $popup->getId();
54
 
55
- $extraOptions = $popup->getExtraRenderOptions();
56
  $events = $popup->getPopupAllEvents($postId, $popupId);
57
 
58
  $events = json_encode($events);
59
 
60
- $popupOptions = $popup->getOptions();
61
- $popupOptions = apply_filters('sgpbPopupRenderOptions', $popupOptions);
62
-
63
- $popupOptions = array_merge($popupOptions, $extraOptions);
64
-
65
- $popupOptions = AdminHelper::serializeData($popupOptions);
66
- $popupOptions = htmlspecialchars($popupOptions);
67
 
68
  $popupContent = apply_filters('sgpbPopupContentLoadToPage', $popup->getPopupTypeContent());
69
 
@@ -88,18 +105,11 @@ class ScriptsLoader
88
  foreach ($popups as $popup) {
89
  $popupId = $popup->getId();
90
 
91
- $extraOptions = $popup->getExtraRenderOptions();
92
  $events = array();
93
 
94
  $events = json_encode($events);
95
 
96
- $popupOptions = $popup->getOptions();
97
- $popupOptions = apply_filters('sgpbPopupRenderOptions', $popupOptions);
98
-
99
- $popupOptions = array_merge($popupOptions, $extraOptions);
100
-
101
- $popupOptions = AdminHelper::serializeData($popupOptions);
102
- $popupOptions = htmlspecialchars($popupOptions);
103
 
104
  $popupContent = apply_filters('sgpbPopupContentLoadToPage', $popup->getPopupTypeContent());
105
 
29
  return $this->isAdmin;
30
  }
31
 
32
+ /**
33
+ * Get encoded popup options
34
+ *
35
+ * @since 3.0.4
36
+ *
37
+ * @param object $popup
38
+ *
39
+ * @return array|mixed|string|void $popupOptions
40
+ */
41
+ private function getEncodedOptionsFromPopup($popup)
42
+ {
43
+ $extraOptions = $popup->getExtraRenderOptions();
44
+ $popupOptions = $popup->getOptions();
45
+ $popupOptions = apply_filters('sgpbPopupRenderOptions', $popupOptions);
46
+
47
+ $popupOptions = array_merge($popupOptions, $extraOptions);
48
+
49
+ // These two lines have been added in order to not use the json_econde and to support PHP 5.3 version.
50
+ $popupOptions = AdminHelper::serializeData($popupOptions);
51
+ $popupOptions = base64_encode($popupOptions);
52
+
53
+ return $popupOptions;
54
+ }
55
+
56
  // load popup scripts and styles and add popup data to the footer
57
  public function loadToFooter()
58
  {
76
  foreach ($popups as $popup) {
77
  $popupId = $popup->getId();
78
 
 
79
  $events = $popup->getPopupAllEvents($postId, $popupId);
80
 
81
  $events = json_encode($events);
82
 
83
+ $popupOptions = $this->getEncodedOptionsFromPopup($popup);
 
 
 
 
 
 
84
 
85
  $popupContent = apply_filters('sgpbPopupContentLoadToPage', $popup->getPopupTypeContent());
86
 
105
  foreach ($popups as $popup) {
106
  $popupId = $popup->getId();
107
 
 
108
  $events = array();
109
 
110
  $events = json_encode($events);
111
 
112
+ $popupOptions = $this->getEncodedOptionsFromPopup($popup);
 
 
 
 
 
 
113
 
114
  $popupContent = apply_filters('sgpbPopupContentLoadToPage', $popup->getPopupTypeContent());
115
 
com/classes/popups/SGPopup.php CHANGED
@@ -656,7 +656,7 @@ abstract class SGPopup
656
  public static function getEventsDataById($popupId, $saveMode = '')
657
  {
658
  $eventsData = array();
659
- if (get_post_meta($popupId, 'sg_popup_events'.$saveMode)) {
660
  $eventsData = get_post_meta($popupId, 'sg_popup_events'.$saveMode, true);
661
  }
662
 
@@ -667,7 +667,7 @@ abstract class SGPopup
667
  {
668
  $targetData = array();
669
 
670
- if (get_post_meta($popupId, 'sg_popup_target'.$saveMode)) {
671
  $targetData = get_post_meta($popupId, 'sg_popup_target'.$saveMode, true);
672
  }
673
 
@@ -677,7 +677,7 @@ abstract class SGPopup
677
  public static function getPopupOptionsById($popupId, $saveMode = '')
678
  {
679
  $optionsData = array();
680
- if (get_post_meta($popupId, 'sg_popup_options'.$saveMode)) {
681
  $optionsData = get_post_meta($popupId, 'sg_popup_options'.$saveMode, true);
682
  }
683
 
656
  public static function getEventsDataById($popupId, $saveMode = '')
657
  {
658
  $eventsData = array();
659
+ if (get_post_meta($popupId, 'sg_popup_events'.$saveMode, true)) {
660
  $eventsData = get_post_meta($popupId, 'sg_popup_events'.$saveMode, true);
661
  }
662
 
667
  {
668
  $targetData = array();
669
 
670
+ if (get_post_meta($popupId, 'sg_popup_target'.$saveMode, true)) {
671
  $targetData = get_post_meta($popupId, 'sg_popup_target'.$saveMode, true);
672
  }
673
 
677
  public static function getPopupOptionsById($popupId, $saveMode = '')
678
  {
679
  $optionsData = array();
680
+ if (get_post_meta($popupId, 'sg_popup_options'.$saveMode, true)) {
681
  $optionsData = get_post_meta($popupId, 'sg_popup_options'.$saveMode, true);
682
  }
683
 
com/config/config.php CHANGED
@@ -58,8 +58,6 @@ class SgpbPopupConfig
58
  self::addDefine('SGPB_FILTER_REPEAT_INTERVAL', 50);
59
  self::addDefine('SG_POPUP_TEXT_DOMAIN', 'popupBuilder');
60
  self::addDefine('SG_POPUP_STORE_URL', 'https://popup-builder.com/');
61
- // for popup builder license version
62
- self::addDefine('SG_VERSION_POPUP_BUILDER', 4.0);
63
  self::addDefine('SG_POPUP_AUTHOR', 'Sygnoos');
64
  self::addDefine('SG_POPUP_KEY', 'POPUP_BUILDER');
65
  self::addDefine('SG_AJAX_NONCE', 'popupBuilderAjaxNonce');
58
  self::addDefine('SGPB_FILTER_REPEAT_INTERVAL', 50);
59
  self::addDefine('SG_POPUP_TEXT_DOMAIN', 'popupBuilder');
60
  self::addDefine('SG_POPUP_STORE_URL', 'https://popup-builder.com/');
 
 
61
  self::addDefine('SG_POPUP_AUTHOR', 'Sygnoos');
62
  self::addDefine('SG_POPUP_KEY', 'POPUP_BUILDER');
63
  self::addDefine('SG_AJAX_NONCE', 'popupBuilderAjaxNonce');
com/config/configPackage.php CHANGED
@@ -3,6 +3,6 @@ if (!defined('ABSPATH')) {
3
  exit();
4
  }
5
 
6
- define('SG_POPUP_VERSION', '3.0.2');
7
  define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
8
  define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
3
  exit();
4
  }
5
 
6
+ define('SG_POPUP_VERSION', '3.0.3');
7
  define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
8
  define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
com/helpers/AdminHelper.php CHANGED
@@ -350,15 +350,15 @@ class AdminHelper
350
  if (isset($_GET['sgpb-subscription-popup-id']) && !empty($_GET['sgpb-subscription-popup-id'])) {
351
  $filterCriteria = esc_sql($_GET['sgpb-subscription-popup-id']);
352
  if ($filterCriteria != 'all') {
353
- $searchQuery .= "subscriptionType = $filterCriteria";
354
  }
355
  }
356
  if ($filterCriteria != '' && $filterCriteria != 'all' && isset($_GET['s']) && !empty($_GET['s'])) {
357
- $searchQuery .= ' LIKE ';
358
  }
359
  if (isset($_GET['s']) && !empty($_GET['s'])) {
360
  $searchCriteria = esc_sql($_GET['s']);
361
- $searchQuery .= " firstName LIKE '%$searchCriteria%' or lastName LIKE '%$searchCriteria%' or email LIKE '%$searchCriteria%' or $postsTablename.post_title LIKE '%$searchCriteria%'";
362
  }
363
  if (isset($_GET['sgpb-subscribers-date']) && !empty($_GET['sgpb-subscribers-date'])) {
364
  $filterCriteria = esc_sql($_GET['sgpb-subscribers-date']);
@@ -370,7 +370,7 @@ class AdminHelper
370
  }
371
  }
372
  if ($searchQuery != '') {
373
- $query .= " WHERE ($searchQuery)";
374
  }
375
 
376
  return $query;
@@ -767,14 +767,4 @@ class AdminHelper
767
 
768
  return $content;
769
  }
770
-
771
- public static function remoteFileExists($filename)
772
- {
773
- $file = wp_remote_head($filename);
774
- if (!empty($file['response']['code']) == 200) {
775
- return $file;
776
- }
777
-
778
- return array();
779
- }
780
  }
350
  if (isset($_GET['sgpb-subscription-popup-id']) && !empty($_GET['sgpb-subscription-popup-id'])) {
351
  $filterCriteria = esc_sql($_GET['sgpb-subscription-popup-id']);
352
  if ($filterCriteria != 'all') {
353
+ $searchQuery .= "(subscriptionType = $filterCriteria)";
354
  }
355
  }
356
  if ($filterCriteria != '' && $filterCriteria != 'all' && isset($_GET['s']) && !empty($_GET['s'])) {
357
+ $searchQuery .= ' AND ';
358
  }
359
  if (isset($_GET['s']) && !empty($_GET['s'])) {
360
  $searchCriteria = esc_sql($_GET['s']);
361
+ $searchQuery .= " (firstName LIKE '%$searchCriteria%' or lastName LIKE '%$searchCriteria%' or email LIKE '%$searchCriteria%' or $postsTablename.post_title LIKE '%$searchCriteria%')";
362
  }
363
  if (isset($_GET['sgpb-subscribers-date']) && !empty($_GET['sgpb-subscribers-date'])) {
364
  $filterCriteria = esc_sql($_GET['sgpb-subscribers-date']);
370
  }
371
  }
372
  if ($searchQuery != '') {
373
+ $query .= " WHERE $searchQuery";
374
  }
375
 
376
  return $query;
767
 
768
  return $content;
769
  }
 
 
 
 
 
 
 
 
 
 
770
  }
com/libs/Table.php CHANGED
@@ -241,7 +241,7 @@ class SGPBTable extends SGPBListTable
241
  else {
242
  $selected = '';
243
  }
244
- $dateList .= '<option value="'.$date['date-value'].'"'.$selected.'>'.$date['date-title'].'</option>';
245
  }
246
  echo $dateList;
247
  ?>
241
  else {
242
  $selected = '';
243
  }
244
+ $dateList .= '<option value="'.$date['date-value'].'"'.$selected.'>'.date('d F Y', strtotime($date['date-title'])).'</option>';
245
  }
246
  echo $dateList;
247
  ?>
popup-builder.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: https://popup-builder.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: 3.0.2
7
  * Author: Sygnoos
8
  * Author URI: https://sygnoos.com
9
  * License: GPLv2
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: https://popup-builder.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: 3.0.3
7
  * Author: Sygnoos
8
  * Author URI: https://sygnoos.com
9
  * License: GPLv2
public/css/fonts/{popup-builder-icon.eot → popupbuilder-icon.eot} RENAMED
File without changes
public/css/fonts/{popup-builder-icon.svg → popupbuilder-icon.svg} RENAMED
File without changes
public/css/fonts/{popup-builder-icon.ttf → popupbuilder-icon.ttf} RENAMED
File without changes
public/css/fonts/{popup-builder-icon.woff → popupbuilder-icon.woff} RENAMED
File without changes
public/css/popupAdminStyles.css CHANGED
@@ -959,10 +959,6 @@ input:checked + .sgpb-slider:before {
959
  line-height: 25px !important;
960
  }
961
 
962
- .select2-container {
963
- z-index: 9999;
964
- }
965
-
966
  .select2-container--default .select2-selection--single,
967
  .select2-dropdown.select2-dropdown--below {
968
  border: 2px solid #dce4ec !important;
@@ -1600,19 +1596,19 @@ input:checked + .sgpb-slider:before {
1600
 
1601
  /* Generated by Glyphter (http://www.glyphter.com) on Thu Jun 28 2018*/
1602
  @font-face {
1603
- font-family: 'popup-builder-icon';
1604
- src: url('fonts/popup-builder-icon.eot');
1605
- src: url('fonts/popup-builder-icon.eot?#iefix') format('embedded-opentype'),
1606
- url('fonts/popup-builder-icon.woff') format('woff'),
1607
- url('fonts/popup-builder-icon.ttf') format('truetype'),
1608
- url('fonts/popup-builder-icon.svg#popup-builder-icon') format('svg');
1609
  font-weight: normal;
1610
  font-style: normal;
1611
  }
1612
 
1613
  [class*='dashicons-menu-icon-sgpb']:before {
1614
  display: inline-block;
1615
- font-family: 'popup-builder-icon';
1616
  font-style: normal;
1617
  font-weight: normal;
1618
  line-height: 1;
959
  line-height: 25px !important;
960
  }
961
 
 
 
 
 
962
  .select2-container--default .select2-selection--single,
963
  .select2-dropdown.select2-dropdown--below {
964
  border: 2px solid #dce4ec !important;
1596
 
1597
  /* Generated by Glyphter (http://www.glyphter.com) on Thu Jun 28 2018*/
1598
  @font-face {
1599
+ font-family: 'popupbuilder-icon';
1600
+ src: url('fonts/popupbuilder-icon.eot');
1601
+ src: url('fonts/popupbuilder-icon.eot?#iefix') format('embedded-opentype'),
1602
+ url('fonts/popupbuilder-icon.woff') format('woff'),
1603
+ url('fonts/popupbuilder-icon.ttf') format('truetype'),
1604
+ url('fonts/popupbuilder-icon.svg#popupbuilder-icon') format('svg');
1605
  font-weight: normal;
1606
  font-style: normal;
1607
  }
1608
 
1609
  [class*='dashicons-menu-icon-sgpb']:before {
1610
  display: inline-block;
1611
+ font-family: 'popupbuilder-icon';
1612
  font-style: normal;
1613
  font-weight: normal;
1614
  line-height: 1;
public/css/theme.css CHANGED
@@ -1 +1 @@
1
- .sg-popup-builder-content{height:100%}.sgpb-theme-1-overlay{background:url(data:image/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAAAAAAeW/F+AAAAOklEQVR4Ae3QIQrAUADD0Lj2AIV//5uO+RE59asKz4U177rz9VAdqkU1qAbVoBpUg2pR3V/VbrVb7QHULigVcx3ZmQAAAABJRU5ErkJggg==)}.sgpb-theme-6-overlay{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpCMEM4NDgzQjlDRTNFMTExODE4NUVDOTdFQ0I0RDgxRSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGREU5OEVCQzAzMjYxMUUyOTg5OURDMDlDRTJDMTc0RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGREU5OEVCQjAzMjYxMUUyOTg5OURDMDlDRTJDMTc0RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkIxQzg0ODNCOUNFM0UxMTE4MTg1RUM5N0VDQjREODFFIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkIwQzg0ODNCOUNFM0UxMTE4MTg1RUM5N0VDQjREODFFIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+s3YRAQAAABtJREFUeNpiFODh2cBABGBiIBKMKqSOQoAAAwBokQDs5F/8FAAAAABJRU5ErkJggg==)}#sgpb-popup-dialog-main-div-wrapper #sgpb-close-button{padding:0!important;color:#444!important;border:0!important;margin:0!important;overflow:visible!important;width:auto!important;background:none!important;text-shadow:0 0 2px #fff!important}#sgpb-popup-dialog-main-div-wrapper #sgpb-close-button:active{outline:0!important}.sgpb-popup-dialog-main-div-wrapper iframe{border:0!important}#popup-dialog-main-div div{margin-bottom:43px}.popup-main-wrapper div:after{background-color:#E6E5E5;content:'';display:block;position:absolute;left:5px;right:5px;bottom:5px;z-index:99999999999999999999999999999999999999999;height:43px}#content-div{border:12px solid #4B4B4B}.sgpb-theme-5-content{border-bottom:34px solid #E6E5E5!important}.sgpb-scroll-wrapper{width:100%;height:100%;overflow:hidden;-webkit-overflow-scrolling:touch}.sgpb-scroll-wrapper iframe{margin:0!important;width:1px!important;min-width:100%!important;height:100%!important}.sgpb-video-iframe-wrapper{width:100%;height:100%;overflow:hidden;-webkit-overflow-scrolling:touch}.sgpb-video-iframe-wrapper iframe{margin:0!important;width:100%;height:100%;border:0}.sgpb-video-error-message-wrapper h1{text-align:center}.sgpb-video-error-message-wrapper h3:last-child{padding:0}.sgpb-popup-builder-content-html{width:100%;height:100%;overflow:auto}#sgpb-yes-button,#sgpb-no-button{text-transform:none!important}.sg-fb-buttons-wrapper{text-align:center;min-height:25px}@media only screen and (max-width:600px){.sgpb-scroll-wrapper{overflow:auto!important}}@media (min-width:600px){.sgpb-fb-wrapper-standard{min-width:450px!important;overflow:hidden}}@media (min-width:521px) and (max-width:599px){.sgpb-fb-wrapper-standard{min-width:450px!important;overflow:scroll}#sg-facebook-like{overflow:hidden}}@media (max-width:520px){.sgpb-fb-wrapper-standard{min-width:380px!important;max-width:380px!important;overflow:hidden}.sgpb-fb-wrapper-standard .fb-like{max-width:380px!important}#sg-facebook-like{overflow:hidden}}@media (max-width:420px){.sgpb-fb-wrapper-standard{min-width:350px!important;max-width:350px!important;overflow:hidden}}@media (max-width:400px){.sgpb-fb-wrapper-standard{min-width:330px!important;max-width:330px!important;overflow:scroll}}@media (max-width:320px){.sgpb-fb-wrapper-standard{min-width:270px!important;max-width:270px!important;overflow:scroll}}.sg-hide-element{display:none}a.sg-show-popup{cursor:pointer!important}.sgpb-theme-1-content{border-radius:6px;padding-bottom:0;box-shadow:rgba(0,0,0,.6) 0 0 0 14px!important;border-bottom-width:35px!important;border-bottom-color:#fff!important}.sgpb-theme-4-content{padding-bottom:0;border-radius:7px!important;border-bottom-width:35px!important;border-bottom-color:#fff!important}.sgpb-popup-close-button-4{height:auto!important}.sgpb-popup-dialog-main-div-theme-wrapper-5{border:8px solid #555;outline:1px solid #8A8A8A;background-color:#707070}.sgpb-theme-5-content{border-radius:3px!important;box-shadow:0 0 10px #222!important}.sgpb-theme-6-content{box-shadow:#646161 0 0 8px 3px!important}.sgpb-popup-close-button-1:hover,.sgpb-popup-close-button-2:hover,.sgpb-popup-close-button-5:hover{opacity:.8}.sgpb-popup-close-button-3:hover{opacity:.9}.sgpb-popup-close-button-2{border-radius:2px}.sgpb-main-image-content-wrapper{line-height:0!important}.sgpb-main-image-content-wrapper img{height:auto;max-width:100%}
1
+ .sg-popup-builder-content{height:100%}.sgpb-theme-1-overlay{background:url(data:image/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAAAAAAeW/F+AAAAOklEQVR4Ae3QIQrAUADD0Lj2AIV//5uO+RE59asKz4U177rz9VAdqkU1qAbVoBpUg2pR3V/VbrVb7QHULigVcx3ZmQAAAABJRU5ErkJggg==)}.sgpb-theme-6-overlay{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpCMEM4NDgzQjlDRTNFMTExODE4NUVDOTdFQ0I0RDgxRSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGREU5OEVCQzAzMjYxMUUyOTg5OURDMDlDRTJDMTc0RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGREU5OEVCQjAzMjYxMUUyOTg5OURDMDlDRTJDMTc0RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkIxQzg0ODNCOUNFM0UxMTE4MTg1RUM5N0VDQjREODFFIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkIwQzg0ODNCOUNFM0UxMTE4MTg1RUM5N0VDQjREODFFIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+s3YRAQAAABtJREFUeNpiFODh2cBABGBiIBKMKqSOQoAAAwBokQDs5F/8FAAAAABJRU5ErkJggg==)}#sgpb-popup-dialog-main-div-wrapper #sgpb-close-button{padding:0!important;color:#444!important;border:0!important;margin:0!important;overflow:visible!important;width:auto!important;background:none!important;text-shadow:0 0 2px #fff!important}#sgpb-popup-dialog-main-div-wrapper #sgpb-close-button:active{outline:0!important}.sgpb-popup-dialog-main-div-wrapper iframe{border:0!important}#popup-dialog-main-div div{margin-bottom:43px}.popup-main-wrapper div:after{background-color:#E6E5E5;content:'';display:block;position:absolute;left:5px;right:5px;bottom:5px;z-index:99999999999999999999999999999999999999999;height:43px}#content-div{border:12px solid #4B4B4B}.sgpb-theme-5-content{border-bottom:34px solid #E6E5E5!important}.sgpb-scroll-wrapper{width:100%;height:100%;overflow:hidden;-webkit-overflow-scrolling:touch}.sgpb-scroll-wrapper iframe{margin:0!important;width:1px!important;min-width:100%!important;height:100%!important}.sgpb-video-iframe-wrapper{width:100%;height:100%;overflow:hidden;-webkit-overflow-scrolling:touch}.sgpb-video-iframe-wrapper iframe{margin:0!important;width:100%;height:100%;border:0}.sgpb-video-error-message-wrapper h1{text-align:center}.sgpb-video-error-message-wrapper h3:last-child{padding:0}.sgpb-popup-builder-content-html{width:100%;height:100%;overflow:auto}#sgpb-yes-button,#sgpb-no-button{text-transform:none!important}.sg-fb-buttons-wrapper{text-align:center;min-height:25px}@media only screen and (max-width:600px){.sgpb-scroll-wrapper{overflow:auto!important}}@media (min-width:600px){.sgpb-fb-wrapper-standard{min-width:450px!important;overflow:hidden}}@media (min-width:521px) and (max-width:599px){.sgpb-fb-wrapper-standard{min-width:450px!important;overflow:scroll}#sg-facebook-like{overflow:hidden}}@media (max-width:520px){.sgpb-fb-wrapper-standard{min-width:380px!important;max-width:380px!important;overflow:hidden}.sgpb-fb-wrapper-standard .fb-like{max-width:380px!important}#sg-facebook-like{overflow:hidden}}@media (max-width:420px){.sgpb-fb-wrapper-standard{min-width:350px!important;max-width:350px!important;overflow:hidden}}@media (max-width:400px){.sgpb-fb-wrapper-standard{min-width:330px!important;max-width:330px!important;overflow:scroll}}@media (max-width:320px){.sgpb-fb-wrapper-standard{min-width:270px!important;max-width:270px!important;overflow:scroll}}.sg-hide-element{display:none}a.sg-show-popup{cursor:pointer!important}.sgpb-theme-1-content{border-radius:6px;padding-bottom:0;box-shadow:rgba(0,0,0,.6) 0 0 0 14px!important;border-bottom-width:35px!important;border-bottom-color:#fff!important}.sgpb-theme-4-content{padding-bottom:0;border-radius:7px!important;border-bottom-width:35px!important;border-bottom-color:#fff!important}.sgpb-popup-close-button-4{height:auto!important}.sgpb-popup-dialog-main-div-theme-wrapper-5{border:8px solid #555;outline:1px solid #8A8A8A;background-color:#707070}.sgpb-theme-5-content{border-radius:3px!important;box-shadow:0 0 10px #222!important}.sgpb-theme-6-content{box-shadow:#646161 0 0 8px 3px!important}.sgpb-popup-close-button-1:hover,.sgpb-popup-close-button-2:hover,.sgpb-popup-close-button-5:hover{opacity:.8}.sgpb-popup-close-button-3:hover{opacity:.9}.sgpb-popup-close-button-2{border-radius:2px}.sgpb-main-image-content-wrapper img{height:auto;max-width:100%}
public/js/PopupBuilder.js CHANGED
@@ -1,1570 +1,2114 @@
1
- function sgAddEvent(element, eventName, fn) {
2
- if (element.addEventListener)
3
- element.addEventListener(eventName, fn, false);
4
- else if (element.attachEvent)
5
- element.attachEvent('on' + eventName, fn);
 
6
  }
 
7
  window.SGPB_ORDER = 0;
8
 
9
- function SGPBPopup() {
10
- this.id = null;
11
- this.eventName = '';
12
- this.popupData = null;
13
- this.popupConfig = {};
14
- this.popupObj = null;
15
- this.onceListener();
16
- this.initialsListeners();
 
17
  }
18
- SGPBPopup.prototype.initialsListeners = function() {
19
- window.SGPB_SOUND = [];
20
- sgAddEvent(window, 'sgpbDidOpen', function(e) {
21
- var args = e.detail;
22
- var popupId = parseInt(args.popupId);
23
- var options = SGPBPopup.getPopupOptionsById(popupId);
24
- var soundUrl = options['sgpb-sound-url'];
25
- var soundStatus = options['sgpb-open-sound'];
26
- if (soundStatus && soundUrl && !window.SGPB_SOUND[popupId]) {
27
- var audio = new Audio(soundUrl);
28
- audio.play();
29
- window.SGPB_SOUND[popupId] = audio;
30
- }
31
- });
32
- sgAddEvent(window, 'sgpbDidClose', function(e) {
33
- var args = e.detail;
34
- var popupId = parseInt(args.popupId);
35
- if (typeof window.SGPB_SOUND[popupId] && window.SGPB_SOUND[popupId]) {
36
- window.SGPB_SOUND[popupId].pause();
37
- delete window.SGPB_SOUND[popupId];
38
- }
39
- });
40
- };
41
- SGPBPopup.prototype.onceListener = function() {
42
- var that = this;
43
- sgAddEvent(window, 'sgpbDidOpen', function(e) {
44
- jQuery('.sg-popup-close').click(function() {
45
- var currentPopup = that.getPopupIdForNextEsc();
46
- if (!currentPopup) {
47
- return false;
48
- }
49
- SGPBPopup.closePopupById(currentPopup.popupId);
50
- });
51
- document.onkeydown = function(e) {
52
- e = e || window.event;
53
- if (e.keyCode == 27) {
54
- var currentPopup = that.getPopupIdForNextEsc();
55
- if (!currentPopup) {
56
- return false;
57
- }
58
- var lastPopupId = parseInt(currentPopup['popupId']);
59
- SGPBPopup.closePopupById(lastPopupId);
60
- }
61
- };
62
- });
63
- sgAddEvent(window, 'sgpbDidClose', function(e) {
64
- if (window.sgPopupBuilder.length != 0) {
65
- var popups = [].concat(window.sgPopupBuilder).reverse();
66
- for (var i in popups) {
67
- var nextIndex = ++i;
68
- var nextObj = popups[nextIndex];
69
- if (typeof nextObj == 'undefined') {
70
- jQuery('html').css({
71
- overflow: 'auto'
72
- });
73
- break;
74
- }
75
- if (nextObj.isOpen == false) {
76
- continue;
77
- }
78
- var options = SGPBPopup.getPopupOptionsById(nextObj.popupId);
79
- if (typeof options['sgpb-disable-page-scrolling'] == 'undefined') {
80
- jQuery('html').css({
81
- overflow: 'auto'
82
- });
83
- } else {
84
- jQuery('html').css({
85
- overflow: 'hidden'
86
- });
87
- }
88
- break;
89
- }
90
- } else {
91
- jQuery('html').css({
92
- overflow: 'auto'
93
- });
94
- }
95
- });
96
- };
97
- SGPBPopup.prototype.getPopupIdForNextEsc = function() {
98
- var popups = window.sgPopupBuilder;
99
- var popup = false;
100
- if (!popups.length) {
101
- return popup;
102
- }
103
- var searchPopups = [].concat(popups).reverse();
104
- for (var i in searchPopups) {
105
- var popupData = searchPopups[i];
106
- if (popupData.isOpen) {
107
- var popupId = parseInt(popupData['popupId']);
108
- var popupOptions = SGPBPopup.getPopupOptionsById(popupId);
109
- if (!popupOptions['sgpb-disable-popup-closing'] && popupOptions['sgpb-esc-key']) {
110
- popup = popupData;
111
- break;
112
- }
113
- }
114
- }
115
- return popup;
116
- };
117
- SGPBPopup.prototype.setPopupId = function(popupId) {
118
- this.id = parseInt(popupId);
119
- };
120
- SGPBPopup.prototype.getPopupId = function() {
121
- return this.id;
122
- };
123
- SGPBPopup.prototype.setPopupObj = function(popupObj) {
124
- this.popupObj = popupObj;
125
- };
126
- SGPBPopup.prototype.getPopupObj = function() {
127
- return this.popupObj;
128
- };
129
- SGPBPopup.prototype.setPopupData = function(popupData) {
130
- if (typeof popupData == 'string') {
131
- var popupData = SGPBPopup.unserialize(popupData);
132
- }
133
- this.popupData = popupData;
134
- };
135
- SGPBPopup.prototype.getPopupData = function() {
136
- return this.popupData;
137
- };
138
- SGPBPopup.prototype.setPopupConfig = function(config) {
139
- this.popupConfig = config;
140
- };
141
- SGPBPopup.prototype.getPopupConfig = function() {
142
- return this.popupConfig;
143
- };
144
- SGPBPopup.prototype.setUpPopupConfig = function() {
145
- var popupConfig = new PopupConfig();
146
- this.setPopupConfig(popupConfig);
147
- };
148
- SGPBPopup.createPopupObjById = function(popupId) {
149
- var options = SGPBPopup.getPopupOptionsById(popupId);
150
- if (!options) {
151
- return false;
152
- }
153
- var popupObj = new SGPBPopup();
154
- popupObj.setPopupId(popupId);
155
- popupObj.setPopupData(options);
156
- return popupObj;
157
- };
158
- SGPBPopup.getPopupOptionsById = function(popupId) {
159
- var popupDataDiv = jQuery('#sg-popup-content-wrapper-' + popupId);
160
- if (!popupDataDiv.length) {
161
- return false;
162
- }
163
- var options = popupDataDiv.attr('data-options');
164
- return SGPBPopup.unserialize(options);
165
- };
166
- SGPBPopup.prototype.getCompatibleZiIndex = function(popupZIndex) {
167
- if (popupZIndex > 2147483647) {
168
- return 2147483627;
169
- }
170
- return popupZIndex;
171
- };
172
- SGPBPopup.prototype.prepareOpen = function() {
173
- var popupId = this.getPopupId();
174
- var popupData = this.getPopupData();
175
- var popupZIndex = this.getCompatibleZiIndex(popupData['sgpb-popup-z-index']);
176
- this.setUpPopupConfig();
177
- var that = this;
178
- var popupConfig = this.getPopupConfig();
179
- this.setPopupDimensions();
180
- if (popupData['sgpb-disable-popup-closing'] == 'on') {
181
- popupData['sgpb-enable-close-button'] = '';
182
- popupData['sgpb-esc-key'] = '';
183
- popupData['sgpb-overlay-click'] = '';
184
- }
185
- popupData['eventName'] = this.eventName;
186
- if (SGPBPopup.varToBool(popupData['sgpb-enable-close-button'])) {
187
- popupConfig.magicCall('setCloseButtonDelay', parseInt(popupData['sgpb-close-button-delay']));
188
- }
189
- popupConfig.magicCall('setShowButton', SGPBPopup.varToBool(popupData['sgpb-enable-close-button']));
190
- var openAnimationSpeed = parseInt(popupData['sgpb-open-animation-speed']) * 1000;
191
- popupConfig.magicCall('setOpenAnimationEffect', popupData['sgpb-open-animation-effect']);
192
- popupConfig.magicCall('setOpenAnimationSpeed', openAnimationSpeed);
193
- popupConfig.magicCall('setOpenAnimationStatus', popupData['sgpb-open-animation']);
194
- popupConfig.magicCall('setContentPadding', popupData['sgpb-content-padding']);
195
- popupConfig.magicCall('setZIndex', popupZIndex);
196
- popupConfig.magicCall('setCloseButtonWidth', popupData['sgpb-button-image-width']);
197
- popupConfig.magicCall('setCloseButtonHeight', popupData['sgpb-button-image-height']);
198
- popupConfig.magicCall('setPopupId', popupId);
199
- popupConfig.magicCall('setPopupData', popupData);
200
- popupConfig.magicCall('setAllowed', !SGPBPopup.varToBool(popupData['sgpb-disable-popup-closing']));
201
- if (popupData['sgpb-type'] == SGPB_POPUP_PARAMS.popupTypeAgeRestriction) {
202
- popupConfig.magicCall('setAllowed', false);
203
- }
204
- popupConfig.magicCall('setEscShouldClose', SGPBPopup.varToBool(popupData['sgpb-esc-key']));
205
- popupConfig.magicCall('setOverlayShouldClose', SGPBPopup.varToBool(popupData['sgpb-overlay-click']));
206
- popupConfig.magicCall('setScrollingEnabled', SGPBPopup.varToBool(popupData['sgpb-enable-content-scrolling']));
207
- if (SGPBPopup.varToBool(popupData['sgpb-content-click'])) {
208
- this.contentCloseBehavior();
209
- }
210
- if (SGPBPopup.varToBool(popupData['sgpb-popup-fixed'])) {
211
- this.addFixedPosition();
212
- }
213
- this.themeCreator();
214
- this.themeCustomizations();
215
- popupConfig.magicCall('setContents', document.getElementById('sg-popup-content-wrapper-' + popupId));
216
- this.setPopupConfig(popupConfig);
217
- this.popupTriggeringListeners();
218
- var allowToOpen = this.checkCurrentPopupType();
219
- if (allowToOpen) {
220
- this.open();
221
- }
222
- };
223
- SGPBPopup.prototype.checkCurrentPopupType = function() {
224
- var allowToOpen = true;
225
- var popupConfig = new PopupConfig();
226
- var isPreview = parseInt(this.popupData['sgpb-is-preview']);
227
- if (!isNaN(isPreview) && isPreview == 1) {
228
- return allowToOpen;
229
- }
230
- var popupHasLimit = this.popupLimitation(this.popupData);
231
- if (!popupHasLimit) {
232
- return false;
233
- }
234
- var dontShowPopupCookieName = 'sgDontShowPopup' + this.popupData['sgpb-post-id'];
235
- var dontShowPopup = SGPopup.getCookie(dontShowPopupCookieName);
236
- if (dontShowPopup != '') {
237
- return false;
238
- }
239
- var className = this.popupData['sgpb-type'];
240
- if (typeof className == 'undefined' || className == 'undefined') {
241
- return false;
242
- }
243
- className = popupConfig.prefix.toUpperCase() + className.firstToUpperCase();
244
- if (window.hasOwnProperty(className)) {
245
- className = eval(className);
246
- var obj = new className;
247
- if (typeof obj.allowToOpen === 'function') {
248
- allowToOpen = obj.allowToOpen(this.id);
249
- }
250
- }
251
- return allowToOpen;
252
- };
253
- SGPBPopup.prototype.popupLimitation = function(popupData) {
254
- var currentUrl = window.location.href;
255
- var currentPopupId = popupData['sgpb-post-id'];
256
- var popupLimitationCookieHomePageLevelName = 'SGPBShowingLimitationHomePage' + currentPopupId;
257
- var popupLimitationCookiePageLevelName = 'SGPBShowingLimitationPage' + currentPopupId;
258
- var popupLimitationCookieDomainName = 'SGPBShowingLimitationDomain' + currentPopupId;
259
- var popupLimitation = popupData['sgpb-show-popup-same-user'];
260
- if (typeof popupLimitation != 'undefined' && popupLimitation) {
261
- var popupShowingLimit = popupData['sgpb-show-popup-same-user-count'];
262
- var popupShowingLimitExpiry = popupData['sgpb-show-popup-same-user-expiry'];
263
- var pageLevelCookie = popupData['sgpb-show-popup-same-user-page-level'];
264
- if (typeof pageLevelCookie == 'undefined') {
265
- pageLevelCookie = '';
266
- }
267
- if (currentUrl == SGPB_POPUP_PARAMS.homePageUrl) {
268
- popupLimitationCookiePageLevelName = popupLimitationCookieHomePageLevelName;
269
- }
270
- var popupLimitationPageLevelCookie = SGPopup.getCookie(popupLimitationCookiePageLevelName);
271
- var popupLimitationDomainCookie = SGPopup.getCookie(popupLimitationCookieDomainName);
272
- if (pageLevelCookie) {
273
- if (popupLimitationPageLevelCookie == '') {
274
- var cookieObject = {
275
- openingCount: 1,
276
- pageLevelCookie: pageLevelCookie,
277
- openingPage: currentUrl
278
- };
279
- SGPBPopup.setCookie(popupLimitationCookiePageLevelName, JSON.stringify(cookieObject), popupShowingLimitExpiry, currentUrl);
280
- } else {
281
- var popupLimitationPageLevelCookie = jQuery.parseJSON(popupLimitationPageLevelCookie);
282
- if (popupShowingLimit <= popupLimitationPageLevelCookie.openingCount) {
283
- return false;
284
- }
285
- var updatedCount = parseInt(popupLimitationPageLevelCookie.openingCount + 1);
286
- popupLimitationPageLevelCookie.openingCount = updatedCount;
287
- SGPBPopup.setCookie(popupLimitationCookiePageLevelName, JSON.stringify(popupLimitationPageLevelCookie), popupShowingLimitExpiry, currentUrl);
288
- }
289
- SGPBPopup.deleteCookie(popupLimitationCookieDomainName);
290
- } else {
291
- var popupLimitationPageLevelCookie = jQuery.parseJSON(popupLimitationPageLevelCookie);
292
- if (popupLimitationPageLevelCookie) {
293
- SGPBPopup.deleteCookie(popupLimitationCookiePageLevelName, popupLimitationPageLevelCookie.openingPage);
294
- }
295
- if (popupLimitationDomainCookie == '') {
296
- var cookieObject = {
297
- openingCount: 1,
298
- pageLevelCookie: pageLevelCookie
299
- };
300
- SGPBPopup.setCookie(popupLimitationCookieDomainName, JSON.stringify(cookieObject), popupShowingLimitExpiry, pageLevelCookie);
301
- } else {
302
- var popupLimitationDomainCookie = jQuery.parseJSON(popupLimitationDomainCookie);
303
- if (popupShowingLimit <= popupLimitationDomainCookie.openingCount) {
304
- return false;
305
- }
306
- var updatedCount = parseInt(popupLimitationDomainCookie.openingCount + 1);
307
- popupLimitationDomainCookie.openingCount = updatedCount;
308
- SGPBPopup.setCookie(popupLimitationCookieDomainName, JSON.stringify(popupLimitationDomainCookie), popupShowingLimitExpiry, pageLevelCookie);
309
- }
310
- }
311
- }
312
- return true;
313
- };
314
- SGPBPopup.prototype.themeCreator = function() {
315
- var noPositionSelected = false;
316
- var popupData = this.getPopupData();
317
- var popupId = this.getPopupId();
318
- var popupConfig = this.getPopupConfig();
319
- var popupTheme = popupData['sgpb-popup-themes'];
320
- var closeButtonWidth = popupData['sgpb-button-image-width'];
321
- var closeButtonHeight = popupData['sgpb-button-image-height'];
322
- var contentPadding = parseInt(popupData['sgpb-content-padding']);
323
- var contentClass = popupData['sgpb-content-custom-class'];
324
- var closeButtonImage = popupConfig.closeButtonImage;
325
- var themeNumber = 1;
326
- if (popupData['sgpb-type'] == 'countdown') {
327
- popupConfig.magicCall('setMinWidth', 300);
328
- }
329
- popupConfig.magicCall('setContentPadding', contentPadding);
330
- popupConfig.magicCall('setOverlayAddClass', popupTheme + '-overlay sgpb-popup-overlay-' + popupId);
331
- popupConfig.magicCall('setContentAddClass', 'sgpb-content sgpb-content-' + popupId + ' ' + popupTheme + '-content ' + contentClass);
332
- if (typeof popupData['sgpb-close-button-position'] == 'undefined' || popupData['sgpb-close-button-position'] == '') {
333
- var noPositionSelected = true;
334
- } else {
335
- var closeButtonPosition = popupData['sgpb-close-button-position'];
336
- popupConfig.magicCall('setButtonPosition', closeButtonPosition);
337
- }
338
- if (popupTheme == 'sgpb-theme-1') {
339
- themeNumber = 1;
340
- popupConfig.magicCall('setShadowSpread', 14);
341
- if (noPositionSelected || closeButtonPosition == 'bottomRight') {
342
- popupConfig.magicCall('setCloseButtonPositionRight', '9px');
343
- popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
344
- } else {
345
- popupConfig.magicCall('setCloseButtonPositionLeft', '9px');
346
- popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
347
- }
348
- } else if (popupTheme == 'sgpb-theme-2') {
349
- themeNumber = 2;
350
- popupConfig.magicCall('setButtonInside', false);
351
- popupConfig.magicCall('setContentBorderWidth', 1);
352
- popupConfig.magicCall('setContentBackgroundColor', 'black');
353
- popupConfig.magicCall('setContentBorderColor', 'black');
354
- popupConfig.magicCall('setOverlayColor', 'white');
355
- if (noPositionSelected || closeButtonPosition == 'topRight') {
356
- popupConfig.magicCall('setCloseButtonPositionRight', '0');
357
- popupConfig.magicCall('setCloseButtonPositionTop', '-' + closeButtonHeight + 'px');
358
- } else {
359
- if (closeButtonPosition == 'topLeft') {
360
- popupConfig.magicCall('setCloseButtonPositionLeft', '0');
361
- popupConfig.magicCall('setCloseButtonPositionTop', '-' + closeButtonHeight + 'px');
362
- } else if (closeButtonPosition == 'bottomRight') {
363
- popupConfig.magicCall('setCloseButtonPositionRight', '0');
364
- popupConfig.magicCall('setCloseButtonPositionBottom', '-' + closeButtonHeight + 'px');
365
- } else if (closeButtonPosition == 'bottomLeft') {
366
- popupConfig.magicCall('setCloseButtonPositionLeft', '0');
367
- popupConfig.magicCall('setCloseButtonPositionBottom', '-' + closeButtonHeight + 'px');
368
- }
369
- }
370
- } else if (popupTheme == 'sgpb-theme-3') {
371
- themeNumber = 3;
372
- popupConfig.magicCall('setContentBorderWidth', 5);
373
- popupConfig.magicCall('setContentBorderRadius', popupData['sgpb-border-radius']);
374
- popupConfig.magicCall('setContentBorderRadiusType', popupData['sgpb-border-radius-type']);
375
- popupConfig.magicCall('setContentBorderColor', popupData['sgpb-border-color']);
376
- if (noPositionSelected) {
377
- popupConfig.magicCall('setCloseButtonWidth', 38);
378
- popupConfig.magicCall('setCloseButtonHeight', 19);
379
- popupConfig.magicCall('setCloseButtonPositionRight', '4px');
380
- popupConfig.magicCall('setCloseButtonPositionTop', '4px');
381
- } else {
382
- if (closeButtonPosition == 'topRight') {
383
- popupConfig.magicCall('setCloseButtonPositionRight', '4px');
384
- popupConfig.magicCall('setCloseButtonPositionTop', '4px');
385
- } else if (closeButtonPosition == 'topLeft') {
386
- popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
387
- popupConfig.magicCall('setCloseButtonPositionTop', '4px');
388
- } else if (closeButtonPosition == 'bottomRight') {
389
- popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
390
- popupConfig.magicCall('setCloseButtonPositionBottom', '4px');
391
- } else if (closeButtonPosition == 'bottomLeft') {
392
- popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
393
- popupConfig.magicCall('setCloseButtonPositionBottom', '4px');
394
- }
395
- }
396
- } else if (popupTheme == 'sgpb-theme-4') {
397
- themeNumber = 4;
398
- popupConfig.magicCall('setButtonImage', popupData['sgpb-button-text']);
399
- popupConfig.magicCall('setCloseButtonType', 'button');
400
- popupConfig.magicCall('setCloseButtonText', popupData['sgpb-button-text']);
401
- popupConfig.magicCall('setContentBorderWidth', 0);
402
- popupConfig.magicCall('setContentBackgroundColor', 'white');
403
- popupConfig.magicCall('setContentBorderColor', 'white');
404
- popupConfig.magicCall('setOverlayColor', 'white');
405
- popupConfig.magicCall('setShadowSpread', 4);
406
- popupConfig.magicCall('setContentShadowBlur', 8);
407
- if (noPositionSelected || closeButtonPosition == 'bottomRight') {
408
- popupConfig.magicCall('setCloseButtonPositionRight', '12px');
409
- popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
410
- } else {
411
- popupConfig.magicCall('setCloseButtonPositionLeft', '12px');
412
- popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
413
- }
414
- } else if (popupTheme == 'sgpb-theme-5') {
415
- themeNumber = 5;
416
- popupConfig.magicCall('setBoxBorderWidth', 10);
417
- popupConfig.magicCall('setContentBorderColor', '#4B4B4B');
418
- if (noPositionSelected || closeButtonPosition == 'bottomRight') {
419
- popupConfig.magicCall('setCloseButtonPositionRight', '8px');
420
- popupConfig.magicCall('setCloseButtonPositionBottom', '8px');
421
- } else {
422
- popupConfig.magicCall('setCloseButtonPositionLeft', '8px');
423
- popupConfig.magicCall('setCloseButtonPositionBottom', '8px');
424
- }
425
- } else if (popupTheme == 'sgpb-theme-6') {
426
- themeNumber = 6;
427
- popupConfig.magicCall('setButtonInside', false);
428
- popupConfig.magicCall('setContentBorderRadius', 7);
429
- popupConfig.magicCall('setContentBorderRadiusType', 'px');
430
- if (noPositionSelected) {
431
- popupConfig.magicCall('setCloseButtonWidth', 37);
432
- popupConfig.magicCall('setCloseButtonHeight', 37);
433
- popupConfig.magicCall('setCloseButtonPositionRight', '-18.5px');
434
- popupConfig.magicCall('setCloseButtonPositionTop', '-18.5px');
435
- } else {
436
- if (closeButtonPosition == 'topRight') {
437
- popupConfig.magicCall('setCloseButtonPositionRight', '-' + (closeButtonWidth / 2) + 'px');
438
- popupConfig.magicCall('setCloseButtonPositionTop', '-' + (closeButtonHeight / 2) + 'px');
439
- } else if (closeButtonPosition == 'topLeft') {
440
- popupConfig.magicCall('setCloseButtonPositionLeft', '-' + (closeButtonWidth / 2) + 'px');
441
- popupConfig.magicCall('setCloseButtonPositionTop', '-' + (closeButtonHeight / 2) + 'px');
442
- } else if (closeButtonPosition == 'bottomRight') {
443
- popupConfig.magicCall('setCloseButtonPositionRight', '-' + (closeButtonWidth / 2) + 'px');
444
- popupConfig.magicCall('setCloseButtonPositionBottom', '-' + (closeButtonHeight / 2) + 'px');
445
- } else if (closeButtonPosition == 'bottomLeft') {
446
- popupConfig.magicCall('setCloseButtonPositionLeft', '-' + (closeButtonWidth / 2) + 'px');
447
- popupConfig.magicCall('setCloseButtonPositionBottom', '-' + (closeButtonHeight / 2) + 'px');
448
- }
449
- }
450
- }
451
- popupConfig.magicCall('setPopupTheme', themeNumber);
452
- if (!popupData['sgpb-button-image']) {
453
- closeButtonImage = SGPB_POPUP_PARAMS.defaultThemeImages[themeNumber];
454
- if (typeof closeButtonImage != 'undefined') {
455
- popupConfig.magicCall('setButtonImage', closeButtonImage);
456
- }
457
- } else {
458
- popupConfig.magicCall('setButtonImage', popupData['sgpb-button-image']);
459
- }
460
- };
461
- SGPBPopup.prototype.themeCustomizations = function() {
462
- var popupId = this.getPopupId();
463
- var popupData = this.getPopupData();
464
- var popupConfig = this.getPopupConfig();
465
- var contentOpacity = popupData['sgpb-content-opacity'];
466
- var contentBgColor = popupData['sgpb-background-color'];
467
- var contentBgImage = popupData['sgpb-background-image'];
468
- var showContentBackground = popupData['sgpb-show-background'];
469
- var contentBgImageMode = popupData['sgpb-background-image-mode'];
470
- var overlayColor = popupData['sgpb-overlay-color'];
471
- var popupTheme = popupData['sgpb-popup-themes'];
472
- if (typeof showContentBackground == 'undefined') {
473
- contentBgColor = '';
474
- contentBgImage = '';
475
- contentBgImageMode = '';
476
- }
477
- if (contentBgImageMode) {
478
- popupConfig.magicCall('setContentBackgroundMode', contentBgImageMode);
479
- }
480
- if (contentBgImage) {
481
- popupConfig.magicCall('setContentBackgroundImage', contentBgImage);
482
- }
483
- if (contentBgColor) {
484
- contentBgColor = SGPBPopup.hexToRgba(contentBgColor, contentOpacity);
485
- popupConfig.magicCall('setContentBackgroundColor', contentBgColor);
486
- }
487
- if (overlayColor) {
488
- popupConfig.magicCall('setOverlayColor', overlayColor);
489
- }
490
- var overlayClasses = popupTheme + '-overlay sgpb-popup-overlay-' + popupId;
491
- if (SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']) || SGPB_JS_PACKAGES.packages['current'] == SGPB_JS_PACKAGES.packages['free']) {
492
- if (SGPB_JS_PACKAGES.packages['current'] != SGPB_JS_PACKAGES.packages['free']) {
493
- popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
494
- }
495
- popupConfig.magicCall('setOverlayAddClass', overlayClasses + ' ' + popupData['sgpb-overlay-custom-class']);
496
- popupConfig.magicCall('setOverlayOpacity', popupData['sgpb-overlay-opacity'] * 100);
497
- } else {
498
- if (SGPB_JS_PACKAGES.packages['current'] == SGPB_JS_PACKAGES.packages['free']) {
499
- popupData['sgpb-enable-popup-overlay'] = true;
500
- }
501
- popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
502
- }
503
- };
504
- SGPBPopup.prototype.formSubmissionDetection = function(args) {
505
- if (args.length) {
506
- return false;
507
- }
508
- var popupId = args.popupId;
509
- var options = SGPBPopup.getPopupOptionsById(popupId);
510
- if (!options['sgpb-reopen-after-form-submission']) {
511
- return false;
512
- }
513
- jQuery('.sgpb-popup-builder-content-' + popupId + ' form').submit(function() {
514
- SGPBPopup.setCookie('SGPBSubmissionReloadPopup', popupId);
515
- });
516
- };
517
- SGPBPopup.prototype.htmlIframeFilterForOpen = function(popupId, popupEventName) {
518
- var popupContent = jQuery('.sgpb-content-' + popupId);
519
- if (!popupContent.length) {
520
- return false;
521
- }
522
- popupContent.find('iframe').each(function() {
523
- if (popupEventName != 'open') {
524
- if (jQuery(this).closest('.fb_iframe_widget').length) {
525
- return true;
526
- }
527
- jQuery(this).attr('data-attr-src', src);
528
- jQuery(this).attr('src', '');
529
- return true;
530
- } else {
531
- var src = jQuery(this).attr('data-attr-src');
532
- jQuery(this).attr('src', src);
533
- }
534
- });
535
- };
536
- SGPBPopup.prototype.getSearchDataFromContent = function(content) {
537
- var pattern = /\[(\[?)(pbvariable)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/gi;
538
- var match;
539
- var collectedData = [];
540
- while (match = pattern.exec(content)) {
541
- var currentSearchData = [];
542
- var attributes;
543
- var attributesKeyValue = [];
544
- var parseAttributes = /\s(\w+?)="(.+?)"/g;
545
- currentSearchData['replaceString'] = this.htmlDecode(match[0]);
546
- while (attributes = parseAttributes.exec(match[3])) {
547
- attributesKeyValue[attributes[1]] = this.htmlDecode(attributes[2]);
548
- }
549
- currentSearchData['searchData'] = attributesKeyValue;
550
- collectedData.push(currentSearchData);
551
- }
552
- return collectedData;
553
- };
554
- SGPBPopup.prototype.replaceWithCustomShortcode = function(popupId) {
555
- var currentHtmlContent = jQuery('.sgpb-content-' + popupId).html();
556
- var searchData = this.getSearchDataFromContent(currentHtmlContent);
557
- var that = this;
558
- if (!searchData.length) {
559
- return false;
560
- }
561
- for (var index in searchData) {
562
- var currentSearchData = searchData[index];
563
- var searchAttributes = currentSearchData['searchData'];
564
- if (typeof searchAttributes['selector'] == 'undefined' || typeof searchAttributes['attribute'] == 'undefined') {
565
- that.replaceShortCode(currentSearchData['replaceString'], '');
566
- continue;
567
- }
568
- try {
569
- if (!jQuery(searchAttributes['selector']).length) {
570
- that.replaceShortCode(currentSearchData['replaceString'], '');
571
- continue;
572
- }
573
- } catch (e) {
574
- that.replaceShortCode(currentSearchData['replaceString'], '');
575
- continue;
576
- }
577
- var replaceName = jQuery(searchAttributes['selector']).attr(searchAttributes['attribute']);
578
- if (typeof replaceName == 'undefined') {
579
- that.replaceShortCode(currentSearchData['replaceString'], '');
580
- continue;
581
- }
582
- that.replaceShortCode(currentSearchData['replaceString'], replaceName, popupId);
583
- }
584
- };
585
- SGPBPopup.prototype.replaceShortCode = function(shortCode, replaceText, popupId) {
586
- var popupId = parseInt(popupId);
587
- if (!popupId) {
588
- return false;
589
- }
590
- var popupContentWrapper = jQuery('.sgpb-content-' + popupId);
591
- if (!popupContentWrapper.length) {
592
- return false;
593
- }
594
- popupContentWrapper.find('div').each(function() {
595
- var currentHtmlContent = jQuery(this).contents();
596
- if (!currentHtmlContent.length) {
597
- return false;
598
- }
599
- for (var index in currentHtmlContent) {
600
- var currentChild = currentHtmlContent[index];
601
- var currentChildNodeValue = currentChild.nodeValue;
602
- var currentChildNodeType = currentChild.nodeType;
603
- if (currentChildNodeType != Node.TEXT_NODE) {
604
- continue;
605
- }
606
- if (currentChildNodeValue.indexOf(shortCode) != -1) {
607
- currentChild.nodeValue = currentChildNodeValue.replace(shortCode, replaceText);
608
- }
609
- }
610
- });
611
- return true;
612
- };
613
- SGPBPopup.prototype.popupTriggeringListeners = function() {
614
- var that = this;
615
- var popupData = this.getPopupData();
616
- var popupConfig = this.getPopupConfig();
617
- sgAddEvent(window, 'sgpbDidOpen', function(e) {
618
- var args = e.detail;
619
- that.formSubmissionDetection(args);
620
- var popupOptions = args.popupData;
621
- if (typeof SGPB_ANALYTICS_PARAMS == 'undefined') {
622
- that.addToCounter(popupOptions['sgpb-post-id']);
623
- }
624
- var closeButtonDelay = parseInt(popupOptions['sgpb-close-button-delay']);
625
- if (closeButtonDelay) {
626
- that.closeButtonDisplay(popupOptions['sgpb-post-id'], 'show', closeButtonDelay);
627
- }
628
- var disablePageScrolling = popupOptions['sgpb-disable-page-scrolling'];
629
- if (popupOptions['sgpb-overlay-color']) {
630
- jQuery('.sgpb-theme-1-overlay').css({
631
- 'background-image': 'none'
632
- });
633
- }
634
- if (SGPBPopup.varToBool(disablePageScrolling)) {
635
- jQuery('html').css({
636
- overflow: 'hidden'
637
- });
638
- }
639
- });
640
- sgAddEvent(window, 'sgpbWillOpen', function(e) {
641
- var args = e.detail;
642
- var popupId = parseInt(args['popupId']);
643
- that.htmlIframeFilterForOpen(args.popupId, 'open');
644
- that.replaceWithCustomShortcode(popupId);
645
- that.sgpbDontShowPopup(popupId);
646
- var autoCloseStatus = SGPBPopup.varToBool(popupData['sgpb-auto-close']);
647
- var closeButtonDelay = parseInt(popupData['sgpb-close-button-delay']);
648
- if (closeButtonDelay) {
649
- that.closeButtonDisplay(popupData['sgpb-post-id'], 'hide');
650
- }
651
- if (autoCloseStatus) {
652
- var autoCloseTime = parseInt(popupData['sgpb-auto-close-time']) * 1000;
653
- setTimeout(function() {
654
- SGPBPopup.closePopupById(that.getPopupId());
655
- }, autoCloseTime);
656
- }
657
- });
658
- sgAddEvent(window, 'sgpbShouldClose', function(e) {});
659
- sgAddEvent(window, 'sgpbWillClose', function(e) {
660
- var args = e.detail;
661
- that.htmlIframeFilterForOpen(args.popupId, 'close');
662
- SGPBPopup.offPopup(e.detail.currentObj);
663
- });
664
- };
665
- SGPBPopup.prototype.sgpbDontShowPopup = function(popupId) {
666
- var dontShowPopup = jQuery('#sg-popup-content-wrapper-' + popupId + ' [class^=sg-popup-dont-show]');
667
- if (!dontShowPopup.length) {
668
- return false;
669
- }
670
- dontShowPopup.each(function() {
671
- jQuery(this).bind('click', function(e) {
672
- e.preventDefault();
673
- var expireTime = SGPB_POPUP_PARAMS.dontShowPopupExpireTime;
674
- var cookieName = 'sgDontShowPopup' + popupId;
675
- var classNameSearch = jQuery(this).attr('class').match(/^sg-popup-dont-show/);
676
- var className = classNameSearch['input'];
677
- var customExpireTime = className.match(/^sg-popup-dont-show-(\d+$)/);
678
- if (customExpireTime) {
679
- expireTime = parseInt(customExpireTime[1]);
680
- }
681
- SGPBPopup.setCookie(cookieName, expireTime, expireTime);
682
- SGPBPopup.closePopupById(popupId);
683
- });
684
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
685
  }
686
- SGPBPopup.prototype.addToCounter = function(popupId) {
687
- if (SGPB_POPUP_PARAMS.isPreview != '') {
688
- return false;
689
- }
690
- var params = {};
691
- params.popupId = popupId;
692
- var data = {
693
- action: 'sgpb_send_to_open_counter',
694
- nonce: SGPB_JS_PARAMS.nonce,
695
- params: params
696
- };
697
- jQuery.post(SGPB_JS_PARAMS.ajaxUrl, data, function(res) {});
698
- };
699
- SGPBPopup.prototype.closeButtonDisplay = function(popupId, display, delay) {
700
- if (display == 'show') {
701
- setTimeout(function() {
702
- jQuery('.sgpb-content-' + popupId).prev().show();
703
- }, delay * 1000);
704
- } else if (display == 'hide') {
705
- jQuery('.sgpb-content-' + popupId).prev().hide();
706
- }
707
- };
708
- SGPBPopup.prototype.open = function() {
709
- var config = this.getPopupConfig();
710
- var popupId = this.getPopupId();
711
- var eventName = this.eventName;
712
- if (typeof window.sgPopupBuilder == 'undefined') {
713
- window.sgPopupBuilder = [];
714
- }
715
- var popupData = SGPBPopup.getPopupWindowDataById(popupId);
716
- if (!popupData) {
717
- window.SGPB_ORDER += 1;
718
- var currentObj = {
719
- 'eventName': eventName,
720
- 'popupId': popupId,
721
- 'order': window.SGPB_ORDER,
722
- 'isOpen': true
723
- };
724
- config.currentObj = currentObj;
725
- var popupConfig = config.combineConfigObj();
726
- var popup = new SGPopup(popupConfig);
727
- currentObj.popup = popup;
728
- window.sgPopupBuilder.push(currentObj);
729
- } else {
730
- popup = popupData['popup'];
731
- popupData['isOpen'] = true;
732
- }
733
- popup.open();
734
- this.setPopupObj(popup);
735
- var options = SGPBPopup.getPopupOptionsById(popupId);
736
- if (typeof options['sgpb-behavior-after-special-events'] != 'undefined') {
737
- if (options['sgpb-behavior-after-special-events'].length) {
738
- options = options['sgpb-behavior-after-special-events'][0][0];
739
- if (options['param'] == 'contact-form-7') {
740
- SgpbEventListener.processCF7MailSent(popupId, options);
741
- }
742
- }
743
- }
744
- };
745
- SGPBPopup.varToBool = function(optionName) {
746
- var returnValue = optionName ? true : false;
747
- return returnValue;
748
- };
749
- SGPBPopup.hexToRgba = function(hex, opacity) {
750
- var c;
751
- if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
752
- c = hex.substring(1).split('');
753
- if (c.length == 3) {
754
- c = [c[0], c[0], c[1], c[1], c[2], c[2]];
755
- }
756
- c = '0x' + c.join('');
757
- return 'rgba(' + [(c >> 16) & 255, (c >> 8) & 255, c & 255].join(',') + ',' + opacity + ')';
758
- }
759
- throw new Error('Bad Hex');
760
- };
761
- SGPBPopup.prototype.contentCopyToClick = function() {
762
- var popupData = this.getPopupData();
763
- var popupId = this.getPopupId();
764
- var textAreaId = 'content-copy-to-click-' + popupId;
765
- var value = this.htmlDecode(popupData['sgpb-copy-to-clipboard-text']);
766
- var textArea = jQuery('<textarea>', {
767
- id: textAreaId,
768
- value: value,
769
- style: 'position: absolute; right: -10000px'
770
- });
771
- if (!jQuery('#' + textAreaId).length) {
772
- jQuery('body').append(textArea);
773
- }
774
- jQuery('#' + textAreaId).select();
775
- document.execCommand('copy');
776
- jQuery('#' + textAreaId).remove();
777
- };
778
- SGPBPopup.prototype.htmlDecode = function(value) {
779
- return jQuery('<textarea/>').html(value).text();
780
- };
781
- SGPBPopup.prototype.findTargetInsideExceptionsList = function(targetName, exceptionList) {
782
- var status = false;
783
- var popupContentMainDiv = document.getElementById('sgpb-popup-dialog-main-div');
784
- while (targetName.parentNode) {
785
- targetName = targetName.parentNode;
786
- var tagName = targetName.tagName.toLowerCase();
787
- if (targetName === popupContentMainDiv) {
788
- break;
789
- }
790
- if (exceptionList.indexOf(tagName) != -1) {
791
- status = true;
792
- break;
793
- }
794
- }
795
- return status;
796
- };
797
- SGPBPopup.prototype.contentCloseBehavior = function() {
798
- var that = this;
799
- var popupData = this.getPopupData();
800
- var popupId = this.getPopupId();
801
- var redirectUrl = popupData['sgpb-click-redirect-to-url'];
802
- var contentClickBehavior = popupData['sgpb-content-click-behavior'];
803
- var redirectToNewTab = SGPBPopup.varToBool(popupData['sgpb-redirect-to-new-tab']);
804
- sgAddEvent(window, 'sgpbDidOpen', function(e) {});
805
- sgAddEvent(window, 'sgpbWillOpen', function(e) {
806
- if (popupId != e.detail.popupId || e.detail.popupData['sgpb-content-click'] == 'undefined') {
807
- return false;
808
- }
809
- jQuery('.sgpb-content-' + e.detail.popupId).on('click', function(event) {
810
- if (contentClickBehavior == 'redirect') {
811
- if (redirectToNewTab) {
812
- window.open(redirectUrl);
813
- SGPBPopup.closePopupById(that.getPopupId());
814
- return;
815
- }
816
- window.location = redirectUrl;
817
- SGPBPopup.closePopupById(that.getPopupId());
818
- } else if (contentClickBehavior == 'copy') {
819
- var exceptionList = ['input', 'textarea', 'select', 'button', 'a'];
820
- var targetName = event.target.tagName.toLowerCase();
821
- var parentTagName = event.target.parentNode.tagName.toLowerCase();
822
- var parentsIsInExceptionsList = that.findTargetInsideExceptionsList(event.target, exceptionList);
823
- if (exceptionList.indexOf(targetName) == -1 && !parentsIsInExceptionsList) {
824
- that.contentCopyToClick();
825
- }
826
- } else if (popupData['sgpb-disable-popup-closing'] != 'on') {
827
- SGPBPopup.closePopupById(that.getPopupId());
828
- }
829
- });
830
- });
831
- sgAddEvent(window, 'sgpbDidClose', function(e) {});
832
- };
833
- SGPBPopup.prototype.addFixedPosition = function() {
834
- var popupData = this.getPopupData();
835
- var popupId = this.getPopupId();
836
- var popupConfig = this.getPopupConfig();
837
- var fixedPosition = popupData['sgpb-popup-fixed-position'];
838
- var positionRight = '';
839
- var positionTop = '';
840
- var positionBottom = '';
841
- var positionLeft = '';
842
- if (fixedPosition == 1) {
843
- positionTop = 40;
844
- positionLeft = 20;
845
- } else if (fixedPosition == 2) {
846
- positionLeft = 'center';
847
- positionTop = 40;
848
- } else if (fixedPosition == 3) {
849
- positionTop = 40;
850
- positionRight = 20;
851
- } else if (fixedPosition == 4) {
852
- positionTop = 'center';
853
- positionLeft = 20;
854
- } else if (fixedPosition == 6) {
855
- positionTop = 'center';
856
- positionRight = 20;
857
- } else if (fixedPosition == 7) {
858
- positionLeft = 20;
859
- positionBottom = 2;
860
- } else if (fixedPosition == 8) {
861
- positionLeft = 'center';
862
- positionBottom = 2;
863
- } else if (fixedPosition == 9) {
864
- positionRight = 20;
865
- positionBottom = 2;
866
- }
867
- popupConfig.magicCall('setPositionTop', positionTop);
868
- popupConfig.magicCall('setPositionRight', positionRight);
869
- popupConfig.magicCall('setPositionBottom', positionBottom);
870
- popupConfig.magicCall('setPositionLeft', positionLeft);
871
- };
872
- SGPBPopup.prototype.setPopupDimensions = function() {
873
- var popupData = this.getPopupData();
874
- var popupConfig = this.getPopupConfig();
875
- var popupId = this.getPopupId();
876
- var dimensionData = popupData['sgpb-popup-dimension-mode'];
877
- var maxWidth = popupData['sgpb-max-width'];
878
- var maxHeight = popupData['sgpb-max-height'];
879
- var minWidth = popupData['sgpb-min-width'];
880
- var minHeight = popupData['sgpb-min-height'];
881
- var contentPadding = popupData['sgpb-content-padding'];
882
- popupConfig.magicCall('setMaxWidth', maxWidth);
883
- popupConfig.magicCall('setMaxHeight', maxHeight);
884
- popupConfig.magicCall('setMinWidth', minWidth);
885
- popupConfig.magicCall('setMinHeight', minHeight);
886
- if (dimensionData == 'responsiveMode') {
887
- var dimensionMeasure = popupData['sgpb-responsive-dimension-measure'];
888
- var popupConfig = this.getPopupConfig();
889
- if (dimensionMeasure != 'auto') {
890
- popupConfig.magicCall('setWidth', dimensionMeasure + '%');
891
- } else {
892
- popupConfig.magicCall('setWidth', jQuery('.sgpb-popup-builder-content-' + popupId).width() + (contentPadding * 2) + 'px');
893
- }
894
- return popupConfig;
895
- }
896
- var popupWidth = popupData['sgpb-width'];
897
- var popupHeight = popupData['sgpb-height'];
898
- popupConfig.magicCall('setWidth', popupWidth);
899
- popupConfig.magicCall('setHeight', popupHeight);
900
- return popupConfig;
901
- };
902
- SGPBPopup.unserialize = function(data) {
903
- var $global = (typeof window !== 'undefined' ? window : global);
904
- var utf8Overhead = function(str) {
905
- var s = str.length;
906
- for (var i = str.length - 1; i >= 0; i--) {
907
- var code = str.charCodeAt(i)
908
- if (code > 0x7f && code <= 0x7ff) {
909
- s++;
910
- } else if (code > 0x7ff && code <= 0xffff) {
911
- s += 2;
912
- }
913
- if (code >= 0xDC00 && code <= 0xDFFF) {
914
- i--;
915
- }
916
- }
917
- return s - 1;
918
- }
919
- var error = function(type, msg, filename, line) {
920
- throw new $global[type](msg, filename, line);
921
- }
922
- var readUntil = function(data, offset, stopchr) {
923
- var i = 2;
924
- var buf = [];
925
- var chr = data.slice(offset, offset + 1);
926
- while (chr !== stopchr) {
927
- if ((i + offset) > data.length) {
928
- error('Error', 'Invalid');
929
- }
930
- buf.push(chr);
931
- chr = data.slice(offset + (i - 1), offset + i);
932
- i += 1;
933
- }
934
- return [buf.length, buf.join('')];
935
- }
936
- var readChrs = function(data, offset, length) {
937
- var i, chr, buf
938
- buf = []
939
- for (i = 0; i < length; i++) {
940
- chr = data.slice(offset + (i - 1), offset + i);
941
- buf.push(chr);
942
- length -= utf8Overhead(chr);
943
- }
944
- return [buf.length, buf.join('')];
945
- }
946
-
947
- function _unserialize(data, offset) {
948
- var dtype
949
- var dataoffset
950
- var keyandchrs
951
- var keys
952
- var contig
953
- var length
954
- var array
955
- var readdata
956
- var readData
957
- var ccount
958
- var stringlength
959
- var i
960
- var key
961
- var kprops
962
- var kchrs
963
- var vprops
964
- var vchrs
965
- var value
966
- var chrs = 0
967
- var typeconvert = function(x) {
968
- return x
969
- }
970
- if (!offset) {
971
- offset = 0
972
- }
973
- dtype = (data.slice(offset, offset + 1)).toLowerCase()
974
- dataoffset = offset + 2
975
- switch (dtype) {
976
- case 'i':
977
- typeconvert = function(x) {
978
- return parseInt(x, 10);
979
- }
980
- readData = readUntil(data, dataoffset, ';');
981
- chrs = readData[0];
982
- readdata = readData[1];
983
- dataoffset += chrs + 1;
984
- break;
985
- case 'b':
986
- typeconvert = function(x) {
987
- return parseInt(x, 10) !== 0;
988
- }
989
- readData = readUntil(data, dataoffset, ';');
990
- chrs = readData[0];
991
- readdata = readData[1];
992
- dataoffset += chrs + 1;
993
- break;
994
- case 'd':
995
- typeconvert = function(x) {
996
- return parseFloat(x);
997
- }
998
- readData = readUntil(data, dataoffset, ';');
999
- chrs = readData[0];
1000
- readdata = readData[1];
1001
- dataoffset += chrs + 1;
1002
- break;
1003
- case 'n':
1004
- readdata = null
1005
- break
1006
- case 's':
1007
- ccount = readUntil(data, dataoffset, ':')
1008
- chrs = ccount[0]
1009
- stringlength = ccount[1]
1010
- dataoffset += chrs + 2
1011
- readData = readChrs(data, dataoffset + 1, parseInt(stringlength, 10))
1012
- chrs = readData[0]
1013
- readdata = readData[1]
1014
- dataoffset += chrs + 2
1015
- if (chrs !== parseInt(stringlength, 10) && chrs !== readdata.length) {
1016
- error('SyntaxError', 'String length mismatch')
1017
- }
1018
- break;
1019
- case 'a':
1020
- readdata = {};
1021
- keyandchrs = readUntil(data, dataoffset, ':');
1022
- chrs = keyandchrs[0];
1023
- keys = keyandchrs[1];
1024
- dataoffset += chrs + 2;
1025
- length = parseInt(keys, 10);
1026
- contig = true;
1027
- for (i = 0; i < length; i++) {
1028
- kprops = _unserialize(data, dataoffset);
1029
- kchrs = kprops[1];
1030
- key = kprops[2];
1031
- dataoffset += kchrs;
1032
- vprops = _unserialize(data, dataoffset);
1033
- vchrs = vprops[1];
1034
- value = vprops[2];
1035
- dataoffset += vchrs;
1036
- if (key !== i) {
1037
- contig = false;
1038
- }
1039
- readdata[key] = value;
1040
- }
1041
- if (contig) {
1042
- array = new Array(length)
1043
- for (i = 0; i < length; i++) {
1044
- array[i] = readdata[i];
1045
- }
1046
- readdata = array;
1047
- }
1048
- dataoffset += 1;
1049
- break;
1050
- default:
1051
- error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
1052
- break;
1053
- }
1054
- return [dtype, dataoffset - offset, typeconvert(readdata)]
1055
- }
1056
- return _unserialize((data + ''), 0)[2];
1057
- };
1058
- SGPBPopup.closePopup = function() {
1059
- var popupObjs = window.sgPopupBuilder;
1060
- var lastPopupObj = this.getLastPopup();
1061
- if (typeof lastPopupObj == 'undefined') {
1062
- return false;
1063
- }
1064
- var popupId = lastPopupObj.popupId;
1065
- SGPBPopup.closePopupById(popupId);
1066
- };
1067
- SGPBPopup.closePopupById = function(popupId) {
1068
- var popupObjs = window.sgPopupBuilder;
1069
- if (!popupObjs.length) {
1070
- return;
1071
- }
1072
- for (var i in popupObjs) {
1073
- var currentObj = popupObjs[i];
1074
- if (currentObj.popupId == popupId) {
1075
- var popupObj = popupObjs[i]['popup'];
1076
- if (popupObj) {
1077
- popupObj.close(true);
1078
- }
1079
- }
1080
- }
1081
- };
1082
- SGPBPopup.getPopupWindowDataById = function(popupId) {
1083
- var popups = window.sgPopupBuilder;
1084
- var popup = false;
1085
- if (typeof popups == 'undefined' || !popups.length) {
1086
- return popup;
1087
- }
1088
- for (var i in popups) {
1089
- var popupData = popups[i];
1090
- if (popupData.popupId == popupId) {
1091
- popup = popupData;
1092
- break;
1093
- }
1094
- }
1095
- return popup;
1096
- };
1097
- SGPBPopup.findPopupObjById = function(popupId) {
1098
- var popup = false;
1099
- var popupData = SGPBPopup.getPopupWindowDataById(popupId);
1100
- if (popupData) {
1101
- popup = popupData['popup'];
1102
- }
1103
- return popup;
1104
- };
1105
- SGPBPopup.getLastPopup = function() {
1106
- var popups = window.sgPopupBuilder;
1107
- var popup = false;
1108
- if (!popups.length) {
1109
- return popup;
1110
- }
1111
- var searchPopups = [].concat(popups);
1112
- for (var i in searchPopups) {
1113
- var popupData = searchPopups[i];
1114
- if (popupData.isOpen) {
1115
- popup = popupData;
1116
- break;
1117
- }
1118
- }
1119
- return popup;
1120
- };
1121
- SGPBPopup.offPopup = function(currentPopup) {
1122
- var popups = window.sgPopupBuilder;
1123
- if (!popups.length) {
1124
- return false;
1125
- }
1126
- for (var i in popups) {
1127
- var popupData = popups[i];
1128
- if (popupData.order == currentPopup.order && popupData.eventName == currentPopup.eventName) {
1129
- popups[i]['isOpen'] = false;
1130
- break;
1131
- }
1132
- }
1133
- return true;
1134
- };
1135
- SGPBPopup.capitalizeFirstLetter = function(string) {
1136
- return string.charAt(0).toUpperCase() + string.slice(1);
1137
- };
1138
- SGPBPopup.getParamFromUrl = function(param) {
1139
- var url = window.location.href;
1140
- param = param.replace(/[\[\]]/g, "\\$&");
1141
- var regex = new RegExp("[?&]" + param + "(=([^&#]*)|&|#|$)"),
1142
- results = regex.exec(url);
1143
- if (!results) {
1144
- return null;
1145
- }
1146
- if (!results[2]) {
1147
- return '';
1148
- }
1149
- return decodeURIComponent(results[2].replace(/\+/g, " "));
1150
- };
1151
- SGPBPopup.setCookie = function(cName, cValue, exDays, cPageLevel) {
1152
- var isPreview = SGPBPopup.getParamFromUrl('preview');
1153
- if (isPreview) {
1154
- return false;
1155
- }
1156
- var expirationDate = new Date();
1157
- var cookiePageLevel = 'path=/;';
1158
- var cookieExpirationData = 1;
1159
- if (!exDays || isNaN(exDays)) {
1160
- exDays = 365 * 50;
1161
- }
1162
- if (typeof cPageLevel == 'undefined') {
1163
- cPageLevel = false;
1164
- }
1165
- expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
1166
- cookieExpirationData = expirationDate.toString();
1167
- var expires = 'expires=' + cookieExpirationData;
1168
- if (exDays == -1) {
1169
- expires = '';
1170
- }
1171
- if (cPageLevel) {
1172
- cookiePageLevel = 'path=' + cPageLevel + ';';
1173
- }
1174
- var value = cValue + ((exDays == null) ? ';' : '; ' + expires + ';' + cookiePageLevel);
1175
- document.cookie = cName + '=' + value;
1176
- };
1177
- SGPBPopup.getCookie = function(cName) {
1178
- var name = cName + '=';
1179
- var ca = document.cookie.split(';');
1180
- for (var i = 0; i < ca.length; i++) {
1181
- var c = ca[i];
1182
- while (c.charAt(0) == ' ') {
1183
- c = c.substring(1);
1184
- }
1185
- if (c.indexOf(name) == 0) {
1186
- return c.substring(name.length, c.length);
1187
- }
1188
- }
1189
- return '';
1190
- };
1191
- SGPBPopup.deleteCookie = function(cName, cPath) {
1192
- if (!cPath) {
1193
- cPath = 'path=/;';
1194
- }
1195
- document.cookie = cName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' + cPath;
1196
- };
1197
-
1198
- function SgpbEventListener() {
1199
- this.evenets = null;
1200
- this.popupObj = {};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1201
  }
 
1202
  SgpbEventListener.inactivityIdicator = 0;
1203
- SgpbEventListener.prototype.setEvents = function(events) {
1204
- this.evenets = events;
1205
- };
1206
- SgpbEventListener.prototype.getEvents = function() {
1207
- return this.evenets;
1208
- };
1209
- SgpbEventListener.prototype.setPopupObj = function(popupObj) {
1210
- this.popupObj = popupObj;
1211
- };
1212
- SgpbEventListener.prototype.getPopupObj = function() {
1213
- return this.popupObj;
1214
- };
1215
- SgpbEventListener.init = function() {
1216
- var popupsData = jQuery('.sg-popup-builder-content');
1217
- if (!popupsData) {
1218
- return '';
1219
- }
1220
- var that = this;
1221
- popupsData.each(function() {
1222
- that.popupObjCreator(jQuery(this));
1223
- });
1224
- };
1225
- SgpbEventListener.popupObjCreator = function(currentData) {
1226
- var popupId = currentData.data('id');
1227
- var popupData = currentData.data('options');
1228
- var events = currentData.data('events');
1229
- SgpbEventListener.reopenAfterFormSubmission(popupData);
1230
- var popupObj = new SGPBPopup();
1231
- popupObj.setPopupId(popupId);
1232
- popupObj.setPopupData(popupData);
1233
- for (var i in events) {
1234
- var obj = new this;
1235
- obj.setPopupObj(popupObj);
1236
- obj.eventListener(events[i]);
1237
- }
1238
- };
1239
- SgpbEventListener.prototype.eventListener = function(eventData) {
1240
- if (eventData == null) {
1241
- return '';
1242
- }
1243
- var event = '';
1244
- if (typeof eventData == 'string') {
1245
- event = eventData;
1246
- } else if (typeof eventData.param != 'undefined') {
1247
- event = eventData.param;
1248
- }
1249
- if (!event) {
1250
- return false;
1251
- }
1252
- var popupObj = this.getPopupObj();
1253
- var popupData = popupObj.getPopupData();
1254
- if (eventData.value == '') {
1255
- eventData.value = popupData['sgpb-popup-delay'];
1256
- }
1257
- var eventName = SGPBPopup.capitalizeFirstLetter(event);
1258
- eventName = 'sgpb' + eventName;
1259
- popupObj.eventName = eventName;
1260
- try {
1261
- eval('this.' + eventName)(this, eventData);
1262
- } catch (err) {
1263
- console.log(err)
1264
- }
1265
- };
1266
- SgpbEventListener.reopenAfterFormSubmission = function(eventData) {
1267
- var popupId = SGPBPopup.getCookie('SGPBSubmissionReloadPopup');
1268
- popupId = parseInt(popupId);
1269
- if (!popupId) {
1270
- return false;
1271
- }
1272
- var popupObj = SGPBPopup.createPopupObjById(popupId);
1273
- if (!popupObj) {
1274
- return false;
1275
- }
1276
- var options = popupObj.getPopupData();
1277
- if (!options['sgpb-reopen-after-form-submission']) {
1278
- return false;
1279
- }
1280
- popupObj.prepareOpen();
1281
- SGPBPopup.deleteCookie('SGPBSubmissionReloadPopup');
1282
- };
1283
- SgpbEventListener.prototype.sgpbLoad = function(listenerObj, eventData) {
1284
- var timeout = parseInt(eventData.value);
1285
- var popupObj = listenerObj.getPopupObj();
1286
- timeout = timeout * 1000;
1287
- var timerId, repetitiveTimeout = null;
1288
- sgAddEvent(window, 'load', function() {
1289
- clearInterval(timerId);
1290
- timerId = setTimeout(function() {
1291
- popupObj.prepareOpen();
1292
- }, timeout);
1293
- });
1294
- sgAddEvent(window, 'sgpbDidOpen', function(e) {
1295
- var args = e.detail;
1296
- clearInterval(repetitiveTimeout);
1297
- });
1298
- sgAddEvent(window, 'sgpbDidClose', function(e) {
1299
- var args = e.detail;
1300
- var options = popupObj.getPopupData();
1301
- if (SGPBPopup.varToBool(eventData['repetitive'])) {
1302
- var intervalTime = parseInt(eventData['value']) * 1000;
1303
- repetitiveTimeout = setInterval(function() {
1304
- popupObj.prepareOpen();
1305
- }, intervalTime);
1306
- }
1307
- });
1308
- };
1309
- SgpbEventListener.prototype.timerIncrement = function(listenerObj, idleInterval) {
1310
- var lastActivity = SgpbEventListener.inactivityIdicator;
1311
- if (lastActivity == 0) {
1312
- clearInterval(idleInterval);
1313
- listenerObj.getPopupObj().prepareOpen();
1314
- }
1315
- SgpbEventListener.inactivityIdicator = 0;
1316
- };
1317
- SgpbEventListener.prototype.sgpbOnScroll = function(listenerObj, eventData) {
1318
- var that = this;
1319
- var percent = parseInt(eventData.value);
1320
- var scrollStatus = false;
1321
- jQuery(window).on('scroll', function() {
1322
- var scrollTop = jQuery(window).scrollTop();
1323
- var docHeight = jQuery(document).height();
1324
- var winHeight = jQuery(window).height();
1325
- var scrollPercent = (scrollTop) / (docHeight - winHeight);
1326
- var scrollPercentRounded = Math.round(scrollPercent * 100);
1327
- if (percent < scrollPercentRounded) {
1328
- if (scrollStatus == false) {
1329
- listenerObj.getPopupObj().prepareOpen();
1330
- scrollStatus = true;
1331
- }
1332
- }
1333
- });
1334
- };
1335
- SgpbEventListener.prototype.sgpbInsideclick = function(listenerObj, eventData) {
1336
- sgAddEvent(window, 'sgpbDidOpen', function(e) {
1337
- var args = e.detail;
1338
- var that = listenerObj;
1339
- var popupObj = that.getPopupObj();
1340
- var popupId = parseInt(popupObj.id);
1341
- var targetClick = jQuery('.sgpb-content .sgpb-popup-id-' + popupId);
1342
- if (!targetClick.length) {
1343
- return false;
1344
- }
1345
- targetClick.each(function() {
1346
- jQuery(this).unbind('click').bind('click', function() {
1347
- SGPBPopup.closePopup();
1348
- popupObj.prepareOpen();
1349
- });
1350
- });
1351
- });
1352
- };
1353
- SgpbEventListener.prototype.sgpbClick = function(listenerObj, eventData) {
1354
- var that = listenerObj;
1355
- var popupIds = [];
1356
- var popupObj = that.getPopupObj();
1357
- var popupOptions = popupObj.getPopupData();
1358
- var popupId = parseInt(popupObj.id);
1359
- popupIds.push(popupId);
1360
- var mapId = listenerObj.filterPopupId(popupId);
1361
- popupIds.push(mapId);
1362
- for (var key in popupIds) {
1363
- var popupId = popupIds[key];
1364
- if (!popupIds.hasOwnProperty(key)) {
1365
- return false;
1366
- }
1367
- var targetClick = jQuery('a[href*=#sg-popup-id-' + popupId + '], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId);
1368
- if (!targetClick.length) {
1369
- continue;
1370
- }
1371
- var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1372
- var clickCount = 1;
1373
- targetClick.each(function() {
1374
- jQuery(this).bind('click', function(e) {
1375
- e.preventDefault();
1376
- if (clickCount > 1) {
1377
- return false;
1378
- }
1379
- ++clickCount;
1380
- jQuery(window).trigger('sgpbClickEvent', popupOptions);
1381
- setTimeout(function() {
1382
- popupObj.prepareOpen();
1383
- clickCount = 1;
1384
- }, delay);
1385
- });
1386
- });
1387
- }
1388
- };
1389
- SgpbEventListener.prototype.sgpbHover = function(listenerObj, eventData) {
1390
- var that = listenerObj;
1391
- var popupObj = that.getPopupObj();
1392
- if (!popupObj) {
1393
- return false;
1394
- }
1395
- var popupIds = [];
1396
- var popupOptions = popupObj.getPopupData();
1397
- var popupId = parseInt(popupObj.id);
1398
- popupIds.push(popupId);
1399
- var mapId = listenerObj.filterPopupId(popupId);
1400
- popupIds.push(mapId);
1401
- for (var key in popupIds) {
1402
- var popupId = popupIds[key];
1403
- if (!popupIds.hasOwnProperty(key)) {
1404
- return false;
1405
- }
1406
- var hoverSelector = jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]');
1407
- if (!hoverSelector) {
1408
- return false;
1409
- }
1410
- var hoverCount = 1;
1411
- var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1412
- hoverSelector.bind('hover', function() {
1413
- if (hoverCount > 1) {
1414
- return false;
1415
- }
1416
- ++hoverCount;
1417
- jQuery(window).trigger('sgpbHoverEvent', popupOptions);
1418
- setTimeout(function() {
1419
- popupObj.prepareOpen();
1420
- hoverCount = 1;
1421
- }, delay);
1422
- });
1423
- }
1424
- };
1425
- SgpbEventListener.prototype.sgpbConfirm = function(listenerObj, eventData) {
1426
- var that = listenerObj;
1427
- var popupObj = that.getPopupObj();
1428
- if (!popupObj) {
1429
- return false;
1430
- }
1431
- var popupIds = [];
1432
- var popupOptions = popupObj.getPopupData();
1433
- var popupId = parseInt(popupObj.id);
1434
- popupIds.push(popupId);
1435
- var mapId = listenerObj.filterPopupId(popupId);
1436
- popupIds.push(mapId);
1437
- for (var key in popupIds) {
1438
- var popupId = popupIds[key];
1439
- if (!popupIds.hasOwnProperty(key)) {
1440
- return false;
1441
- }
1442
- var confirmSelector = jQuery('.sg-confirm-popup-' + popupId);
1443
- if (!confirmSelector) {
1444
- return false;
1445
- }
1446
- var confirmCount = 1;
1447
- confirmSelector.bind('click', function(e) {
1448
- e.preventDefault();
1449
- if (confirmCount > 1) {
1450
- return false;
1451
- }
1452
- ++confirmCount;
1453
- jQuery(window).trigger('sgpbConfirmEvent', popupOptions);
1454
- var target = jQuery(this).attr('target');
1455
- if (typeof target == 'undefined') {
1456
- target = 'self';
1457
- }
1458
- var href = jQuery(this).attr('href');
1459
- var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1460
- setTimeout(function() {
1461
- if (typeof href != 'undefined') {
1462
- popupOptions['sgpb-confirm-' + popupId] = {
1463
- 'target': target,
1464
- 'href': href
1465
- };
1466
- popupObj.setPopupData(popupOptions);
1467
- }
1468
- popupObj.prepareOpen();
1469
- confirmCount = 1;
1470
- }, delay);
1471
- });
1472
- sgAddEvent(window, 'sgpbDidClose', function(e) {
1473
- var args = e.detail;
1474
- var popupId = parseInt(args.popupId);
1475
- var popupOptions = args.popupData;
1476
- if (typeof popupOptions['sgpb-confirm-' + popupId] != 'undefined') {
1477
- var confirmAgrs = popupOptions['sgpb-confirm-' + popupId];
1478
- if (confirmAgrs['target'] == '_blank') {
1479
- window.open(confirmAgrs['href']);
1480
- } else {
1481
- window.location.href = confirmAgrs['href'];
1482
- }
1483
- delete popupOptions['sgpb-confirm-' + popupId];
1484
- popupObj.setPopupData(popupOptions);
1485
- }
1486
- });
1487
- }
1488
- };
1489
- SgpbEventListener.prototype.sgpbIframe = function(listenerObj, eventData) {
1490
- var that = listenerObj;
1491
- var popupObj = that.getPopupObj();
1492
- var popupId = parseInt(popupObj.id);
1493
- popupId = listenerObj.filterPopupId(popupId);
1494
- var popupOptions = popupObj.getPopupData();
1495
- var iframeCount = 1;
1496
- var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1497
- jQuery('.sg-iframe-popup-' + popupId).each(function() {
1498
- jQuery(this).bind('click', function(e) {
1499
- e.preventDefault();
1500
- var link = jQuery(this).attr('href');
1501
- if (typeof link == 'undefined') {
1502
- var childLinkTag = jQuery(this).find('a');
1503
- link = jQuery(this).attr('href');
1504
- if (typeof link == 'undefined') {
1505
- return false;
1506
- }
1507
- }
1508
- if (iframeCount > 1) {
1509
- return false;
1510
- }
1511
- ++iframeCount;
1512
- jQuery(window).trigger('sgpbIframeEvent', popupOptions);
1513
- setTimeout(function() {
1514
- popupOptions['sgpb-iframe-' + popupId] = link;
1515
- popupObj.setPopupData(popupOptions);
1516
- popupObj.prepareOpen();
1517
- var currentIframe = jQuery('.sgpb-popup-builder-content-' + popupId).find('iframe');
1518
- currentIframe.data('attr-src', link);
1519
- iframeCount = 1;
1520
- return false;
1521
- }, delay);
1522
- });
1523
- });
1524
- };
1525
- SgpbEventListener.prototype.sgpbAttronload = function(listenerObj, eventData) {
1526
- var that = listenerObj;
1527
- var popupObj = that.getPopupObj();
1528
- var popupId = parseInt(popupObj.id);
1529
- popupId = listenerObj.filterPopupId(popupId);
1530
- var popupOptions = popupObj.getPopupData();
1531
- var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1532
- jQuery(window).trigger('sgpbAttronloadEvent', popupOptions);
1533
- setTimeout(function() {
1534
- popupObj.prepareOpen();
1535
- }, delay);
1536
- };
1537
- SgpbEventListener.prototype.filterPopupId = function(popupId) {
1538
- var convertedIds = SGPB_POPUP_PARAMS.convertedIdsReverse;
1539
- if (convertedIds[popupId]) {
1540
- return convertedIds[popupId];
1541
- }
1542
- return popupId;
1543
- };
1544
- SgpbEventListener.findCF7InPopup = function(popupId) {
1545
- return document.querySelector('#sg-popup-content-wrapper-' + popupId + ' .wpcf7');
1546
- };
1547
- SgpbEventListener.processCF7MailSent = function(popupId, options) {
1548
- var wpcf7Elm = SgpbEventListener.findCF7InPopup(popupId);
1549
- if (wpcf7Elm) {
1550
- wpcf7Elm.addEventListener('wpcf7mailsent', function(event) {
1551
- if (typeof options['operator'] == 'undefined') {
1552
- return;
1553
- }
1554
- if (options['operator'] == 'close-popup') {
1555
- setTimeout(function() {
1556
- SGPBPopup.closePopupById(popupId);
1557
- }, parseInt(options['value']) * 1000);
1558
- } else if (options['operator'] == 'redirect-url') {
1559
- window.location.href = options['value'];
1560
- } else if (options['operator'] == 'open-popup') {
1561
- SGPBPopup.closePopupById(popupId);
1562
- var popupObj = SGPBPopup.createPopupObjById(Object.keys(options['value'])[0]);
1563
- popupObj.prepareOpen();
1564
- }
1565
- }, false);
1566
- }
1567
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1568
  jQuery(document).ready(function(e) {
1569
- SgpbEventListener.init();
1570
- });
1
+ function sgAddEvent(element, eventName, fn)
2
+ {
3
+ if (element.addEventListener)
4
+ element.addEventListener(eventName, fn, false);
5
+ else if (element.attachEvent)
6
+ element.attachEvent('on' + eventName, fn);
7
  }
8
+ /*Popup order count*/
9
  window.SGPB_ORDER = 0;
10
 
11
+ function SGPBPopup()
12
+ {
13
+ this.id = null;
14
+ this.eventName = '';
15
+ this.popupData = null;
16
+ this.popupConfig = {};
17
+ this.popupObj = null;
18
+ this.onceListener();
19
+ this.initialsListeners();
20
  }
21
+
22
+ SGPBPopup.prototype.initialsListeners = function()
23
+ {
24
+ window.SGPB_SOUND = [];
25
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
26
+ var args = e.detail;
27
+ var popupId = parseInt(args.popupId);
28
+ var options = SGPBPopup.getPopupOptionsById(popupId);
29
+ var soundUrl = options['sgpb-sound-url'];
30
+ var soundStatus = options['sgpb-open-sound'];
31
+
32
+ if (soundStatus && soundUrl && !window.SGPB_SOUND[popupId]) {
33
+ var audio = new Audio(soundUrl);
34
+ audio.play();
35
+ window.SGPB_SOUND[popupId] = audio;
36
+ }
37
+ });
38
+
39
+ sgAddEvent(window, 'sgpbDidClose', function(e) {
40
+ var args = e.detail;
41
+ var popupId = parseInt(args.popupId);
42
+
43
+ if (typeof window.SGPB_SOUND[popupId] && window.SGPB_SOUND[popupId]) {
44
+ window.SGPB_SOUND[popupId].pause();
45
+ delete window.SGPB_SOUND[popupId];
46
+ }
47
+ });
48
+ };
49
+
50
+ SGPBPopup.prototype.onceListener = function()
51
+ {
52
+ var that = this;
53
+
54
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
55
+ jQuery('.sg-popup-close').click(function(){
56
+ var currentPopup = that.getPopupIdForNextEsc();
57
+ if (!currentPopup) {
58
+ return false;
59
+ }
60
+
61
+ SGPBPopup.closePopupById(currentPopup.popupId);
62
+ });
63
+ document.onkeydown = function(e) {
64
+ e = e || window.event;
65
+
66
+ if (e.keyCode == 27) { /*esc pressed*/
67
+ var currentPopup = that.getPopupIdForNextEsc();
68
+ if (!currentPopup) {
69
+ return false;
70
+ }
71
+ var lastPopupId = parseInt(currentPopup['popupId']);
72
+ SGPBPopup.closePopupById(lastPopupId);
73
+ }
74
+ };
75
+ });
76
+
77
+ sgAddEvent(window, 'sgpbDidClose', function(e) {
78
+ if (window.sgPopupBuilder.length != 0) {
79
+ var popups = [].concat(window.sgPopupBuilder).reverse();
80
+ for (var i in popups) {
81
+ var nextIndex = ++i;
82
+ var nextObj = popups[nextIndex];
83
+
84
+ if (typeof nextObj == 'undefined') {
85
+ jQuery('html').css({overflow: 'auto'});
86
+ break;
87
+ }
88
+
89
+ if (nextObj.isOpen == false) {
90
+ continue;
91
+ }
92
+ var options = SGPBPopup.getPopupOptionsById(nextObj.popupId);
93
+ if (typeof options['sgpb-disable-page-scrolling'] == 'undefined') {
94
+ jQuery('html').css({overflow: 'auto'});
95
+ }
96
+ else {
97
+ jQuery('html').css({overflow: 'hidden'});
98
+ }
99
+ break;
100
+ }
101
+ }
102
+ else {
103
+ jQuery('html').css({overflow: 'auto'});
104
+ }
105
+ });
106
+ };
107
+
108
+ SGPBPopup.prototype.getPopupIdForNextEsc = function()
109
+ {
110
+ var popups = window.sgPopupBuilder;
111
+ var popup = false;
112
+
113
+ if (!popups.length) {
114
+ return popup;
115
+ }
116
+
117
+ var searchPopups = [].concat(popups).reverse();
118
+
119
+ for (var i in searchPopups) {
120
+ var popupData = searchPopups[i];
121
+
122
+ if (popupData.isOpen) {
123
+ var popupId = parseInt(popupData['popupId']);
124
+ var popupOptions = SGPBPopup.getPopupOptionsById(popupId);
125
+
126
+ if (!popupOptions['sgpb-disable-popup-closing'] && popupOptions['sgpb-esc-key']) {
127
+ popup = popupData;
128
+ break;
129
+ }
130
+ }
131
+ }
132
+
133
+ return popup;
134
+ };
135
+
136
+ SGPBPopup.prototype.setPopupId = function(popupId)
137
+ {
138
+ this.id = parseInt(popupId);
139
+ };
140
+
141
+ SGPBPopup.prototype.getPopupId = function()
142
+ {
143
+ return this.id;
144
+ };
145
+
146
+ SGPBPopup.prototype.setPopupObj = function(popupObj)
147
+ {
148
+ this.popupObj = popupObj;
149
+ };
150
+
151
+ SGPBPopup.prototype.getPopupObj = function()
152
+ {
153
+ return this.popupObj;
154
+ };
155
+
156
+ SGPBPopup.prototype.setPopupData = function(popupData)
157
+ {
158
+ if (typeof popupData == 'string') {
159
+ var popupData = SGPBPopup.unserialize(popupData);
160
+ }
161
+
162
+ this.popupData = popupData;
163
+ };
164
+
165
+ SGPBPopup.prototype.getPopupData = function()
166
+ {
167
+ return this.popupData;
168
+ };
169
+
170
+ SGPBPopup.prototype.setPopupConfig = function(config)
171
+ {
172
+ this.popupConfig = config;
173
+ };
174
+
175
+ SGPBPopup.prototype.getPopupConfig = function()
176
+ {
177
+ return this.popupConfig;
178
+ };
179
+
180
+ SGPBPopup.prototype.setUpPopupConfig = function()
181
+ {
182
+ var popupConfig = new PopupConfig();
183
+ this.setPopupConfig(popupConfig);
184
+ };
185
+
186
+ SGPBPopup.createPopupObjById = function(popupId)
187
+ {
188
+ var options = SGPBPopup.getPopupOptionsById(popupId);
189
+
190
+ if (!options) {
191
+ return false;
192
+ }
193
+ var popupObj = new SGPBPopup();
194
+ popupObj.setPopupId(popupId);
195
+ popupObj.setPopupData(options);
196
+
197
+ return popupObj;
198
+ };
199
+
200
+
201
+ SGPBPopup.getPopupOptionsById = function(popupId)
202
+ {
203
+ var popupDataDiv = jQuery('#sg-popup-content-wrapper-'+popupId);
204
+
205
+ if (!popupDataDiv.length) {
206
+ return false;
207
+ }
208
+ var options = popupDataDiv.attr('data-options');
209
+
210
+ return SGPBPopup.unserialize(options);
211
+ };
212
+
213
+ SGPBPopup.prototype.getCompatibleZiIndex = function(popupZIndex)
214
+ {
215
+ /*2147483647 it's maximal z index value*/
216
+ if (popupZIndex > 2147483647) {
217
+ return 2147483627;
218
+ }
219
+
220
+ return popupZIndex;
221
+ };
222
+
223
+ SGPBPopup.prototype.prepareOpen = function()
224
+ {
225
+ var popupId = this.getPopupId();
226
+ var popupData = this.getPopupData();
227
+ var popupZIndex = this.getCompatibleZiIndex(popupData['sgpb-popup-z-index']);
228
+ this.setUpPopupConfig();
229
+ var that = this;
230
+
231
+ var popupConfig = this.getPopupConfig();
232
+ this.setPopupDimensions();
233
+
234
+ if (popupData['sgpb-disable-popup-closing'] == 'on') {
235
+ popupData['sgpb-enable-close-button'] = '';
236
+ popupData['sgpb-esc-key'] = '';
237
+ popupData['sgpb-overlay-click'] = '';
238
+ }
239
+ /*used in the analytics*/
240
+ popupData['eventName'] = this.eventName;
241
+
242
+ if (SGPBPopup.varToBool(popupData['sgpb-enable-close-button'])) {
243
+ popupConfig.magicCall('setCloseButtonDelay', parseInt(popupData['sgpb-close-button-delay']));
244
+ }
245
+
246
+ popupConfig.magicCall('setShowButton', SGPBPopup.varToBool(popupData['sgpb-enable-close-button']));
247
+ /* Convert seconds to micro seconds */
248
+ var openAnimationSpeed = parseInt(popupData['sgpb-open-animation-speed'])*1000;
249
+ popupConfig.magicCall('setOpenAnimationEffect', popupData['sgpb-open-animation-effect']);
250
+ popupConfig.magicCall('setOpenAnimationSpeed', openAnimationSpeed);
251
+ popupConfig.magicCall('setOpenAnimationStatus', popupData['sgpb-open-animation']);
252
+ popupConfig.magicCall('setContentPadding', popupData['sgpb-content-padding']);
253
+ popupConfig.magicCall('setZIndex', popupZIndex);
254
+ popupConfig.magicCall('setCloseButtonWidth', popupData['sgpb-button-image-width']);
255
+ popupConfig.magicCall('setCloseButtonHeight', popupData['sgpb-button-image-height']);
256
+ popupConfig.magicCall('setPopupId', popupId);
257
+ popupConfig.magicCall('setPopupData', popupData);
258
+ popupConfig.magicCall('setAllowed', !SGPBPopup.varToBool(popupData['sgpb-disable-popup-closing']));
259
+ if (popupData['sgpb-type'] == SGPB_POPUP_PARAMS.popupTypeAgeRestriction) {
260
+ popupConfig.magicCall('setAllowed', false);
261
+ }
262
+ popupConfig.magicCall('setEscShouldClose', SGPBPopup.varToBool(popupData['sgpb-esc-key']));
263
+ popupConfig.magicCall('setOverlayShouldClose', SGPBPopup.varToBool(popupData['sgpb-overlay-click']));
264
+
265
+ popupConfig.magicCall('setScrollingEnabled', SGPBPopup.varToBool(popupData['sgpb-enable-content-scrolling']));
266
+
267
+ if (SGPBPopup.varToBool(popupData['sgpb-content-click'])) {
268
+ this.contentCloseBehavior();
269
+ }
270
+ if (SGPBPopup.varToBool(popupData['sgpb-popup-fixed'])) {
271
+ this.addFixedPosition();
272
+ }
273
+ /*ThemeCreator*/
274
+ this.themeCreator();
275
+ this.themeCustomizations();
276
+
277
+ popupConfig.magicCall('setContents', document.getElementById('sg-popup-content-wrapper-'+popupId));
278
+ this.setPopupConfig(popupConfig);
279
+ this.popupTriggeringListeners();
280
+
281
+ /* check popup type, then check if popup can be opened by popup type */
282
+ var allowToOpen = this.checkCurrentPopupType();
283
+ if (allowToOpen) {
284
+ this.open();
285
+ }
286
+ };
287
+
288
+ SGPBPopup.prototype.checkCurrentPopupType = function()
289
+ {
290
+ var allowToOpen = true;
291
+ var popupConfig = new PopupConfig();
292
+
293
+ var isPreview = parseInt(this.popupData['sgpb-is-preview']);
294
+ if (!isNaN(isPreview) && isPreview == 1) {
295
+ return allowToOpen;
296
+ }
297
+
298
+ var popupHasLimit = this.popupLimitation(this.popupData);
299
+ if (!popupHasLimit) {
300
+ return false;
301
+ }
302
+
303
+ var dontShowPopupCookieName = 'sgDontShowPopup' + this.popupData['sgpb-post-id'];
304
+ var dontShowPopup = SGPopup.getCookie(dontShowPopupCookieName);
305
+ if (dontShowPopup != '') {
306
+ return false;
307
+ }
308
+
309
+ var className = this.popupData['sgpb-type'];
310
+ if (typeof className == 'undefined' || className == 'undefined') {
311
+ return false;
312
+ }
313
+ /* make the first letter of a string uppercase, then concat prefix (uppercase all prefix string) */
314
+ className = popupConfig.prefix.toUpperCase() + className.firstToUpperCase();
315
+ /* hasOwnProperty returns boolean value */
316
+ if (window.hasOwnProperty(className)) {
317
+ className = eval(className);
318
+ /* create current popup type object */
319
+ var obj = new className;
320
+ /* call allowToOpen function if exists */
321
+ if (typeof obj.allowToOpen === 'function') {
322
+ allowToOpen = obj.allowToOpen(this.id);
323
+ }
324
+ }
325
+
326
+ return allowToOpen;
327
+ };
328
+
329
+ SGPBPopup.prototype.popupLimitation = function(popupData)
330
+ {
331
+ var currentUrl = window.location.href;
332
+ var currentPopupId = popupData['sgpb-post-id'];
333
+ var popupLimitationCookieHomePageLevelName = 'SGPBShowingLimitationHomePage' + currentPopupId;
334
+ var popupLimitationCookiePageLevelName = 'SGPBShowingLimitationPage' + currentPopupId;
335
+ var popupLimitationCookieDomainName = 'SGPBShowingLimitationDomain' + currentPopupId;
336
+ var popupLimitation = popupData['sgpb-show-popup-same-user'];
337
+ if (typeof popupLimitation != 'undefined' && popupLimitation) {
338
+ var popupShowingLimit = popupData['sgpb-show-popup-same-user-count'];
339
+ var popupShowingLimitExpiry = popupData['sgpb-show-popup-same-user-expiry'];
340
+ var pageLevelCookie = popupData['sgpb-show-popup-same-user-page-level'];
341
+ if (typeof pageLevelCookie == 'undefined') {
342
+ pageLevelCookie = '';
343
+ }
344
+ if (currentUrl == SGPB_POPUP_PARAMS.homePageUrl) {
345
+ popupLimitationCookiePageLevelName = popupLimitationCookieHomePageLevelName;
346
+ }
347
+ var popupLimitationPageLevelCookie = SGPopup.getCookie(popupLimitationCookiePageLevelName);
348
+ var popupLimitationDomainCookie = SGPopup.getCookie(popupLimitationCookieDomainName);
349
+ /* page level cookie saving selected */
350
+ if (pageLevelCookie) {
351
+ /* if has already another saving level cookie */
352
+ if (popupLimitationPageLevelCookie == '') {
353
+ var cookieObject = {
354
+ openingCount : 1,
355
+ pageLevelCookie : pageLevelCookie,
356
+ openingPage : currentUrl
357
+ };
358
+ SGPBPopup.setCookie(popupLimitationCookiePageLevelName, JSON.stringify(cookieObject), popupShowingLimitExpiry, currentUrl);
359
+ }
360
+ else {
361
+ var popupLimitationPageLevelCookie = jQuery.parseJSON(popupLimitationPageLevelCookie);
362
+ if (popupShowingLimit <= popupLimitationPageLevelCookie.openingCount) {
363
+ return false;
364
+ }
365
+ var updatedCount = parseInt(popupLimitationPageLevelCookie.openingCount + 1);
366
+ popupLimitationPageLevelCookie.openingCount = updatedCount;
367
+ SGPBPopup.setCookie(popupLimitationCookiePageLevelName, JSON.stringify(popupLimitationPageLevelCookie), popupShowingLimitExpiry, currentUrl);
368
+ }
369
+ SGPBPopup.deleteCookie(popupLimitationCookieDomainName);
370
+ }
371
+ /* domain level cookie saving selected */
372
+ else {
373
+ var popupLimitationPageLevelCookie = jQuery.parseJSON(popupLimitationPageLevelCookie);
374
+ /* if has already another saving level cookie */
375
+ if (popupLimitationPageLevelCookie) {
376
+ SGPBPopup.deleteCookie(popupLimitationCookiePageLevelName, popupLimitationPageLevelCookie.openingPage);
377
+ }
378
+
379
+ if (popupLimitationDomainCookie == '') {
380
+ var cookieObject = {
381
+ openingCount : 1,
382
+ pageLevelCookie : pageLevelCookie
383
+ };
384
+ SGPBPopup.setCookie(popupLimitationCookieDomainName, JSON.stringify(cookieObject), popupShowingLimitExpiry, pageLevelCookie);
385
+ }
386
+ else {
387
+ var popupLimitationDomainCookie = jQuery.parseJSON(popupLimitationDomainCookie);
388
+ if (popupShowingLimit <= popupLimitationDomainCookie.openingCount) {
389
+ return false;
390
+ }
391
+ var updatedCount = parseInt(popupLimitationDomainCookie.openingCount + 1);
392
+ popupLimitationDomainCookie.openingCount = updatedCount;
393
+ SGPBPopup.setCookie(popupLimitationCookieDomainName, JSON.stringify(popupLimitationDomainCookie), popupShowingLimitExpiry, pageLevelCookie);
394
+ }
395
+ }
396
+ }
397
+
398
+ return true;
399
+ };
400
+
401
+ SGPBPopup.prototype.themeCreator = function()
402
+ {
403
+ var noPositionSelected = false;
404
+ var popupData = this.getPopupData();
405
+ var popupId = this.getPopupId();
406
+ var popupConfig = this.getPopupConfig();
407
+ var popupTheme = popupData['sgpb-popup-themes'];
408
+ var closeButtonWidth = popupData['sgpb-button-image-width'];
409
+ var closeButtonHeight = popupData['sgpb-button-image-height'];
410
+ var contentPadding = parseInt(popupData['sgpb-content-padding']);
411
+ var contentClass = popupData['sgpb-content-custom-class'];
412
+ var closeButtonImage = popupConfig.closeButtonImage;
413
+ var themeNumber = 1;
414
+
415
+ if (popupData['sgpb-type'] == 'countdown') {
416
+ popupConfig.magicCall('setMinWidth', 300);
417
+ }
418
+ popupConfig.magicCall('setContentPadding', contentPadding);
419
+ popupConfig.magicCall('setOverlayAddClass', popupTheme+'-overlay sgpb-popup-overlay-' + popupId);
420
+ popupConfig.magicCall('setContentAddClass', 'sgpb-content sgpb-content-'+popupId+' ' + popupTheme+'-content ' + contentClass);
421
+
422
+ if (typeof popupData['sgpb-close-button-position'] == 'undefined' || popupData['sgpb-close-button-position'] == '') {
423
+ /*
424
+ * in the old version we don't have close button position option
425
+ * and if noPositionSelected is true, the popup was not edited
426
+ */
427
+ var noPositionSelected = true;
428
+ }
429
+ else {
430
+ var closeButtonPosition = popupData['sgpb-close-button-position'];
431
+ popupConfig.magicCall('setButtonPosition', closeButtonPosition);
432
+ }
433
+
434
+ if (popupTheme == 'sgpb-theme-1') {
435
+ themeNumber = 1;
436
+ popupConfig.magicCall('setShadowSpread', 14);
437
+ /* 9px theme default close button position for all cases */
438
+ if (noPositionSelected || closeButtonPosition == 'bottomRight') {
439
+ popupConfig.magicCall('setCloseButtonPositionRight', '9px');
440
+ popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
441
+ }
442
+ else {
443
+ popupConfig.magicCall('setCloseButtonPositionLeft', '9px');
444
+ popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
445
+ }
446
+ }
447
+ else if (popupTheme == 'sgpb-theme-2') {
448
+ themeNumber = 2;
449
+ popupConfig.magicCall('setButtonInside', false);
450
+ popupConfig.magicCall('setContentBorderWidth', 1);
451
+ popupConfig.magicCall('setContentBackgroundColor', 'black');
452
+ popupConfig.magicCall('setContentBorderColor', 'transparent');
453
+ popupConfig.magicCall('setOverlayColor', 'white');
454
+ if (noPositionSelected || closeButtonPosition == 'topRight') {
455
+ /* this theme has 1px border */
456
+ popupConfig.magicCall('setCloseButtonPositionRight', '0');
457
+ popupConfig.magicCall('setCloseButtonPositionTop', '-' + closeButtonHeight + 'px');
458
+ }
459
+ else {
460
+ if (closeButtonPosition == 'topLeft') {
461
+ popupConfig.magicCall('setCloseButtonPositionLeft', '0');
462
+ popupConfig.magicCall('setCloseButtonPositionTop', '-' + closeButtonHeight + 'px');
463
+ }
464
+ else if (closeButtonPosition == 'bottomRight') {
465
+ popupConfig.magicCall('setCloseButtonPositionRight', '0');
466
+ popupConfig.magicCall('setCloseButtonPositionBottom', '-' + closeButtonHeight + 'px');
467
+ }
468
+ else if (closeButtonPosition == 'bottomLeft') {
469
+ popupConfig.magicCall('setCloseButtonPositionLeft', '0');
470
+ popupConfig.magicCall('setCloseButtonPositionBottom', '-' + closeButtonHeight + 'px');
471
+ }
472
+ }
473
+ }
474
+ else if (popupTheme == 'sgpb-theme-3') {
475
+ themeNumber = 3;
476
+ popupConfig.magicCall('setContentBorderWidth', 5);
477
+ popupConfig.magicCall('setContentBorderRadius', popupData['sgpb-border-radius']);
478
+ popupConfig.magicCall('setContentBorderRadiusType', popupData['sgpb-border-radius-type']);
479
+ popupConfig.magicCall('setContentBorderColor', popupData['sgpb-border-color']);
480
+ if (noPositionSelected) {
481
+ popupConfig.magicCall('setCloseButtonWidth', 38);
482
+ popupConfig.magicCall('setCloseButtonHeight', 19);
483
+ popupConfig.magicCall('setCloseButtonPositionRight', '4px');
484
+ popupConfig.magicCall('setCloseButtonPositionTop', '4px');
485
+ }
486
+ else {
487
+ if (closeButtonPosition == 'topRight') {
488
+ popupConfig.magicCall('setCloseButtonPositionRight', '4px');
489
+ popupConfig.magicCall('setCloseButtonPositionTop', '4px');
490
+ }
491
+ else if (closeButtonPosition == 'topLeft') {
492
+ popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
493
+ popupConfig.magicCall('setCloseButtonPositionTop', '4px');
494
+ }
495
+ else if (closeButtonPosition == 'bottomRight') {
496
+ popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
497
+ popupConfig.magicCall('setCloseButtonPositionBottom', '4px');
498
+ }
499
+ else if (closeButtonPosition == 'bottomLeft') {
500
+ popupConfig.magicCall('setCloseButtonPositionLeft', '4px');
501
+ popupConfig.magicCall('setCloseButtonPositionBottom', '4px');
502
+ }
503
+ }
504
+ }
505
+ else if (popupTheme == 'sgpb-theme-4') {
506
+ /* in theme-4 close button type is button,not image,
507
+ * then set type to button, default is image and
508
+ * set text
509
+ */
510
+ themeNumber = 4;
511
+ popupConfig.magicCall('setButtonImage', popupData['sgpb-button-text']);
512
+ popupConfig.magicCall('setCloseButtonType', 'button');
513
+ popupConfig.magicCall('setCloseButtonText', popupData['sgpb-button-text']);
514
+ popupConfig.magicCall('setContentBorderWidth', 0);
515
+ popupConfig.magicCall('setContentBackgroundColor', 'white');
516
+ popupConfig.magicCall('setContentBorderColor', 'white');
517
+ popupConfig.magicCall('setOverlayColor', 'white');
518
+ popupConfig.magicCall('setShadowSpread', 4);
519
+ popupConfig.magicCall('setContentShadowBlur', 8);
520
+ /* 8px/12px theme default close button position for all cases */
521
+ if (noPositionSelected || closeButtonPosition == 'bottomRight') {
522
+ popupConfig.magicCall('setCloseButtonPositionRight', '12px');
523
+ popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
524
+ }
525
+ else {
526
+ popupConfig.magicCall('setCloseButtonPositionLeft', '12px');
527
+ popupConfig.magicCall('setCloseButtonPositionBottom', '9px');
528
+ }
529
+ }
530
+ else if (popupTheme == 'sgpb-theme-5') {
531
+ themeNumber = 5;
532
+ popupConfig.magicCall('setBoxBorderWidth', 10);
533
+ popupConfig.magicCall('setContentBorderColor', '#4B4B4B');
534
+ if (noPositionSelected || closeButtonPosition == 'bottomRight') {
535
+ popupConfig.magicCall('setCloseButtonPositionRight', '8px');
536
+ popupConfig.magicCall('setCloseButtonPositionBottom', '8px');
537
+ }
538
+ else {
539
+ popupConfig.magicCall('setCloseButtonPositionLeft', '8px');
540
+ popupConfig.magicCall('setCloseButtonPositionBottom', '8px');
541
+ }
542
+ }
543
+ else if (popupTheme == 'sgpb-theme-6') {
544
+ themeNumber = 6;
545
+ popupConfig.magicCall('setButtonInside', false);
546
+ popupConfig.magicCall('setContentBorderRadius', 7);
547
+ popupConfig.magicCall('setContentBorderRadiusType', 'px');
548
+ if (noPositionSelected) {
549
+ popupConfig.magicCall('setCloseButtonWidth', 37);
550
+ popupConfig.magicCall('setCloseButtonHeight', 37);
551
+ popupConfig.magicCall('setCloseButtonPositionRight', '-18.5px');
552
+ popupConfig.magicCall('setCloseButtonPositionTop', '-18.5px');
553
+ }
554
+ else {
555
+ if (closeButtonPosition == 'topRight') {
556
+ popupConfig.magicCall('setCloseButtonPositionRight', '-' + (closeButtonWidth / 2) + 'px');
557
+ popupConfig.magicCall('setCloseButtonPositionTop', '-' + (closeButtonHeight / 2) + 'px');
558
+ }
559
+ else if (closeButtonPosition == 'topLeft') {
560
+ popupConfig.magicCall('setCloseButtonPositionLeft', '-' + (closeButtonWidth / 2) + 'px');
561
+ popupConfig.magicCall('setCloseButtonPositionTop', '-' + (closeButtonHeight / 2) + 'px');
562
+ }
563
+ else if (closeButtonPosition == 'bottomRight') {
564
+ popupConfig.magicCall('setCloseButtonPositionRight', '-' + (closeButtonWidth / 2) + 'px');
565
+ popupConfig.magicCall('setCloseButtonPositionBottom', '-' + (closeButtonHeight / 2) + 'px');
566
+ }
567
+ else if (closeButtonPosition == 'bottomLeft') {
568
+ popupConfig.magicCall('setCloseButtonPositionLeft', '-' + (closeButtonWidth / 2) + 'px');
569
+ popupConfig.magicCall('setCloseButtonPositionBottom', '-' + (closeButtonHeight / 2) + 'px');
570
+ }
571
+ }
572
+ }
573
+
574
+ popupConfig.magicCall('setPopupTheme', themeNumber);
575
+
576
+ if (!popupData['sgpb-button-image']) {
577
+ closeButtonImage = SGPB_POPUP_PARAMS.defaultThemeImages[themeNumber];
578
+ if (typeof closeButtonImage != 'undefined') {
579
+ popupConfig.magicCall('setButtonImage', closeButtonImage);
580
+ }
581
+ }
582
+ else {
583
+ popupConfig.magicCall('setButtonImage', popupData['sgpb-button-image']);
584
+ }
585
+
586
+ };
587
+
588
+ SGPBPopup.prototype.themeCustomizations = function()
589
+ {
590
+ var popupId = this.getPopupId();
591
+ var popupData = this.getPopupData();
592
+ var popupConfig = this.getPopupConfig();
593
+ var contentOpacity = popupData['sgpb-content-opacity'];
594
+ var contentBgColor = popupData['sgpb-background-color'];
595
+ var contentBgImage = popupData['sgpb-background-image'];
596
+ var showContentBackground = popupData['sgpb-show-background'];
597
+ var contentBgImageMode = popupData['sgpb-background-image-mode'];
598
+ var overlayColor = popupData['sgpb-overlay-color'];
599
+ var popupTheme = popupData['sgpb-popup-themes'];
600
+
601
+ if (typeof showContentBackground == 'undefined') {
602
+ contentBgColor = '';
603
+ contentBgImage = '';
604
+ contentBgImageMode = '';
605
+ }
606
+
607
+ if (contentBgImageMode) {
608
+ popupConfig.magicCall('setContentBackgroundMode', contentBgImageMode);
609
+ }
610
+ if (contentBgImage) {
611
+ popupConfig.magicCall('setContentBackgroundImage', contentBgImage);
612
+ }
613
+ if (contentBgColor) {
614
+ contentBgColor = SGPBPopup.hexToRgba(contentBgColor, contentOpacity);
615
+ popupConfig.magicCall('setContentBackgroundColor', contentBgColor);
616
+ }
617
+ if (overlayColor) {
618
+ popupConfig.magicCall('setOverlayColor', overlayColor);
619
+ }
620
+
621
+ var overlayClasses = popupTheme+'-overlay sgpb-popup-overlay-'+popupId;
622
+ if (SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']) || SGPB_JS_PACKAGES.packages['current'] == SGPB_JS_PACKAGES.packages['free']) {
623
+ if (SGPB_JS_PACKAGES.packages['current'] != SGPB_JS_PACKAGES.packages['free']) {
624
+ popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
625
+ }
626
+ popupConfig.magicCall('setOverlayAddClass', overlayClasses + ' ' + popupData['sgpb-overlay-custom-class']);
627
+ popupConfig.magicCall('setOverlayOpacity', popupData['sgpb-overlay-opacity'] * 100);
628
+ }
629
+ else {
630
+ if (SGPB_JS_PACKAGES.packages['current'] == SGPB_JS_PACKAGES.packages['free']) {
631
+ popupData['sgpb-enable-popup-overlay'] = true;
632
+ }
633
+ popupConfig.magicCall('setOverlayVisible', SGPBPopup.varToBool(popupData['sgpb-enable-popup-overlay']));
634
+ }
635
+ };
636
+
637
+ SGPBPopup.prototype.formSubmissionDetection = function(args)
638
+ {
639
+ if (args.length) {
640
+ return false;
641
+ }
642
+ var popupId = args.popupId;
643
+ var options = SGPBPopup.getPopupOptionsById(popupId);
644
+
645
+ if (!options['sgpb-reopen-after-form-submission']) {
646
+ return false;
647
+ }
648
+
649
+ jQuery('.sgpb-popup-builder-content-' + popupId + ' form').submit(function() {
650
+ SGPBPopup.setCookie('SGPBSubmissionReloadPopup', popupId);
651
+ });
652
+ };
653
+
654
+ SGPBPopup.prototype.htmlIframeFilterForOpen = function(popupId, popupEventName)
655
+ {
656
+ var popupContent = jQuery('.sgpb-content-' + popupId);
657
+
658
+ if (!popupContent.length) {
659
+ return false;
660
+ }
661
+
662
+ popupContent.find('iframe').each(function() {
663
+
664
+ if (popupEventName != 'open') {
665
+ /* for do not affect facebook type buttons iframe only */
666
+ if (jQuery(this).closest('.fb_iframe_widget').length) {
667
+ return true;
668
+ }
669
+
670
+ jQuery(this).attr('data-attr-src', src);
671
+ jQuery(this).attr('src', '');
672
+ return true;
673
+ }
674
+ else {
675
+ var src = jQuery(this).attr('data-attr-src');
676
+ jQuery(this).attr('src', src);
677
+ }
678
+ });
679
+ };
680
+
681
+ SGPBPopup.prototype.getSearchDataFromContent = function(content)
682
+ {
683
+ var pattern = /\[(\[?)(pbvariable)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]\*+(?:\[(?!\/\2\])[^\[]\*+)\*+)\[\/\2\])?)(\]?)/gi;
684
+ var match;
685
+ var collectedData = [];
686
+
687
+ while (match = pattern.exec(content)) {
688
+ var currentSearchData = [];
689
+ var attributes;
690
+ var attributesKeyValue = [];
691
+ var parseAttributes = /\s(\w+?)="(.+?)"/g;
692
+ currentSearchData['replaceString'] = this.htmlDecode(match[0]);
693
+
694
+ while (attributes = parseAttributes.exec(match[3])) {
695
+ attributesKeyValue[attributes[1]] = this.htmlDecode(attributes[2]);
696
+ }
697
+
698
+ currentSearchData['searchData'] = attributesKeyValue;
699
+ collectedData.push(currentSearchData);
700
+ }
701
+
702
+ return collectedData;
703
+ };
704
+
705
+ SGPBPopup.prototype.replaceWithCustomShortcode = function(popupId)
706
+ {
707
+ var currentHtmlContent = jQuery('.sgpb-content-'+popupId).html();
708
+ var searchData = this.getSearchDataFromContent(currentHtmlContent);
709
+
710
+ var that = this;
711
+
712
+ if (!searchData.length) {
713
+ return false;
714
+ }
715
+
716
+ for (var index in searchData) {
717
+ var currentSearchData = searchData[index];
718
+ var searchAttributes = currentSearchData['searchData'];
719
+
720
+ if (typeof searchAttributes['selector'] == 'undefined' || typeof searchAttributes['attribute'] == 'undefined') {
721
+ that.replaceShortCode(currentSearchData['replaceString'], '');
722
+ continue;
723
+ }
724
+
725
+ try {
726
+ if (!jQuery(searchAttributes['selector']).length) {
727
+ that.replaceShortCode(currentSearchData['replaceString'], '');
728
+ continue;
729
+ }
730
+ }
731
+ catch (e) {
732
+ that.replaceShortCode(currentSearchData['replaceString'], '');
733
+ continue;
734
+ }
735
+
736
+ var replaceName = jQuery(searchAttributes['selector']).attr(searchAttributes['attribute']);
737
+
738
+ if (typeof replaceName == 'undefined') {
739
+ that.replaceShortCode(currentSearchData['replaceString'], '');
740
+ continue;
741
+ }
742
+
743
+ that.replaceShortCode(currentSearchData['replaceString'], replaceName, popupId);
744
+ }
745
+ };
746
+
747
+ SGPBPopup.prototype.replaceShortCode = function(shortCode, replaceText, popupId)
748
+ {
749
+ var popupId = parseInt(popupId);
750
+
751
+ if (!popupId) {
752
+ return false;
753
+ }
754
+
755
+ var popupContentWrapper = jQuery('.sgpb-content-' + popupId);
756
+
757
+ if (!popupContentWrapper.length) {
758
+ return false;
759
+ }
760
+
761
+ popupContentWrapper.find('div').each(function() {
762
+ var currentHtmlContent = jQuery(this).contents();
763
+
764
+ if (!currentHtmlContent.length) {
765
+ return false;
766
+ }
767
+
768
+ for (var index in currentHtmlContent) {
769
+ var currentChild = currentHtmlContent[index];
770
+ var currentChildNodeValue = currentChild.nodeValue;
771
+ var currentChildNodeType = currentChild.nodeType;
772
+
773
+ if (currentChildNodeType != Node.TEXT_NODE) {
774
+ continue;
775
+ }
776
+
777
+ if (currentChildNodeValue.indexOf(shortCode) != -1) {
778
+ currentChild.nodeValue = currentChildNodeValue.replace(shortCode, replaceText);
779
+ }
780
+ }
781
+ });
782
+
783
+ return true;
784
+ };
785
+
786
+ SGPBPopup.prototype.popupTriggeringListeners = function()
787
+ {
788
+ var that = this;
789
+ var popupData = this.getPopupData();
790
+ var popupConfig = this.getPopupConfig();
791
+
792
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
793
+ var args = e.detail;
794
+ that.formSubmissionDetection(args);
795
+ var popupOptions = args.popupData;
796
+ /* if no analytics extension */
797
+ if (typeof SGPB_ANALYTICS_PARAMS == 'undefined') {
798
+ that.addToCounter(popupOptions['sgpb-post-id']);
799
+ }
800
+
801
+ var closeButtonDelay = parseInt(popupOptions['sgpb-close-button-delay']);
802
+ if (closeButtonDelay) {
803
+ that.closeButtonDisplay(popupOptions['sgpb-post-id'], 'show', closeButtonDelay);
804
+ }
805
+ var disablePageScrolling = popupOptions['sgpb-disable-page-scrolling'];
806
+ if (popupOptions['sgpb-overlay-color']) {
807
+ jQuery('.sgpb-theme-1-overlay').css({'background-image': 'none'});
808
+ }
809
+ if (SGPBPopup.varToBool(disablePageScrolling)) {
810
+ jQuery('html').css({overflow: 'hidden'});
811
+ }
812
+ });
813
+
814
+ sgAddEvent(window, 'sgpbWillOpen', function(e) {
815
+ var args = e.detail;
816
+ var popupId = parseInt(args['popupId']);
817
+
818
+ that.htmlIframeFilterForOpen(args.popupId, 'open');
819
+ that.replaceWithCustomShortcode(popupId);
820
+ that.sgpbDontShowPopup(popupId);
821
+ var autoCloseStatus = SGPBPopup.varToBool(popupData['sgpb-auto-close']);
822
+ var closeButtonDelay = parseInt(popupData['sgpb-close-button-delay']);
823
+ if (closeButtonDelay) {
824
+ that.closeButtonDisplay(popupData['sgpb-post-id'], 'hide');
825
+ }
826
+ if (autoCloseStatus) {
827
+ var autoCloseTime = parseInt(popupData['sgpb-auto-close-time'])*1000;
828
+ setTimeout(function() {
829
+ SGPBPopup.closePopupById(that.getPopupId());
830
+ }, autoCloseTime);
831
+ }
832
+ });
833
+
834
+ sgAddEvent(window, 'sgpbShouldClose', function(e) {
835
+
836
+ });
837
+
838
+ sgAddEvent(window, 'sgpbWillClose', function(e) {
839
+ var args = e.detail;
840
+ that.htmlIframeFilterForOpen(args.popupId, 'close');
841
+ SGPBPopup.offPopup(e.detail.currentObj);
842
+ });
843
+ };
844
+
845
+ SGPBPopup.prototype.sgpbDontShowPopup = function(popupId)
846
+ {
847
+ var dontShowPopup = jQuery('#sg-popup-content-wrapper-' + popupId + ' [class^=sg-popup-dont-show]');
848
+
849
+ if (!dontShowPopup.length) {
850
+ return false;
851
+ }
852
+
853
+ dontShowPopup.each(function() {
854
+ jQuery(this).bind('click', function(e) {
855
+ e.preventDefault();
856
+ var expireTime = SGPB_POPUP_PARAMS.dontShowPopupExpireTime;
857
+ var cookieName = 'sgDontShowPopup' + popupId;
858
+ var classNameSearch = jQuery(this).attr('class').match(/^sg-popup-dont-show/);
859
+ var className = classNameSearch['input'];
860
+ var customExpireTime = className.match(/^sg-popup-dont-show-(\d+$)/);
861
+
862
+ if (customExpireTime) {
863
+ expireTime = parseInt(customExpireTime[1]);
864
+ }
865
+
866
+ SGPBPopup.setCookie(cookieName, expireTime, expireTime);
867
+ SGPBPopup.closePopupById(popupId);
868
+ });
869
+ });
870
  }
871
+
872
+ SGPBPopup.prototype.addToCounter = function(popupId)
873
+ {
874
+ if (SGPB_POPUP_PARAMS.isPreview != '') {
875
+ return false;
876
+ }
877
+ var params = {};
878
+ params.popupId = popupId;
879
+
880
+ var data = {
881
+ action: 'sgpb_send_to_open_counter',
882
+ nonce: SGPB_JS_PARAMS.nonce,
883
+ params: params
884
+ };
885
+
886
+ jQuery.post(SGPB_JS_PARAMS.ajaxUrl, data, function(res) {
887
+
888
+ });
889
+ };
890
+
891
+ /*
892
+ * closeButtonDisplay()
893
+ * close or hide close button
894
+ * @param popupId
895
+ * @param display
896
+ * @param delay
897
+ */
898
+
899
+ SGPBPopup.prototype.closeButtonDisplay = function(popupId, display, delay)
900
+ {
901
+ if (display == 'show') {
902
+ setTimeout(function() {
903
+ jQuery('.sgpb-content-' + popupId).prev().show();
904
+ },
905
+ delay * 1000 /* received values covert to milliseconds */
906
+ );
907
+ }
908
+ else if (display == 'hide') {
909
+ jQuery('.sgpb-content-' + popupId).prev().hide();
910
+ }
911
+ };
912
+
913
+ SGPBPopup.prototype.open = function()
914
+ {
915
+ var config = this.getPopupConfig();
916
+ var popupId = this.getPopupId();
917
+ var eventName = this.eventName;
918
+
919
+ if (typeof window.sgPopupBuilder == 'undefined') {
920
+ window.sgPopupBuilder = [];
921
+ }
922
+ var popupData = SGPBPopup.getPopupWindowDataById(popupId);
923
+
924
+ if (!popupData) {
925
+ window.SGPB_ORDER += 1;
926
+ var currentObj = {
927
+ 'eventName': eventName,
928
+ 'popupId': popupId,
929
+ 'order': window.SGPB_ORDER,
930
+ 'isOpen': true
931
+ };
932
+ config.currentObj = currentObj;
933
+ var popupConfig = config.combineConfigObj();
934
+ var popup = new SGPopup(popupConfig);
935
+ currentObj.popup = popup;
936
+ window.sgPopupBuilder.push(currentObj);
937
+ }
938
+ else {
939
+ popup = popupData['popup'];
940
+ popupData['isOpen'] = true;
941
+ }
942
+
943
+ popup.open();
944
+ this.setPopupObj(popup);
945
+
946
+ /* contact form 7 form submission
947
+ * TODO: this must be moved to a better place in the future
948
+ * I'm leaving it here for now, since sgpbDidOpen() gets called way too much!
949
+ */
950
+ var options = SGPBPopup.getPopupOptionsById(popupId);
951
+ if (typeof options['sgpb-behavior-after-special-events'] != 'undefined') {
952
+ if (options['sgpb-behavior-after-special-events'].length) {
953
+ options = options['sgpb-behavior-after-special-events'][0][0];
954
+ if (options['param'] == 'contact-form-7') {
955
+ SgpbEventListener.processCF7MailSent(popupId, options);
956
+ }
957
+ }
958
+ }
959
+ };
960
+
961
+ SGPBPopup.varToBool = function(optionName)
962
+ {
963
+ var returnValue = optionName ? true : false;
964
+
965
+ return returnValue;
966
+ };
967
+
968
+ SGPBPopup.hexToRgba = function(hex, opacity)
969
+ {
970
+ var c;
971
+ if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
972
+ c = hex.substring(1).split('');
973
+
974
+ if (c.length == 3){
975
+ c= [c[0], c[0], c[1], c[1], c[2], c[2]];
976
+ }
977
+ c = '0x'+c.join('');
978
+ return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')';
979
+ }
980
+ throw new Error('Bad Hex');
981
+ };
982
+
983
+ SGPBPopup.prototype.contentCopyToClick = function()
984
+ {
985
+ var popupData = this.getPopupData();
986
+ var popupId = this.getPopupId();
987
+ var textAreaId = 'content-copy-to-click-'+popupId;
988
+
989
+ var value = this.htmlDecode(popupData['sgpb-copy-to-clipboard-text']);
990
+ var textArea = jQuery('<textarea>', {
991
+ id: textAreaId,
992
+ value: value,
993
+ style: 'position: absolute; right: -10000px'
994
+ });
995
+
996
+ if (!jQuery('#'+textAreaId).length) {
997
+ jQuery('body').append(textArea);
998
+ }
999
+ jQuery('#'+textAreaId).select();
1000
+ document.execCommand('copy');
1001
+ jQuery('#'+textAreaId).remove();
1002
+ };
1003
+
1004
+ SGPBPopup.prototype.htmlDecode = function(value)
1005
+ {
1006
+ return jQuery('<textarea/>').html(value).text();
1007
+ };
1008
+
1009
+ SGPBPopup.prototype.findTargetInsideExceptionsList = function(targetName, exceptionList)
1010
+ {
1011
+ var status = false;
1012
+ var popupContentMainDiv = document.getElementById('sgpb-popup-dialog-main-div');
1013
+
1014
+ while (targetName.parentNode) {
1015
+ targetName = targetName.parentNode;
1016
+ var tagName = targetName.tagName.toLowerCase();
1017
+ if (targetName === popupContentMainDiv) {
1018
+ break;
1019
+ }
1020
+ if (exceptionList.indexOf(tagName) != -1) {
1021
+ status = true;
1022
+ break;
1023
+ }
1024
+ }
1025
+
1026
+ return status;
1027
+ };
1028
+
1029
+ SGPBPopup.prototype.contentCloseBehavior = function()
1030
+ {
1031
+ var that = this;
1032
+ var popupData = this.getPopupData();
1033
+ var popupId = this.getPopupId();
1034
+ var redirectUrl = popupData['sgpb-click-redirect-to-url'];
1035
+ var contentClickBehavior = popupData['sgpb-content-click-behavior'];
1036
+ var redirectToNewTab = SGPBPopup.varToBool(popupData['sgpb-redirect-to-new-tab']);
1037
+
1038
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
1039
+
1040
+ });
1041
+
1042
+ sgAddEvent(window, 'sgpbWillOpen', function(e) {
1043
+ if (popupId != e.detail.popupId || e.detail.popupData['sgpb-content-click'] == 'undefined') {
1044
+ return false;
1045
+ }
1046
+ jQuery('.sgpb-content-'+e.detail.popupId).on('click', function(event) {
1047
+ if (contentClickBehavior == 'redirect') {
1048
+ if (redirectToNewTab) {
1049
+ window.open(redirectUrl);
1050
+ SGPBPopup.closePopupById(that.getPopupId());
1051
+ return;
1052
+ }
1053
+ window.location = redirectUrl;
1054
+ SGPBPopup.closePopupById(that.getPopupId());
1055
+ }
1056
+ else if (contentClickBehavior == 'copy') {
1057
+ var exceptionList = ['input', 'textarea', 'select', 'button', 'a'];
1058
+ var targetName = event.target.tagName.toLowerCase();
1059
+ var parentTagName = event.target.parentNode.tagName.toLowerCase();
1060
+ var parentsIsInExceptionsList = that.findTargetInsideExceptionsList(event.target, exceptionList);
1061
+
1062
+ /*for do not copy when user click to any input element*/
1063
+ if (exceptionList.indexOf(targetName) == -1 && !parentsIsInExceptionsList) {
1064
+ that.contentCopyToClick();
1065
+ }
1066
+ }
1067
+ else if (popupData['sgpb-disable-popup-closing'] != 'on') {
1068
+ SGPBPopup.closePopupById(that.getPopupId());
1069
+ }
1070
+ });
1071
+ });
1072
+
1073
+ sgAddEvent(window, 'sgpbDidClose', function(e) {
1074
+
1075
+ });
1076
+ };
1077
+
1078
+ SGPBPopup.prototype.addFixedPosition = function()
1079
+ {
1080
+ var popupData = this.getPopupData();
1081
+ var popupId = this.getPopupId();
1082
+ var popupConfig = this.getPopupConfig();
1083
+
1084
+ var fixedPosition = popupData['sgpb-popup-fixed-position'];
1085
+ var positionRight = '';
1086
+ var positionTop = '';
1087
+ var positionBottom = '';
1088
+ var positionLeft = '';
1089
+
1090
+ if (fixedPosition == 1) {
1091
+ positionTop = 40;
1092
+ positionLeft = 20;
1093
+ }
1094
+ else if (fixedPosition == 2) {
1095
+ positionLeft = 'center';
1096
+ positionTop = 40;
1097
+ }
1098
+ else if (fixedPosition == 3) {
1099
+ positionTop = 40;
1100
+ positionRight = 20;
1101
+ }
1102
+ else if (fixedPosition == 4) {
1103
+ positionTop = 'center';
1104
+ positionLeft = 20;
1105
+ }
1106
+ else if (fixedPosition == 6) {
1107
+ positionTop = 'center';
1108
+ positionRight = 20;
1109
+ }
1110
+ else if (fixedPosition == 7) {
1111
+ positionLeft = 20;
1112
+ positionBottom = 2;
1113
+ }
1114
+ else if (fixedPosition == 8) {
1115
+ positionLeft = 'center';
1116
+ positionBottom = 2;
1117
+ }
1118
+ else if (fixedPosition == 9) {
1119
+ positionRight = 20;
1120
+ positionBottom = 2;
1121
+ }
1122
+
1123
+ popupConfig.magicCall('setPositionTop', positionTop);
1124
+ popupConfig.magicCall('setPositionRight', positionRight);
1125
+ popupConfig.magicCall('setPositionBottom', positionBottom);
1126
+ popupConfig.magicCall('setPositionLeft', positionLeft);
1127
+ };
1128
+
1129
+ SGPBPopup.prototype.setPopupDimensions = function()
1130
+ {
1131
+ var popupData = this.getPopupData();
1132
+ var popupConfig = this.getPopupConfig();
1133
+ var popupId = this.getPopupId();
1134
+ var dimensionData = popupData['sgpb-popup-dimension-mode'];
1135
+ var maxWidth = popupData['sgpb-max-width'];
1136
+ var maxHeight = popupData['sgpb-max-height'];
1137
+ var minWidth = popupData['sgpb-min-width'];
1138
+ var minHeight = popupData['sgpb-min-height'];
1139
+ var contentPadding = popupData['sgpb-content-padding'];
1140
+
1141
+ popupConfig.magicCall('setMaxWidth', maxWidth);
1142
+ popupConfig.magicCall('setMaxHeight', maxHeight);
1143
+ popupConfig.magicCall('setMinWidth', minWidth);
1144
+ popupConfig.magicCall('setMinHeight', minHeight);
1145
+
1146
+ if (dimensionData == 'responsiveMode') {
1147
+ var dimensionMeasure = popupData['sgpb-responsive-dimension-measure'];
1148
+ var popupConfig = this.getPopupConfig();
1149
+
1150
+ if (dimensionMeasure != 'auto') {
1151
+ popupConfig.magicCall('setWidth', dimensionMeasure+'%');
1152
+ }
1153
+ else {
1154
+ popupConfig.magicCall('setWidth', jQuery('.sgpb-popup-builder-content-'+popupId).width() + (contentPadding*2) + 'px');
1155
+ }
1156
+
1157
+ return popupConfig;
1158
+ }
1159
+
1160
+ var popupWidth = popupData['sgpb-width'];
1161
+ var popupHeight = popupData['sgpb-height'];
1162
+
1163
+ popupConfig.magicCall('setWidth', popupWidth);
1164
+ popupConfig.magicCall('setHeight', popupHeight);
1165
+
1166
+ return popupConfig;
1167
+ };
1168
+
1169
+ SGPBPopup.b64DecodeUnicode = function(str)
1170
+ {
1171
+ var Base64 = {
1172
+
1173
+ /* private property */
1174
+ _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
1175
+
1176
+ /* public method for decoding */
1177
+ decode : function (input) {
1178
+ var output = "";
1179
+ var chr1, chr2, chr3;
1180
+ var enc1, enc2, enc3, enc4;
1181
+ var i = 0;
1182
+
1183
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
1184
+
1185
+ while (i < input.length) {
1186
+ enc1 = this._keyStr.indexOf(input.charAt(i++));
1187
+ enc2 = this._keyStr.indexOf(input.charAt(i++));
1188
+ enc3 = this._keyStr.indexOf(input.charAt(i++));
1189
+ enc4 = this._keyStr.indexOf(input.charAt(i++));
1190
+
1191
+ chr1 = (enc1 << 2) | (enc2 >> 4);
1192
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
1193
+ chr3 = ((enc3 & 3) << 6) | enc4;
1194
+
1195
+ output = output + String.fromCharCode(chr1);
1196
+
1197
+ if (enc3 != 64) {
1198
+ output = output + String.fromCharCode(chr2);
1199
+ }
1200
+ if (enc4 != 64) {
1201
+ output = output + String.fromCharCode(chr3);
1202
+ }
1203
+
1204
+ }
1205
+
1206
+ output = Base64._utf8_decode(output);
1207
+
1208
+ return output;
1209
+
1210
+ },
1211
+
1212
+ /* private method for UTF-8 decoding */
1213
+ _utf8_decode : function (utftext) {
1214
+ var string = "";
1215
+ var i = 0;
1216
+ var c = c1 = c2 = 0;
1217
+
1218
+ while (i < utftext.length) {
1219
+
1220
+ c = utftext.charCodeAt(i);
1221
+
1222
+ if (c < 128) {
1223
+ string += String.fromCharCode(c);
1224
+ i++;
1225
+ }
1226
+ else if ((c > 191) && (c < 224)) {
1227
+ c2 = utftext.charCodeAt(i+1);
1228
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
1229
+ i += 2;
1230
+ }
1231
+ else {
1232
+ c2 = utftext.charCodeAt(i+1);
1233
+ c3 = utftext.charCodeAt(i+2);
1234
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
1235
+ i += 3;
1236
+ }
1237
+ }
1238
+
1239
+ return string;
1240
+ }
1241
+ };
1242
+
1243
+ return Base64.decode(str);
1244
+ };
1245
+
1246
+ SGPBPopup.unserialize = function(data)
1247
+ {
1248
+ data = SGPBPopup.b64DecodeUnicode(data);
1249
+
1250
+ var $global = (typeof window !== 'undefined' ? window : global);
1251
+
1252
+ var utf8Overhead = function(str) {
1253
+ var s = str.length;
1254
+ for (var i = str.length - 1; i >= 0; i--) {
1255
+ var code = str.charCodeAt(i)
1256
+ if (code > 0x7f && code <= 0x7ff) {
1257
+ s++;
1258
+ }
1259
+ else if (code > 0x7ff && code <= 0xffff) {
1260
+ s += 2;
1261
+ }
1262
+ /* trail surrogate */
1263
+ if (code >= 0xDC00 && code <= 0xDFFF) {
1264
+ i--;
1265
+ }
1266
+ }
1267
+ return s - 1;
1268
+ }
1269
+
1270
+ var error = function(type, msg, filename, line) {
1271
+ throw new $global[type](msg, filename, line);
1272
+ }
1273
+ var readUntil = function(data, offset, stopchr) {
1274
+ var i = 2;
1275
+ var buf = [];
1276
+ var chr = data.slice(offset, offset + 1);
1277
+
1278
+ while (chr !== stopchr) {
1279
+ if ((i + offset) > data.length) {
1280
+ error('Error', 'Invalid');
1281
+ }
1282
+ buf.push(chr);
1283
+ chr = data.slice(offset + (i - 1), offset + i);
1284
+ i += 1;
1285
+ }
1286
+ return [buf.length, buf.join('')];
1287
+ }
1288
+ var readChrs = function(data, offset, length) {
1289
+ var i, chr, buf
1290
+
1291
+ buf = []
1292
+ for (i = 0; i < length; i++) {
1293
+ chr = data.slice(offset + (i - 1), offset + i);
1294
+ buf.push(chr);
1295
+ length -= utf8Overhead(chr);
1296
+ }
1297
+ return [buf.length, buf.join('')];
1298
+ }
1299
+ function _unserialize(data, offset) {
1300
+ var dtype
1301
+ var dataoffset
1302
+ var keyandchrs
1303
+ var keys
1304
+ var contig
1305
+ var length
1306
+ var array
1307
+ var readdata
1308
+ var readData
1309
+ var ccount
1310
+ var stringlength
1311
+ var i
1312
+ var key
1313
+ var kprops
1314
+ var kchrs
1315
+ var vprops
1316
+ var vchrs
1317
+ var value
1318
+ var chrs = 0
1319
+ var typeconvert = function(x) {
1320
+ return x
1321
+ }
1322
+
1323
+ if (!offset) {
1324
+ offset = 0
1325
+ }
1326
+ dtype = (data.slice(offset, offset + 1)).toLowerCase()
1327
+
1328
+ dataoffset = offset + 2
1329
+
1330
+ switch (dtype) {
1331
+ case 'i':
1332
+ typeconvert = function(x) {
1333
+ return parseInt(x, 10);
1334
+ }
1335
+ readData = readUntil(data, dataoffset, ';');
1336
+ chrs = readData[0];
1337
+ readdata = readData[1];
1338
+ dataoffset += chrs + 1;
1339
+ break;
1340
+ case 'b':
1341
+ typeconvert = function(x) {
1342
+ return parseInt(x, 10) !== 0;
1343
+ }
1344
+ readData = readUntil(data, dataoffset, ';');
1345
+ chrs = readData[0];
1346
+ readdata = readData[1];
1347
+ dataoffset += chrs + 1;
1348
+ break;
1349
+ case 'd':
1350
+ typeconvert = function(x) {
1351
+ return parseFloat(x);
1352
+ }
1353
+ readData = readUntil(data, dataoffset, ';');
1354
+ chrs = readData[0];
1355
+ readdata = readData[1];
1356
+ dataoffset += chrs + 1;
1357
+ break;
1358
+ case 'n':
1359
+ readdata = null
1360
+ break
1361
+ case 's':
1362
+ ccount = readUntil(data, dataoffset, ':')
1363
+ chrs = ccount[0]
1364
+ stringlength = ccount[1]
1365
+ dataoffset += chrs + 2
1366
+
1367
+ readData = readChrs(data, dataoffset + 1, parseInt(stringlength, 10))
1368
+ chrs = readData[0]
1369
+ readdata = readData[1]
1370
+ dataoffset += chrs + 2
1371
+ if (chrs !== parseInt(stringlength, 10) && chrs !== readdata.length) {
1372
+ error('SyntaxError', 'String length mismatch')
1373
+ }
1374
+ break;
1375
+ case 'a':
1376
+ readdata = {};
1377
+
1378
+ keyandchrs = readUntil(data, dataoffset, ':');
1379
+ chrs = keyandchrs[0];
1380
+ keys = keyandchrs[1];
1381
+ dataoffset += chrs + 2;
1382
+
1383
+ length = parseInt(keys, 10);
1384
+ contig = true;
1385
+
1386
+ for (i = 0; i < length; i++) {
1387
+ kprops = _unserialize(data, dataoffset);
1388
+ kchrs = kprops[1];
1389
+ key = kprops[2];
1390
+ dataoffset += kchrs;
1391
+
1392
+ vprops = _unserialize(data, dataoffset);
1393
+ vchrs = vprops[1];
1394
+ value = vprops[2];
1395
+ dataoffset += vchrs;
1396
+
1397
+ if (key !== i) {
1398
+ contig = false;
1399
+ }
1400
+
1401
+ readdata[key] = value;
1402
+ }
1403
+
1404
+ if (contig) {
1405
+ array = new Array(length)
1406
+ for (i = 0; i < length; i++) {
1407
+ array[i] = readdata[i];
1408
+ }
1409
+ readdata = array;
1410
+ }
1411
+
1412
+ dataoffset += 1;
1413
+ break;
1414
+ default:
1415
+ error('SyntaxError', 'Unknown / Unhandled data type(s): ' + dtype);
1416
+ break;
1417
+ }
1418
+
1419
+ return [dtype, dataoffset - offset, typeconvert(readdata)]
1420
+ }
1421
+
1422
+ return _unserialize((data + ''), 0)[2];
1423
+ };
1424
+
1425
+ SGPBPopup.closePopup = function()
1426
+ {
1427
+ var popupObjs = window.sgPopupBuilder;
1428
+ var lastPopupObj = this.getLastPopup();
1429
+
1430
+ if (typeof lastPopupObj == 'undefined') {
1431
+ return false;
1432
+ }
1433
+
1434
+ var popupId = lastPopupObj.popupId;
1435
+
1436
+ SGPBPopup.closePopupById(popupId);
1437
+ };
1438
+
1439
+ SGPBPopup.closePopupById = function(popupId)
1440
+ {
1441
+ var popupObjs = window.sgPopupBuilder;
1442
+ if (!popupObjs.length) {
1443
+ return;
1444
+ }
1445
+
1446
+ for (var i in popupObjs) {
1447
+
1448
+ var currentObj = popupObjs[i];
1449
+
1450
+ if (currentObj.popupId == popupId) {
1451
+ var popupObj = popupObjs[i]['popup'];
1452
+ if (popupObj) {
1453
+ /*Send true argument to don’t count disable popup option*/
1454
+ popupObj.close(true);
1455
+ }
1456
+ }
1457
+ }
1458
+ };
1459
+
1460
+ SGPBPopup.getPopupWindowDataById = function(popupId)
1461
+ {
1462
+ var popups = window.sgPopupBuilder;
1463
+ var popup = false;
1464
+
1465
+ if (typeof popups == 'undefined' || !popups.length) {
1466
+ return popup;
1467
+ }
1468
+
1469
+ for (var i in popups) {
1470
+ var popupData = popups[i];
1471
+
1472
+ if (popupData.popupId == popupId) {
1473
+ popup = popupData;
1474
+ break;
1475
+ }
1476
+ }
1477
+
1478
+ return popup;
1479
+ };
1480
+
1481
+ SGPBPopup.findPopupObjById = function(popupId)
1482
+ {
1483
+ var popup = false;
1484
+ var popupData = SGPBPopup.getPopupWindowDataById(popupId);
1485
+
1486
+ if (popupData) {
1487
+ popup = popupData['popup'];
1488
+ }
1489
+
1490
+ return popup;
1491
+ };
1492
+
1493
+ SGPBPopup.getLastPopup = function()
1494
+ {
1495
+ var popups = window.sgPopupBuilder;
1496
+ var popup = false;
1497
+
1498
+ if (!popups.length) {
1499
+ return popup;
1500
+ }
1501
+
1502
+ var searchPopups = [].concat(popups);
1503
+
1504
+ for (var i in searchPopups) {
1505
+ var popupData = searchPopups[i];
1506
+
1507
+ if (popupData.isOpen) {
1508
+ popup = popupData;
1509
+ break;
1510
+ }
1511
+ }
1512
+
1513
+ return popup;
1514
+ };
1515
+
1516
+ SGPBPopup.offPopup = function(currentPopup)
1517
+ {
1518
+ var popups = window.sgPopupBuilder;
1519
+
1520
+ if (!popups.length) {
1521
+ return false;
1522
+ }
1523
+
1524
+ for (var i in popups) {
1525
+ var popupData = popups[i];
1526
+
1527
+ if (popupData.order == currentPopup.order && popupData.eventName == currentPopup.eventName) {
1528
+ popups[i]['isOpen'] = false;
1529
+ break;
1530
+ }
1531
+ }
1532
+
1533
+ return true;
1534
+ };
1535
+
1536
+ SGPBPopup.capitalizeFirstLetter = function(string)
1537
+ {
1538
+ return string.charAt(0).toUpperCase() + string.slice(1);
1539
+ };
1540
+
1541
+ SGPBPopup.getParamFromUrl = function(param)
1542
+ {
1543
+ var url = window.location.href;
1544
+ param = param.replace(/[\[\]]/g, "\\$&");
1545
+ var regex = new RegExp("[?&]" + param + "(=([^&#]*)|&|#|$)"),
1546
+ results = regex.exec(url);
1547
+ if (!results) {
1548
+ return null;
1549
+ }
1550
+ if (!results[2]) {
1551
+ return '';
1552
+ }
1553
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
1554
+ };
1555
+
1556
+ /*
1557
+ *
1558
+ * SGPBPopup Cookies' settings
1559
+ *
1560
+ */
1561
+
1562
+ SGPBPopup.setCookie = function(cName, cValue, exDays, cPageLevel)
1563
+ {
1564
+ var isPreview = SGPBPopup.getParamFromUrl('preview');
1565
+ if (isPreview) {
1566
+ return false;
1567
+ }
1568
+ var expirationDate = new Date();
1569
+ var cookiePageLevel = 'path=/;';
1570
+ var cookieExpirationData = 1;
1571
+ if (!exDays || isNaN(exDays)) {
1572
+ exDays = 365*50;
1573
+ }
1574
+ if (typeof cPageLevel == 'undefined') {
1575
+ cPageLevel = false;
1576
+ }
1577
+
1578
+ expirationDate.setDate(parseInt(expirationDate.getDate() + parseInt(exDays)));
1579
+ cookieExpirationData = expirationDate.toString();
1580
+ var expires = 'expires='+cookieExpirationData;
1581
+
1582
+ if (exDays == -1) {
1583
+ expires = '';
1584
+ }
1585
+
1586
+ if (cPageLevel) {
1587
+ cookiePageLevel = 'path=' + cPageLevel + ';';
1588
+ }
1589
+
1590
+ var value = cValue+((exDays == null) ? ';' : '; '+expires+';'+cookiePageLevel);
1591
+ document.cookie = cName + '=' + value;
1592
+ };
1593
+
1594
+ SGPBPopup.getCookie = function(cName)
1595
+ {
1596
+ var name = cName + '=';
1597
+ var ca = document.cookie.split(';');
1598
+ for (var i = 0; i < ca.length; i++) {
1599
+ var c = ca[i];
1600
+ while (c.charAt(0) == ' ') {
1601
+ c = c.substring(1);
1602
+ }
1603
+ if (c.indexOf(name) == 0) {
1604
+ return c.substring(name.length, c.length);
1605
+ }
1606
+ }
1607
+
1608
+ return '';
1609
+ };
1610
+
1611
+ /*
1612
+ *
1613
+ * Delete the cookie by expiring it
1614
+ *
1615
+ */
1616
+
1617
+ SGPBPopup.deleteCookie = function(cName, cPath)
1618
+ {
1619
+ if (!cPath) {
1620
+ cPath = 'path=/;';
1621
+ }
1622
+
1623
+ document.cookie = cName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;' + cPath;
1624
+ };
1625
+
1626
+ /**
1627
+ *
1628
+ * @SgpbEventListener listen Events and call corresponding events
1629
+ *
1630
+ *
1631
+ *
1632
+ *
1633
+ *
1634
+ *
1635
+ *
1636
+ *
1637
+ *
1638
+ */
1639
+
1640
+ function SgpbEventListener()
1641
+ {
1642
+ this.evenets = null;
1643
+ this.popupObj = {};
1644
  }
1645
+
1646
  SgpbEventListener.inactivityIdicator = 0;
1647
+
1648
+ SgpbEventListener.prototype.setEvents = function(events)
1649
+ {
1650
+ this.evenets = events;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1651
  };
1652
+
1653
+ SgpbEventListener.prototype.getEvents = function()
1654
+ {
1655
+ return this.evenets;
1656
+ };
1657
+
1658
+ SgpbEventListener.prototype.setPopupObj = function(popupObj)
1659
+ {
1660
+ this.popupObj = popupObj;
1661
+ };
1662
+
1663
+ SgpbEventListener.prototype.getPopupObj = function()
1664
+ {
1665
+ return this.popupObj;
1666
+ };
1667
+
1668
+ SgpbEventListener.init = function()
1669
+ {
1670
+ var popupsData = jQuery('.sg-popup-builder-content');
1671
+
1672
+ if (!popupsData) {
1673
+ return '';
1674
+ }
1675
+
1676
+ var that = this;
1677
+
1678
+ popupsData.each(function() {
1679
+ that.popupObjCreator(jQuery(this));
1680
+ });
1681
+
1682
+ };
1683
+
1684
+ SgpbEventListener.popupObjCreator = function(currentData)
1685
+ {
1686
+ var popupId = currentData.data('id');
1687
+ var popupData = currentData.data('options');
1688
+ var events = currentData.data('events');
1689
+
1690
+ SgpbEventListener.reopenAfterFormSubmission(popupData);
1691
+
1692
+ var popupObj = new SGPBPopup();
1693
+ popupObj.setPopupId(popupId);
1694
+ popupObj.setPopupData(popupData);
1695
+
1696
+ for (var i in events) {
1697
+ var obj = new this;
1698
+ obj.setPopupObj(popupObj);
1699
+ obj.eventListener(events[i]);
1700
+ }
1701
+
1702
+ };
1703
+
1704
+ SgpbEventListener.prototype.eventListener = function(eventData)
1705
+ {
1706
+ if (eventData == null) {
1707
+ return '';
1708
+ }
1709
+ var event = '';
1710
+ if (typeof eventData == 'string') {
1711
+ event = eventData;
1712
+ }
1713
+ else if (typeof eventData.param != 'undefined') {
1714
+ event = eventData.param;
1715
+ }
1716
+
1717
+ if (!event) {
1718
+ return false;
1719
+ }
1720
+
1721
+ var popupObj = this.getPopupObj();
1722
+ var popupData = popupObj.getPopupData();
1723
+
1724
+ if (eventData.value == '') {
1725
+ eventData.value = popupData['sgpb-popup-delay'];
1726
+ }
1727
+
1728
+ var eventName = SGPBPopup.capitalizeFirstLetter(event);
1729
+
1730
+ eventName = 'sgpb'+eventName;
1731
+ popupObj.eventName = eventName;
1732
+
1733
+ try {
1734
+ eval('this.'+eventName)(this, eventData);
1735
+ }
1736
+ catch (err) {
1737
+ console.log(err)
1738
+ }
1739
+
1740
+ };
1741
+
1742
+ SgpbEventListener.reopenAfterFormSubmission = function(eventData)
1743
+ {
1744
+ var popupId = SGPBPopup.getCookie('SGPBSubmissionReloadPopup');
1745
+ popupId = parseInt(popupId);
1746
+
1747
+ if (!popupId) {
1748
+ return false;
1749
+ }
1750
+ var popupObj = SGPBPopup.createPopupObjById(popupId);
1751
+ if (!popupObj) {
1752
+ return false;
1753
+ }
1754
+ var options = popupObj.getPopupData();
1755
+
1756
+ if (!options['sgpb-reopen-after-form-submission']) {
1757
+ return false;
1758
+ }
1759
+
1760
+ popupObj.prepareOpen();
1761
+ SGPBPopup.deleteCookie('SGPBSubmissionReloadPopup');
1762
+ };
1763
+
1764
+ SgpbEventListener.prototype.sgpbLoad = function(listenerObj, eventData)
1765
+ {
1766
+ var timeout = parseInt(eventData.value);
1767
+ var popupObj = listenerObj.getPopupObj();
1768
+ timeout = timeout*1000;
1769
+ var timerId,
1770
+ repetitiveTimeout = null;
1771
+
1772
+ sgAddEvent(window, 'load', function() {
1773
+ clearInterval(timerId);
1774
+ timerId = setTimeout(function() {
1775
+ popupObj.prepareOpen();
1776
+ }, timeout);
1777
+ });
1778
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
1779
+ var args = e.detail;
1780
+ clearInterval(repetitiveTimeout);
1781
+ });
1782
+
1783
+ sgAddEvent(window, 'sgpbDidClose', function(e) {
1784
+ var args = e.detail;
1785
+ var options = popupObj.getPopupData();
1786
+
1787
+ if (SGPBPopup.varToBool(eventData['repetitive'])) {
1788
+ var intervalTime = parseInt(eventData['value'])*1000;
1789
+ repetitiveTimeout = setInterval(function() {
1790
+ popupObj.prepareOpen();
1791
+ }, intervalTime);
1792
+ }
1793
+ });
1794
+ };
1795
+
1796
+ SgpbEventListener.prototype.timerIncrement = function(listenerObj , idleInterval)
1797
+ {
1798
+ var lastActivity = SgpbEventListener.inactivityIdicator;
1799
+
1800
+ if (lastActivity == 0) {
1801
+ clearInterval(idleInterval);
1802
+ listenerObj.getPopupObj().prepareOpen();
1803
+ }
1804
+ SgpbEventListener.inactivityIdicator = 0;
1805
+ };
1806
+
1807
+ SgpbEventListener.prototype.sgpbOnScroll = function(listenerObj, eventData)
1808
+ {
1809
+ var that = this;
1810
+ var percent = parseInt(eventData.value);
1811
+ var scrollStatus = false;
1812
+
1813
+ jQuery(window).on('scroll', function() {
1814
+
1815
+ var scrollTop = jQuery(window).scrollTop();
1816
+ var docHeight = jQuery(document).height();
1817
+ var winHeight = jQuery(window).height();
1818
+ var scrollPercent = (scrollTop) / (docHeight - winHeight);
1819
+ var scrollPercentRounded = Math.round(scrollPercent*100);
1820
+ if (percent < scrollPercentRounded) {
1821
+ if (scrollStatus == false) {
1822
+ listenerObj.getPopupObj().prepareOpen();
1823
+ scrollStatus = true;
1824
+ }
1825
+ }
1826
+ });
1827
+ };
1828
+
1829
+ SgpbEventListener.prototype.sgpbInsideclick = function(listenerObj, eventData)
1830
+ {
1831
+ sgAddEvent(window, 'sgpbDidOpen', function(e) {
1832
+ var args = e.detail;
1833
+ var that = listenerObj;
1834
+ var popupObj = that.getPopupObj();
1835
+ var popupId = parseInt(popupObj.id);
1836
+ var targetClick = jQuery('.sgpb-content .sgpb-popup-id-'+popupId);
1837
+
1838
+ if (!targetClick.length) {
1839
+ return false;
1840
+ }
1841
+
1842
+ targetClick.each(function() {
1843
+ jQuery(this).unbind('click').bind('click', function() {
1844
+ SGPBPopup.closePopup();
1845
+ popupObj.prepareOpen();
1846
+ });
1847
+ });
1848
+ });
1849
+ };
1850
+
1851
+ SgpbEventListener.prototype.sgpbClick = function(listenerObj, eventData)
1852
+ {
1853
+ var that = listenerObj;
1854
+ var popupIds = [];
1855
+ var popupObj = that.getPopupObj();
1856
+ var popupOptions = popupObj.getPopupData();
1857
+ var popupId = parseInt(popupObj.id);
1858
+ popupIds.push(popupId);
1859
+ var mapId = listenerObj.filterPopupId(popupId);
1860
+ popupIds.push(mapId);
1861
+
1862
+ for(var key in popupIds) {
1863
+ var popupId = popupIds[key];
1864
+ if (!popupIds.hasOwnProperty(key)) {
1865
+ return false;
1866
+ }
1867
+ var targetClick = jQuery('a[href*="#sg-popup-id-' + popupId + '"], .sg-popup-id-' + popupId + ', .sgpb-popup-id-' + popupId);
1868
+
1869
+ if (!targetClick.length) {
1870
+ continue;
1871
+ }
1872
+ var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1873
+ var clickCount = 1;
1874
+ targetClick.each(function() {
1875
+ jQuery(this).bind('click', function(e) {
1876
+ e.preventDefault();
1877
+ if (clickCount > 1) {
1878
+ return false;
1879
+ }
1880
+ ++clickCount;
1881
+ jQuery(window).trigger('sgpbClickEvent', popupOptions);
1882
+ setTimeout(function() {
1883
+ popupObj.prepareOpen();
1884
+ clickCount = 1;
1885
+ }, delay);
1886
+ });
1887
+ });
1888
+ }
1889
+ };
1890
+
1891
+ SgpbEventListener.prototype.sgpbHover = function(listenerObj, eventData)
1892
+ {
1893
+ var that = listenerObj;
1894
+ var popupObj = that.getPopupObj();
1895
+
1896
+ if (!popupObj) {
1897
+ return false;
1898
+ }
1899
+ var popupIds = [];
1900
+ var popupOptions = popupObj.getPopupData();
1901
+ var popupId = parseInt(popupObj.id);
1902
+ popupIds.push(popupId);
1903
+ var mapId = listenerObj.filterPopupId(popupId);
1904
+ popupIds.push(mapId);
1905
+
1906
+ for(var key in popupIds) {
1907
+ var popupId = popupIds[key];
1908
+ if (!popupIds.hasOwnProperty(key)) {
1909
+ return false;
1910
+ }
1911
+
1912
+ var hoverSelector = jQuery('.sg-popup-hover-' + popupId + ', .sgpb-popup-id-' + popupId + '[data-popup-event="hover"]');
1913
+
1914
+ if (!hoverSelector) {
1915
+ return false;
1916
+ }
1917
+ var hoverCount = 1;
1918
+ var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1919
+ hoverSelector.bind('hover', function() {
1920
+ if (hoverCount > 1) {
1921
+ return false;
1922
+ }
1923
+ ++hoverCount;
1924
+ jQuery(window).trigger('sgpbHoverEvent', popupOptions);
1925
+ setTimeout(function() {
1926
+ popupObj.prepareOpen();
1927
+ hoverCount = 1;
1928
+ }, delay);
1929
+ });
1930
+ }
1931
+ };
1932
+
1933
+ SgpbEventListener.prototype.sgpbConfirm = function(listenerObj, eventData)
1934
+ {
1935
+ var that = listenerObj;
1936
+ var popupObj = that.getPopupObj();
1937
+
1938
+ if (!popupObj) {
1939
+ return false;
1940
+ }
1941
+ var popupIds = [];
1942
+ var popupOptions = popupObj.getPopupData();
1943
+ var popupId = parseInt(popupObj.id);
1944
+ popupIds.push(popupId);
1945
+ var mapId = listenerObj.filterPopupId(popupId);
1946
+ popupIds.push(mapId);
1947
+
1948
+ for(var key in popupIds) {
1949
+ var popupId = popupIds[key];
1950
+ if (!popupIds.hasOwnProperty(key)) {
1951
+ return false;
1952
+ }
1953
+
1954
+ var confirmSelector = jQuery('.sg-confirm-popup-' + popupId);
1955
+
1956
+ if (!confirmSelector) {
1957
+ return false;
1958
+ }
1959
+ var confirmCount = 1;
1960
+
1961
+ confirmSelector.bind('click', function(e) {
1962
+ e.preventDefault();
1963
+
1964
+ if (confirmCount > 1) {
1965
+ return false;
1966
+ }
1967
+ ++confirmCount;
1968
+ jQuery(window).trigger('sgpbConfirmEvent', popupOptions);
1969
+ var target = jQuery(this).attr('target');
1970
+
1971
+ if (typeof target == 'undefined') {
1972
+ target = 'self';
1973
+ }
1974
+ var href = jQuery(this).attr('href');
1975
+ var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
1976
+ setTimeout(function() {
1977
+ if (typeof href != 'undefined') {
1978
+ popupOptions['sgpb-confirm-' + popupId] = {'target' : target, 'href' : href};
1979
+ popupObj.setPopupData(popupOptions);
1980
+ }
1981
+ popupObj.prepareOpen();
1982
+ confirmCount = 1;
1983
+ }, delay);
1984
+
1985
+ });
1986
+
1987
+ sgAddEvent(window, 'sgpbDidClose', function(e) {
1988
+ var args = e.detail;
1989
+ var popupId = parseInt(args.popupId);
1990
+ var popupOptions = args.popupData;
1991
+
1992
+ if (typeof popupOptions['sgpb-confirm-' + popupId] != 'undefined') {
1993
+ var confirmAgrs = popupOptions['sgpb-confirm-' + popupId];
1994
+
1995
+ if (confirmAgrs['target'] == '_blank') {
1996
+ window.open(confirmAgrs['href']);
1997
+ }
1998
+ else {
1999
+ window.location.href = confirmAgrs['href'];
2000
+ }
2001
+
2002
+ delete popupOptions['sgpb-confirm-' + popupId];
2003
+ popupObj.setPopupData(popupOptions);
2004
+ }
2005
+ });
2006
+ }
2007
+ };
2008
+
2009
+ SgpbEventListener.prototype.sgpbIframe = function(listenerObj, eventData)
2010
+ {
2011
+ var that = listenerObj;
2012
+ var popupObj = that.getPopupObj();
2013
+ var popupId = parseInt(popupObj.id);
2014
+ popupId = listenerObj.filterPopupId(popupId);
2015
+ var popupOptions = popupObj.getPopupData();
2016
+ var iframeCount = 1;
2017
+ var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2018
+
2019
+ jQuery('.sg-iframe-popup-' + popupId).each(function() {
2020
+ jQuery(this).bind('click', function(e) {
2021
+ e.preventDefault();
2022
+
2023
+ var link = jQuery(this).attr('href');
2024
+
2025
+ if (typeof link == 'undefined') {
2026
+ var childLinkTag = jQuery(this).find('a');
2027
+ link = jQuery(this).attr('href');
2028
+
2029
+ if (typeof link == 'undefined') {
2030
+ return false;
2031
+ }
2032
+ }
2033
+
2034
+ if (iframeCount > 1) {
2035
+ return false;
2036
+ }
2037
+ ++iframeCount;
2038
+ jQuery(window).trigger('sgpbIframeEvent', popupOptions);
2039
+ setTimeout(function() {
2040
+ popupOptions['sgpb-iframe-' + popupId] = link;
2041
+ popupObj.setPopupData(popupOptions);
2042
+
2043
+ popupObj.prepareOpen();
2044
+ var currentIframe = jQuery('.sgpb-popup-builder-content-' + popupId).find('iframe');
2045
+ currentIframe.data('attr-src', link);
2046
+ iframeCount = 1;
2047
+ return false;
2048
+ }, delay);
2049
+ });
2050
+ });
2051
+ };
2052
+
2053
+ SgpbEventListener.prototype.sgpbAttronload = function(listenerObj, eventData)
2054
+ {
2055
+ var that = listenerObj;
2056
+ var popupObj = that.getPopupObj();
2057
+ var popupId = parseInt(popupObj.id);
2058
+ popupId = listenerObj.filterPopupId(popupId);
2059
+ var popupOptions = popupObj.getPopupData();
2060
+ var delay = parseInt(popupOptions['sgpb-popup-delay']) * 1000;
2061
+ jQuery(window).trigger('sgpbAttronloadEvent', popupOptions);
2062
+
2063
+ setTimeout(function() {
2064
+ popupObj.prepareOpen();
2065
+ }, delay);
2066
+ };
2067
+
2068
+ /*for the old popups*/
2069
+ SgpbEventListener.prototype.filterPopupId = function(popupId)
2070
+ {
2071
+ var convertedIds = SGPB_POPUP_PARAMS.convertedIdsReverse;
2072
+
2073
+ if (convertedIds[popupId]) {
2074
+ return convertedIds[popupId];
2075
+ }
2076
+
2077
+ return popupId;
2078
+ };
2079
+
2080
+ SgpbEventListener.findCF7InPopup = function(popupId)
2081
+ {
2082
+ return document.querySelector('#sg-popup-content-wrapper-'+popupId+' .wpcf7');
2083
+ };
2084
+
2085
+ SgpbEventListener.processCF7MailSent = function(popupId, options)
2086
+ {
2087
+ var wpcf7Elm = SgpbEventListener.findCF7InPopup(popupId);
2088
+
2089
+ if (wpcf7Elm) {
2090
+ wpcf7Elm.addEventListener('wpcf7mailsent', function(event) {
2091
+ if (typeof options['operator'] == 'undefined') {
2092
+ return;
2093
+ }
2094
+
2095
+ if (options['operator'] == 'close-popup') {
2096
+ setTimeout(function() {
2097
+ SGPBPopup.closePopupById(popupId);
2098
+ }, parseInt(options['value'])*1000);
2099
+ }
2100
+ else if (options['operator'] == 'redirect-url') {
2101
+ window.location.href = options['value'];
2102
+ }
2103
+ else if (options['operator'] == 'open-popup') {
2104
+ SGPBPopup.closePopupById(popupId);
2105
+ var popupObj = SGPBPopup.createPopupObjById(Object.keys(options['value'])[0]);
2106
+ popupObj.prepareOpen();
2107
+ }
2108
+ }, false);
2109
+ }
2110
+ };
2111
+
2112
  jQuery(document).ready(function(e) {
2113
+ SgpbEventListener.init();
2114
+ });
public/js/PopupConfig.js CHANGED
@@ -5,5 +5,5 @@ String.prototype.firstToLowerCase=function()
5
  {return this.charAt(0).toUpperCase()+this.slice(1);};PopupConfig.prototype.magicCall=function(functionName,arrgname)
6
  {if(functionName.indexOf('get')!=-1){var param=functionName.replace(/^get/g,"").firstToLowerCase();return this[param];}
7
  else{var param=functionName.replace(/^set/g,"").firstToLowerCase();this[param]=arrgname;}};PopupConfig.prototype.addCustomEvent=function(eventName,args)
8
- {var event=new CustomEvent(eventName,{'detail':args});window.dispatchEvent(event);};PopupConfig.prototype.combineConfigObj=function()
9
  {var that=this;var eventSendArgs={'popupId':that.popupId,'popupData':that.popupData,'currentObj':that.currentObj};var config={openDelay:this.openDelay,popupTheme:this.popupTheme,closeBehavior:{allowed:this.allowed,showButton:this.showButton,buttonPosition:this.buttonPosition,buttonInside:this.buttonInside,autoclose:this.autoclose,overlayShouldClose:this.overlayShouldClose,contentShouldClose:this.contentShouldClose,escShouldClose:this.escShouldClose,right:this.closeButtonPositionRight,top:this.closeButtonPositionTop,bottom:this.closeButtonPositionBottom,left:this.closeButtonPositionLeft},openAnimation:{type:this.openAnimationEffect,speed:this.openAnimationSpeed,status:this.openAnimationStatus},closeButton:{data:this.buttonImage,width:this.closeButtonWidth,height:this.closeButtonHeight,widthType:this.closeButtonWidthType,heightType:this.closeButtonHeightType,type:this.closeButtonType,text:this.closeButtonText},overlay:{visible:this.overlayVisible,color:this.overlayColor,opacity:this.overlayOpacity,addClass:this.overlayAddClass},contentBox:{padding:this.contentPadding,zIndex:this.zIndex,showBackground:this.contentShowBackground,backgroundColor:this.contentBackgroundColor,backgroundImage:this.contentBackgroundImage,backgroundMode:this.contentBackgroundMode,borderStyle:this.contentBorderStyle,borderRadius:this.contentBorderRadius,borderRadiusType:this.contentBorderRadiusType,borderColor:this.contentBorderColor,borderWidth:this.contentBorderWidth,boxBorderWidth:this.boxBorderWidth,shadowColor:this.contentShadowColor,shadowBlur:this.contentShadowBlur,scrollingEnabled:this.scrollingEnabled,shadowSpread:this.shadowSpread,addClass:this.contentAddClass},contents:this.contents,inline:this.srcElement,iframe:false,position:{right:this.positionRight,top:this.positionTop,bottom:this.positionBottom,left:this.positionLeft},sizingRanges:[{screenFrom:{width:0,height:0},screenTo:{width:399,height:3000},width:'100%',height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight},{screenFrom:{width:400,height:0},screenTo:{width:3000,height:3000},width:this.width,height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight}],shouldOpen:function(){that.addCustomEvent('sgpbShouldOpen',eventSendArgs);return true;},willOpen:function(){that.addCustomEvent('sgpbWillOpen',eventSendArgs);},didOpen:function(){that.addCustomEvent('sgpbDidOpen',eventSendArgs);},shouldClose:function(){that.addCustomEvent('sgpbShouldClose',eventSendArgs);return true;},willClose:function(){that.addCustomEvent('sgpbWillClose',eventSendArgs);},didClose:function(){that.addCustomEvent('sgpbDidClose',eventSendArgs);}};return config;};var obj=new PopupConfig();
5
  {return this.charAt(0).toUpperCase()+this.slice(1);};PopupConfig.prototype.magicCall=function(functionName,arrgname)
6
  {if(functionName.indexOf('get')!=-1){var param=functionName.replace(/^get/g,"").firstToLowerCase();return this[param];}
7
  else{var param=functionName.replace(/^set/g,"").firstToLowerCase();this[param]=arrgname;}};PopupConfig.prototype.addCustomEvent=function(eventName,args)
8
+ {var event=document.createEvent('CustomEvent');event.initCustomEvent(eventName,true,true,args);window.dispatchEvent(event);};PopupConfig.prototype.combineConfigObj=function()
9
  {var that=this;var eventSendArgs={'popupId':that.popupId,'popupData':that.popupData,'currentObj':that.currentObj};var config={openDelay:this.openDelay,popupTheme:this.popupTheme,closeBehavior:{allowed:this.allowed,showButton:this.showButton,buttonPosition:this.buttonPosition,buttonInside:this.buttonInside,autoclose:this.autoclose,overlayShouldClose:this.overlayShouldClose,contentShouldClose:this.contentShouldClose,escShouldClose:this.escShouldClose,right:this.closeButtonPositionRight,top:this.closeButtonPositionTop,bottom:this.closeButtonPositionBottom,left:this.closeButtonPositionLeft},openAnimation:{type:this.openAnimationEffect,speed:this.openAnimationSpeed,status:this.openAnimationStatus},closeButton:{data:this.buttonImage,width:this.closeButtonWidth,height:this.closeButtonHeight,widthType:this.closeButtonWidthType,heightType:this.closeButtonHeightType,type:this.closeButtonType,text:this.closeButtonText},overlay:{visible:this.overlayVisible,color:this.overlayColor,opacity:this.overlayOpacity,addClass:this.overlayAddClass},contentBox:{padding:this.contentPadding,zIndex:this.zIndex,showBackground:this.contentShowBackground,backgroundColor:this.contentBackgroundColor,backgroundImage:this.contentBackgroundImage,backgroundMode:this.contentBackgroundMode,borderStyle:this.contentBorderStyle,borderRadius:this.contentBorderRadius,borderRadiusType:this.contentBorderRadiusType,borderColor:this.contentBorderColor,borderWidth:this.contentBorderWidth,boxBorderWidth:this.boxBorderWidth,shadowColor:this.contentShadowColor,shadowBlur:this.contentShadowBlur,scrollingEnabled:this.scrollingEnabled,shadowSpread:this.shadowSpread,addClass:this.contentAddClass},contents:this.contents,inline:this.srcElement,iframe:false,position:{right:this.positionRight,top:this.positionTop,bottom:this.positionBottom,left:this.positionLeft},sizingRanges:[{screenFrom:{width:0,height:0},screenTo:{width:399,height:3000},width:'100%',height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight},{screenFrom:{width:400,height:0},screenTo:{width:3000,height:3000},width:this.width,height:this.height,maxWidth:this.maxWidth,maxHeight:this.maxHeight,minWidth:this.minWidth,minHeight:this.minHeight}],shouldOpen:function(){that.addCustomEvent('sgpbShouldOpen',eventSendArgs);return true;},willOpen:function(){that.addCustomEvent('sgpbWillOpen',eventSendArgs);},didOpen:function(){that.addCustomEvent('sgpbDidOpen',eventSendArgs);},shouldClose:function(){that.addCustomEvent('sgpbShouldClose',eventSendArgs);return true;},willClose:function(){that.addCustomEvent('sgpbWillClose',eventSendArgs);},didClose:function(){that.addCustomEvent('sgpbDidClose',eventSendArgs);}};return config;};var obj=new PopupConfig();
public/views/subscribers.php CHANGED
@@ -105,3 +105,9 @@ $subscribersSelectbox = AdminHelper::createSelectBox(
105
  </div>
106
  </div>
107
  <!-- add subscribers popup end -->
 
 
 
 
 
 
105
  </div>
106
  </div>
107
  <!-- add subscribers popup end -->
108
+
109
+ <style type="text/css">
110
+ .select2-container {
111
+ z-index: 9999;
112
+ }
113
+ </style>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Author: Popup Builder
5
  Donate link: https://popup-builder.com
6
  Tags: popup, pop up, wordpress popup, popup maker, exit popup, popup builder, wordpress popup plugin
7
  Requires at least: 3.8
8
- Tested up to: 4.9.6
9
  Requires PHP: 5.3.3
10
  Stable tag: trunk
11
  License: GPLv2 or later
@@ -166,6 +166,15 @@ Go to the Popup Builder settings and set your desired options.
166
 
167
  == Changelog ==
168
 
 
 
 
 
 
 
 
 
 
169
  = Version 3.0.2 =
170
  * Bug fixed connected to mail subject.
171
  * Bug fixed subscription popup type.
5
  Donate link: https://popup-builder.com
6
  Tags: popup, pop up, wordpress popup, popup maker, exit popup, popup builder, wordpress popup plugin
7
  Requires at least: 3.8
8
+ Tested up to: 4.9.7
9
  Requires PHP: 5.3.3
10
  Stable tag: trunk
11
  License: GPLv2 or later
166
 
167
  == Changelog ==
168
 
169
+ = Version 3.0.3 =
170
+ * Bug fixed connected to update from v2 to v3 when popups disappear.
171
+ * Compatability with old popup (v2) classes. Example sg-popup-id-1.
172
+ * Popup preview big fixed.
173
+ * Bug fixed connected to selected pages/post for popup showing.
174
+ * Bug fixed connected to new line brake inside the TinyMCE.
175
+ * Bug fixed connected to close button image rendering issue.
176
+ * Bug fixed connected to popup themes.
177
+
178
  = Version 3.0.2 =
179
  * Bug fixed connected to mail subject.
180
  * Bug fixed subscription popup type.