WhatsApp me - Version 4.1.7

Version Description

  • FIX jQuery 3 deprecation warnings for event shorthands
  • FIX JSON error with """ on variable replacement
  • FIX Don't load public hooks on wp-login.php page
Download this release

Release Info

Developer creapuntome
Plugin Icon 128x128 WhatsApp me
Version 4.1.7
Comparing to
See all releases

Code changes from version 4.1.6 to 4.1.7

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: whatsapp business, whatsapp, click to chat, button, whatsapp support chat,
5
  Requires at least: 3.0.1
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
- Stable tag: 4.1.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -214,6 +214,11 @@ There is a Javascript event that Join.chat triggers automatically before launch
214
 
215
  == Changelog ==
216
 
 
 
 
 
 
217
  = 4.1.6 =
218
  * FIX minor css error introduced in v4.1.5
219
 
5
  Requires at least: 3.0.1
6
  Tested up to: 5.6
7
  Requires PHP: 5.3
8
+ Stable tag: 4.1.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
214
 
215
  == Changelog ==
216
 
217
+ = 4.1.7 =
218
+ * FIX jQuery 3 deprecation warnings for event shorthands
219
+ * FIX JSON error with """ on variable replacement
220
+ * FIX Don't load public hooks on wp-login.php page
221
+
222
  = 4.1.6 =
223
  * FIX minor css error introduced in v4.1.5
224
 
admin/class-joinchat-admin.php CHANGED
@@ -71,7 +71,7 @@ class JoinChatAdmin {
71
  $this->version = $version;
72
 
73
  // Updated in get_settings() at 'admin_init' hook
74
- $this->enhanced_phone = '17.0.3'; // intl-tel-input version
75
  $this->tabs = array();
76
  $this->settings = array();
77
 
71
  $this->version = $version;
72
 
73
  // Updated in get_settings() at 'admin_init' hook
74
+ $this->enhanced_phone = '17.0.8'; // intl-tel-input version
75
  $this->tabs = array();
76
  $this->settings = array();
77
 
admin/js/joinchat.js CHANGED
@@ -64,7 +64,7 @@
64
 
65
  if ($('#joinchat_form').length === 1) {
66
  // Tabs
67
- $('.nav-tab').click(function (e) {
68
  e.preventDefault();
69
  var $navtab = $(this);
70
  var href = $navtab.attr('href');
@@ -81,25 +81,25 @@
81
  });
82
 
83
  // Toggle WhatsApp web option
84
- $('#joinchat_mobile_only').change(function () {
85
  $('#joinchat_whatsapp_web').closest('tr').toggleClass('joinchat-hidden', this.checked);
86
- }).change();
87
 
88
  // Toggle badge option
89
  $('#joinchat_message_delay').on('change input', function () {
90
  $('#joinchat_message_badge, #joinchat_message_views').closest('tr').toggleClass('joinchat-hidden', this.value == '0');
91
- }).change();
92
 
93
  // Show help
94
- $('.joinchat-show-help').click(function (e) {
95
  e.preventDefault();
96
  var help_tab = $(this).attr('href');
97
  if ($('#contextual-help-wrap').is(':visible')) {
98
  $("html, body").animate({ scrollTop: 0 });
99
  } else {
100
- $('#contextual-help-link').click();
101
  }
102
- $(help_tab != '#' ? help_tab : '#tab-link-styles-and-vars').find('a').click();
103
  });
104
 
105
  // Texarea focus and auto height
@@ -138,11 +138,11 @@
138
  }
139
  }
140
 
141
- $('input', $tab_visibility).change(function () {
142
  propagate_inheritance();
143
  });
144
 
145
- $('.joinchat_view_reset').click(function (e) {
146
  e.preventDefault();
147
  $('input[value=""]', $tab_visibility).prop('checked', true);
148
  $('.joinchat_view_all input', $tab_visibility).first().prop('checked', true);
@@ -151,7 +151,7 @@
151
 
152
  propagate_inheritance();
153
 
154
- $('#joinchat_button_image_add').click(function (e) {
155
  e.preventDefault();
156
 
157
  if (!media_frame) {
@@ -184,7 +184,7 @@
184
  media_frame.open();
185
  });
186
 
187
- $('#joinchat_button_image_remove').click(function (e) {
188
  e.preventDefault();
189
 
190
  $('#joinchat_button_image_holder').removeAttr('style');
64
 
65
  if ($('#joinchat_form').length === 1) {
66
  // Tabs
67
+ $('.nav-tab').on('click', function (e) {
68
  e.preventDefault();
69
  var $navtab = $(this);
70
  var href = $navtab.attr('href');
81
  });
82
 
83
  // Toggle WhatsApp web option
84
+ $('#joinchat_mobile_only').on('change', function () {
85
  $('#joinchat_whatsapp_web').closest('tr').toggleClass('joinchat-hidden', this.checked);
86
+ }).trigger('change');
87
 
88
  // Toggle badge option
89
  $('#joinchat_message_delay').on('change input', function () {
90
  $('#joinchat_message_badge, #joinchat_message_views').closest('tr').toggleClass('joinchat-hidden', this.value == '0');
91
+ }).trigger('change');
92
 
93
  // Show help
94
+ $('.joinchat-show-help').on('click', function (e) {
95
  e.preventDefault();
96
  var help_tab = $(this).attr('href');
97
  if ($('#contextual-help-wrap').is(':visible')) {
98
  $("html, body").animate({ scrollTop: 0 });
99
  } else {
100
+ $('#contextual-help-link').trigger('click');
101
  }
102
+ $(help_tab != '#' ? help_tab : '#tab-link-styles-and-vars').find('a').trigger('click');
103
  });
104
 
105
  // Texarea focus and auto height
138
  }
139
  }
140
 
141
+ $('input', $tab_visibility).on('change', function () {
142
  propagate_inheritance();
143
  });
144
 
145
+ $('.joinchat_view_reset').on('click', function (e) {
146
  e.preventDefault();
147
  $('input[value=""]', $tab_visibility).prop('checked', true);
148
  $('.joinchat_view_all input', $tab_visibility).first().prop('checked', true);
151
 
152
  propagate_inheritance();
153
 
154
+ $('#joinchat_button_image_add').on('click', function (e) {
155
  e.preventDefault();
156
 
157
  if (!media_frame) {
184
  media_frame.open();
185
  });
186
 
187
+ $('#joinchat_button_image_remove').on('click', function (e) {
188
  e.preventDefault();
189
 
190
  $('#joinchat_button_image_holder').removeAttr('style');
admin/js/joinchat.min.js CHANGED
@@ -1 +1 @@
1
- !function(h){"use strict";function r(){h(this).height(0).height(this.scrollHeight)}window.intl_tel_input_version=window.intlTelConf&&intlTelConf.version,h(function(){var n,t,a,e,i,o,c,l;function s(t,e){var n;t=t||"all",e=e||h('input[name="joinchat[view]['+t+']"]:checked').val(),h(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e),"cpts"==t?h("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e):t in l&&(n=""===(n=h('input[name="joinchat[view]['+t+']"]:checked').val())?e:n,h.each(l[t],function(){s(this,n)}))}"function"==typeof intlTelInput&&h("#joinchat_phone").length&&(t=JSON.parse(localStorage.joinchat_country_code||"{}"),a=!(!t.code||t.date!=(new Date).toDateString())&&t.code,e=h("#joinchat_phone"),i=""===e.val()?e.attr("placeholder"):null,e.removeAttr("placeholder"),(o=intlTelInput(e.get(0),{hiddenInput:e.data("name")||"joinchat[telephone]",initialCountry:"auto",preferredCountries:[a||""],geoIpLookup:function(e){a?e(a):h.getJSON("https://ipinfo.io").always(function(t){t=t&&t.country?t.country:"";localStorage.joinchat_country_code=JSON.stringify({code:t,date:(new Date).toDateString()}),e(t)})},customPlaceholder:function(t){return intlTelConf.placeholder+" "+t},utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/"+intlTelConf.version+"/js/utils.js"})).hiddenInput.value=e.val(),"string"==typeof i&&""!=i&&o.promise.then(function(){o.setNumber(i),e.attr("placeholder",o.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val("")}),e.on("input",function(){var t=h(this),e=intlTelInputGlobals.getInstance(this);t.css("color",t.val().trim()&&!e.isValidNumber()?"#ca4a1f":""),e.hiddenInput.value=e.getNumber()}).on("blur",function(){var t=intlTelInputGlobals.getInstance(this);t.setNumber(t.getNumber())})),1===h("#joinchat_form").length&&(h(".nav-tab").click(function(t){t.preventDefault();var e=h(this),n=e.attr("href"),a=h("input[name=_wp_http_referer]"),t=a.val();a.val(t.substr(0,t.indexOf("page=joinchat"))+"page=joinchat&tab="+n.substr(14)),h(".nav-tab").removeClass("nav-tab-active").attr("aria-selected","false"),e.addClass("nav-tab-active").attr("aria-selected","true").get(0).blur(),h(".joinchat-tab").removeClass("joinchat-tab-active"),h(n).addClass("joinchat-tab-active").find("textarea").each(r)}),h("#joinchat_mobile_only").change(function(){h("#joinchat_whatsapp_web").closest("tr").toggleClass("joinchat-hidden",this.checked)}).change(),h("#joinchat_message_delay").on("change input",function(){h("#joinchat_message_badge, #joinchat_message_views").closest("tr").toggleClass("joinchat-hidden","0"==this.value)}).change(),h(".joinchat-show-help").click(function(t){t.preventDefault();t=h(this).attr("href");h("#contextual-help-wrap").is(":visible")?h("html, body").animate({scrollTop:0}):h("#contextual-help-link").click(),h("#"!=t?t:"#tab-link-styles-and-vars").find("a").click()}),h("textarea","#joinchat_form").on("focus",function(){h(this).closest("tr").addClass("joinchat--focus")}).on("blur",function(){h(this).closest("tr").removeClass("joinchat--focus")}).on("input",r).each(r),c=h("#joinchat_tab_visibility"),l=h(".joinchat_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]},h("input",c).change(function(){s()}),h(".joinchat_view_reset").click(function(t){t.preventDefault(),h('input[value=""]',c).prop("checked",!0),h(".joinchat_view_all input",c).first().prop("checked",!0),s()}),s(),h("#joinchat_button_image_add").click(function(t){t.preventDefault(),n||((n=wp.media({title:h(this).data("title")||"Select button image",button:{text:h(this).data("button")||"Use Image"},library:{type:"image"},multiple:!1})).on("select",function(){var t=n.state().get("selection").first().toJSON(),e=t.sizes&&t.sizes.thumbnail&&t.sizes.thumbnail.url||t.url;h("#joinchat_button_image_holder").css({"background-size":"cover","background-image":"url("+e+")"}),h("#joinchat_button_image").val(t.id),h("#joinchat_button_image_remove").removeClass("joinchat-hidden")}),n.on("open",function(){var t=wp.media.attachment(h("#joinchat_button_image").val());n.state().get("selection").add(t?[t]:[])})),n.open()}),h("#joinchat_button_image_remove").click(function(t){t.preventDefault(),h("#joinchat_button_image_holder").removeAttr("style"),h("#joinchat_button_image").val(""),h(this).addClass("joinchat-hidden")}),h("#joinchat_color").wpColorPicker(),h("#joinchat_header_custom").on("click",function(){h(this).prev().find("input").prop("checked",!0)})),1===h(".joinchat-metabox").length&&h("textarea",".joinchat-metabox").on("focus input",r).each(r)})}(jQuery);
1
+ !function(r){"use strict";function h(){r(this).height(0).height(this.scrollHeight)}window.intl_tel_input_version=window.intlTelConf&&intlTelConf.version,r(function(){var n,t,a,e,i,o,c,l;function s(t,e){var n;t=t||"all",e=e||r('input[name="joinchat[view]['+t+']"]:checked').val(),r(".view_inheritance_"+t).toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e),"cpts"==t?r("[class*=view_inheritance_cpt_]").toggleClass("dashicons-visibility","yes"==e).toggleClass("dashicons-hidden","no"==e):t in l&&(n=""===(n=r('input[name="joinchat[view]['+t+']"]:checked').val())?e:n,r.each(l[t],function(){s(this,n)}))}"function"==typeof intlTelInput&&r("#joinchat_phone").length&&(t=JSON.parse(localStorage.joinchat_country_code||"{}"),a=!(!t.code||t.date!=(new Date).toDateString())&&t.code,e=r("#joinchat_phone"),i=""===e.val()?e.attr("placeholder"):null,e.removeAttr("placeholder"),(o=intlTelInput(e.get(0),{hiddenInput:e.data("name")||"joinchat[telephone]",initialCountry:"auto",preferredCountries:[a||""],geoIpLookup:function(e){a?e(a):r.getJSON("https://ipinfo.io").always(function(t){t=t&&t.country?t.country:"";localStorage.joinchat_country_code=JSON.stringify({code:t,date:(new Date).toDateString()}),e(t)})},customPlaceholder:function(t){return intlTelConf.placeholder+" "+t},utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/"+intlTelConf.version+"/js/utils.js"})).hiddenInput.value=e.val(),"string"==typeof i&&""!=i&&o.promise.then(function(){o.setNumber(i),e.attr("placeholder",o.getNumber(intlTelInputUtils.numberFormat.NATIONAL)).val("")}),e.on("input",function(){var t=r(this),e=intlTelInputGlobals.getInstance(this);t.css("color",t.val().trim()&&!e.isValidNumber()?"#ca4a1f":""),e.hiddenInput.value=e.getNumber()}).on("blur",function(){var t=intlTelInputGlobals.getInstance(this);t.setNumber(t.getNumber())})),1===r("#joinchat_form").length&&(r(".nav-tab").on("click",function(t){t.preventDefault();var e=r(this),n=e.attr("href"),a=r("input[name=_wp_http_referer]"),t=a.val();a.val(t.substr(0,t.indexOf("page=joinchat"))+"page=joinchat&tab="+n.substr(14)),r(".nav-tab").removeClass("nav-tab-active").attr("aria-selected","false"),e.addClass("nav-tab-active").attr("aria-selected","true").get(0).blur(),r(".joinchat-tab").removeClass("joinchat-tab-active"),r(n).addClass("joinchat-tab-active").find("textarea").each(h)}),r("#joinchat_mobile_only").on("change",function(){r("#joinchat_whatsapp_web").closest("tr").toggleClass("joinchat-hidden",this.checked)}).trigger("change"),r("#joinchat_message_delay").on("change input",function(){r("#joinchat_message_badge, #joinchat_message_views").closest("tr").toggleClass("joinchat-hidden","0"==this.value)}).trigger("change"),r(".joinchat-show-help").on("click",function(t){t.preventDefault();t=r(this).attr("href");r("#contextual-help-wrap").is(":visible")?r("html, body").animate({scrollTop:0}):r("#contextual-help-link").trigger("click"),r("#"!=t?t:"#tab-link-styles-and-vars").find("a").trigger("click")}),r("textarea","#joinchat_form").on("focus",function(){r(this).closest("tr").addClass("joinchat--focus")}).on("blur",function(){r(this).closest("tr").removeClass("joinchat--focus")}).on("input",h).each(h),c=r("#joinchat_tab_visibility"),l=r(".joinchat_view_all").data("inheritance")||{all:["front_page","blog_page","404_page","search","archive","singular","cpts"],archive:["date","author"],singular:["page","post"]},r("input",c).on("change",function(){s()}),r(".joinchat_view_reset").on("click",function(t){t.preventDefault(),r('input[value=""]',c).prop("checked",!0),r(".joinchat_view_all input",c).first().prop("checked",!0),s()}),s(),r("#joinchat_button_image_add").on("click",function(t){t.preventDefault(),n||((n=wp.media({title:r(this).data("title")||"Select button image",button:{text:r(this).data("button")||"Use Image"},library:{type:"image"},multiple:!1})).on("select",function(){var t=n.state().get("selection").first().toJSON(),e=t.sizes&&t.sizes.thumbnail&&t.sizes.thumbnail.url||t.url;r("#joinchat_button_image_holder").css({"background-size":"cover","background-image":"url("+e+")"}),r("#joinchat_button_image").val(t.id),r("#joinchat_button_image_remove").removeClass("joinchat-hidden")}),n.on("open",function(){var t=wp.media.attachment(r("#joinchat_button_image").val());n.state().get("selection").add(t?[t]:[])})),n.open()}),r("#joinchat_button_image_remove").on("click",function(t){t.preventDefault(),r("#joinchat_button_image_holder").removeAttr("style"),r("#joinchat_button_image").val(""),r(this).addClass("joinchat-hidden")}),r("#joinchat_color").wpColorPicker(),r("#joinchat_header_custom").on("click",function(){r(this).prev().find("input").prop("checked",!0)})),1===r(".joinchat-metabox").length&&r("textarea",".joinchat-metabox").on("focus input",h).each(h)})}(jQuery);
includes/class-joinchat-util.php CHANGED
@@ -205,6 +205,7 @@ class JoinChatUtil {
205
  * Format message send, replace vars.
206
  *
207
  * @since 3.1.0
 
208
  * @param string $string string to apply variable replacements
209
  * @return string string with replaced variables
210
  */
@@ -220,14 +221,21 @@ class JoinChatUtil {
220
  )
221
  );
222
 
223
- // Convert VAR to regex {VAR}
224
- $patterns = array_map(
225
- function ( $var ) {
226
- return "/\{$var\}/u";
227
- },
228
- array_keys( $replacements )
 
 
 
229
  );
230
 
 
 
 
 
231
  return preg_replace( $patterns, $replacements, $string );
232
 
233
  }
205
  * Format message send, replace vars.
206
  *
207
  * @since 3.1.0
208
+ * @since 4.1.7 Added replacements fixes
209
  * @param string $string string to apply variable replacements
210
  * @return string string with replaced variables
211
  */
221
  )
222
  );
223
 
224
+ // Patterns as regex {VAR}
225
+ $patterns = array();
226
+ foreach ( $replacements as $var => $replacement ) {
227
+ $patterns[] = "/\{$var\}/u";
228
+ }
229
+
230
+ $fixes = array(
231
+ '"' => '"', // Prevent malformed json
232
+ '$' => '\$', // Prevent regex reference
233
  );
234
 
235
+ foreach ( $replacements as $var => $replacement ) {
236
+ $replacements[ $var ] = str_replace( array_keys( $fixes ), $fixes, $replacement );
237
+ }
238
+
239
  return preg_replace( $patterns, $replacements, $string );
240
 
241
  }
includes/class-joinchat.php CHANGED
@@ -54,6 +54,9 @@ class JoinChat {
54
  * @since 1.0.0
55
  */
56
  public function __construct() {
 
 
 
57
  $this->version = defined( 'JOINCHAT_VERSION' ) ? JOINCHAT_VERSION : '1.0.0';
58
  $this->plugin_name = 'joinchat';
59
 
@@ -61,7 +64,11 @@ class JoinChat {
61
  $this->set_locale();
62
  $this->load_integrations();
63
 
64
- is_admin() ? $this->define_admin_hooks() : $this->define_public_hooks();
 
 
 
 
65
 
66
  add_action( 'joinchat_run_pre', array( $this, 'disable_remove_brand' ), 11 );
67
 
54
  * @since 1.0.0
55
  */
56
  public function __construct() {
57
+
58
+ global $pagenow;
59
+
60
  $this->version = defined( 'JOINCHAT_VERSION' ) ? JOINCHAT_VERSION : '1.0.0';
61
  $this->plugin_name = 'joinchat';
62
 
64
  $this->set_locale();
65
  $this->load_integrations();
66
 
67
+ if ( is_admin() ) {
68
+ $this->define_admin_hooks();
69
+ } elseif ( 'wp-login.php' !== $pagenow ) {
70
+ $this->define_public_hooks();
71
+ }
72
 
73
  add_action( 'joinchat_run_pre', array( $this, 'disable_remove_brand' ), 11 );
74
 
joinchat.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin Name: Join.chat
10
  * Plugin URI: https://join.chat
11
  * Description: Connects a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
12
- * Version: 4.1.6
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
@@ -26,7 +26,7 @@ if ( ! defined( 'WPINC' ) ) {
26
  /**
27
  * Currently plugin version.
28
  */
29
- define( 'JOINCHAT_VERSION', '4.1.6' );
30
 
31
  /**
32
  * The core plugin class that is used to define internationalization,
9
  * Plugin Name: Join.chat
10
  * Plugin URI: https://join.chat
11
  * Description: Connects a WordPress chat with WhatsApp. The best solution for marketing and support. Stop losing customers and increase your sales.
12
+ * Version: 4.1.7
13
  * Author: Creame
14
  * Author URI: https://crea.me
15
  * License: GPL-2.0+
26
  /**
27
  * Currently plugin version.
28
  */
29
+ define( 'JOINCHAT_VERSION', '4.1.7' );
30
 
31
  /**
32
  * The core plugin class that is used to define internationalization,
public/class-joinchat-woopublic.php CHANGED
@@ -153,16 +153,15 @@ class JoinChatWooPublic {
153
  if ( is_product() ) {
154
  $product = wc_get_product();
155
 
156
- $replacements = array_merge(
157
- $replacements,
158
- array(
159
- 'PRODUCT' => $product->get_name(),
160
- 'SKU' => $product->get_sku(),
161
- 'REGULAR' => $this->get_regular_price( $product ),
162
- 'PRICE' => $this->get_price( $product ),
163
- 'DISCOUNT' => $this->get_discount( $product ),
164
- )
165
  );
 
 
166
  }
167
 
168
  return $replacements;
@@ -199,9 +198,6 @@ class JoinChatWooPublic {
199
 
200
  $string = strip_tags( wc_price( wc_get_price_to_display( $product, array( 'price' => $price ) ) ) );
201
 
202
- // Escape $ for regex replacement
203
- return str_replace( '$', '\$', $string );
204
-
205
  }
206
 
207
  /**
153
  if ( is_product() ) {
154
  $product = wc_get_product();
155
 
156
+ $woo_replacements = array(
157
+ 'PRODUCT' => $product->get_name(),
158
+ 'SKU' => $product->get_sku(),
159
+ 'REGULAR' => $this->get_regular_price( $product ),
160
+ 'PRICE' => $this->get_price( $product ),
161
+ 'DISCOUNT' => $this->get_discount( $product ),
 
 
 
162
  );
163
+
164
+ $replacements = array_merge( $replacements, $woo_replacements );
165
  }
166
 
167
  return $replacements;
198
 
199
  $string = strip_tags( wc_price( wc_get_price_to_display( $product, array( 'price' => $price ) ) ) );
200
 
 
 
 
201
  }
202
 
203
  /**
public/js/joinchat.js CHANGED
@@ -116,9 +116,151 @@
116
  }
117
  };
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  // Ready!!
120
  $(function () {
121
  joinchat_obj.$div = $('.joinchat');
 
 
 
 
122
  joinchat_obj.settings = joinchat_obj.$div.data('settings');
123
  joinchat_obj.is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
124
 
@@ -138,12 +280,16 @@
138
 
139
  // In some strange cases data settings are empty
140
  if (typeof joinchat_obj.settings == 'undefined') {
141
- try { joinchat_obj.settings = JSON.parse(joinchat_obj.$div.attr('data-settings')); }
142
- catch (error) { joinchat_obj.settings = undefined; }
 
 
 
 
143
  }
144
 
145
  // Only works if joinchat is defined
146
- if (joinchat_obj.$div.length && !!joinchat_obj.settings && !!joinchat_obj.settings.telephone) {
147
  if (joinchat_obj.is_mobile || !joinchat_obj.settings.mobile_only) {
148
  joinchat_magic();
149
  } else {
@@ -156,144 +302,6 @@
156
  }
157
 
158
  joinchat_obj.store.setItem('joinchat_views', parseInt(joinchat_obj.store.getItem('joinchat_views') || 0) + 1);
159
-
160
- function joinchat_magic() {
161
- $(doc).trigger('joinchat:starting');
162
-
163
- var button_delay = joinchat_obj.settings.button_delay * 1000;
164
- var chat_delay = joinchat_obj.settings.message_delay * 1000;
165
- var has_cta = !!joinchat_obj.settings.message_hash;
166
- var has_chatbox = !!joinchat_obj.$('.joinchat__box').length;
167
- var timeoutHover, timeoutCTA;
168
-
169
- // Stored values
170
- var has_pageviews = parseInt(joinchat_obj.store.getItem('joinchat_views') || 1) >= joinchat_obj.settings.message_views;
171
- var saved_hashes = (joinchat_obj.store.getItem('joinchat_hashes') || '').split(',').filter(Boolean);
172
- var is_viewed = saved_hashes.indexOf(joinchat_obj.settings.message_hash || 'none') !== -1;
173
-
174
- function chatbox_show() {
175
- clearTimeout(timeoutCTA);
176
- joinchat_obj.chatbox_show();
177
- }
178
-
179
- function chatbox_hide() {
180
- joinchat_obj.save_hash();
181
- joinchat_obj.chatbox_hide();
182
- }
183
-
184
- function joinchat_click() {
185
- if (has_chatbox && !joinchat_obj.chatbox) {
186
- chatbox_show();
187
- } else {
188
- chatbox_hide();
189
- joinchat_obj.open_whatsapp();
190
- }
191
- }
192
-
193
- // Show button (and tooltip)
194
- var classes = 'joinchat--show';
195
- if (!is_viewed && (!has_cta || !chat_delay || joinchat_obj.settings.message_badge || !has_pageviews)) {
196
- classes += ' joinchat--tooltip';
197
- }
198
- setTimeout(function () { joinchat_obj.$div.addClass(classes); }, button_delay);
199
-
200
- // Show badge or chatbox
201
- if (has_cta && !is_viewed && chat_delay) {
202
- if (joinchat_obj.settings.message_badge) {
203
- timeoutCTA = setTimeout(function () { joinchat_obj.$('.joinchat__badge').addClass('joinchat__badge--in'); }, button_delay + chat_delay);
204
- } else if (has_pageviews) {
205
- timeoutCTA = setTimeout(chatbox_show, button_delay + chat_delay);
206
- }
207
- }
208
-
209
- // Open Join.chat on mouse over
210
- if (has_chatbox && !joinchat_obj.is_mobile) {
211
- joinchat_obj.$('.joinchat__button')
212
- .mouseenter(function () { timeoutHover = setTimeout(chatbox_show, 1500); })
213
- .mouseleave(function () { clearTimeout(timeoutHover); });
214
- }
215
-
216
- joinchat_obj.$('.joinchat__button').click(joinchat_click);
217
- joinchat_obj.$('.joinchat__close').click(chatbox_hide);
218
-
219
- // Only scroll Join.chat message box (no all body)
220
- // TODO: disable also on touch
221
- joinchat_obj.$('.joinchat__box__scroll').on('mousewheel DOMMouseScroll', function (e) {
222
- e.preventDefault();
223
- var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
224
- this.scrollTop += (delta < 0 ? 1 : -1) * 30;
225
- });
226
-
227
- // Mobile enhancements
228
- if (joinchat_obj.is_mobile) {
229
- var timeoutKB, timeoutResize;
230
-
231
- function form_focus_toggle() {
232
- var type = (doc.activeElement.type || '').toLowerCase();
233
-
234
- if (['date', 'datetime', 'email', 'month', 'number', 'password', 'search', 'tel', 'text', 'textarea', 'time', 'url', 'week'].indexOf(type) >= 0) {
235
- if (joinchat_obj.chatbox) {
236
- joinchat_obj.chatbox_hide();
237
- setTimeout(function () { joinchat_obj.$div.removeClass('joinchat--show'); }, 400);
238
- } else {
239
- joinchat_obj.$div.removeClass('joinchat--show');
240
- }
241
- } else {
242
- joinchat_obj.$div.addClass('joinchat--show');
243
- }
244
- }
245
-
246
- // Hide on mobile when virtual keyboard is open (on fill forms)
247
- $(doc).on('focus blur', 'input, textarea', function (e) {
248
- if (!$(e.target).closest(joinchat_obj.$div).length) {
249
- clearTimeout(timeoutKB);
250
- timeoutKB = setTimeout(form_focus_toggle, 200);
251
- }
252
- });
253
-
254
- // Ensure header is visible
255
- $(win).resize(function () {
256
- clearTimeout(timeoutResize);
257
- timeoutResize = setTimeout(function () { joinchat_obj.$div[0].style.setProperty('--vh', window.innerHeight + 'px'); }, 200);
258
- }).resize();
259
- }
260
-
261
- // Open chatbox or launch WhatsApp when click on nodes with classes "joinchat_open" "joinchat_app"
262
- // or links with href "#joinchat" or "#whatsapp"
263
- $(doc).on('click', '.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]', function (e) {
264
- e.preventDefault();
265
- if (!has_chatbox || $(this).is('.joinchat_app, a[href="#whatsapp"]')) joinchat_obj.open_whatsapp(); // WhatsApp direct
266
- else chatbox_show(); // Open chatbox
267
- });
268
-
269
- // Close chatbox when click on nodes with class "joinchat_close"
270
- $(doc).on('click', '.joinchat_close', function (e) {
271
- e.preventDefault();
272
- joinchat_obj.chatbox_hide();
273
- });
274
-
275
- // Open Join.chat when "joinchat_show" or "joinchat_force_show" on viewport
276
- if (has_chatbox && 'IntersectionObserver' in win) {
277
- var $show_on_scroll = $('.joinchat_show, .joinchat_force_show');
278
-
279
- function joinchat_observed(objs) {
280
- $.each(objs, function () {
281
- if (this.intersectionRatio > 0 && (!is_viewed || $(this.target).hasClass('joinchat_force_show'))) {
282
- chatbox_show();
283
- observer.disconnect(); // Only one show for visit
284
- return false;
285
- }
286
- });
287
- }
288
-
289
- if ($show_on_scroll.length > 0) {
290
- var observer = new IntersectionObserver(joinchat_observed);
291
- $show_on_scroll.each(function () { observer.observe(this); });
292
- }
293
- }
294
-
295
- $(doc).trigger('joinchat:start');
296
- }
297
  });
298
 
299
  }(jQuery, window, document));
116
  }
117
  };
118
 
119
+ function joinchat_magic() {
120
+ $(doc).trigger('joinchat:starting');
121
+
122
+ var button_delay = joinchat_obj.settings.button_delay * 1000;
123
+ var chat_delay = joinchat_obj.settings.message_delay * 1000;
124
+ var has_cta = !!joinchat_obj.settings.message_hash;
125
+ var has_chatbox = !!joinchat_obj.$('.joinchat__box').length;
126
+ var timeoutHover, timeoutCTA;
127
+
128
+ // Stored values
129
+ var has_pageviews = parseInt(joinchat_obj.store.getItem('joinchat_views') || 1) >= joinchat_obj.settings.message_views;
130
+ var saved_hashes = (joinchat_obj.store.getItem('joinchat_hashes') || '').split(',').filter(Boolean);
131
+ var is_viewed = saved_hashes.indexOf(joinchat_obj.settings.message_hash || 'none') !== -1;
132
+
133
+ function chatbox_show() {
134
+ clearTimeout(timeoutCTA);
135
+ joinchat_obj.chatbox_show();
136
+ }
137
+
138
+ function chatbox_hide() {
139
+ joinchat_obj.save_hash();
140
+ joinchat_obj.chatbox_hide();
141
+ }
142
+
143
+ function joinchat_click() {
144
+ if (has_chatbox && !joinchat_obj.chatbox) {
145
+ chatbox_show();
146
+ } else {
147
+ chatbox_hide();
148
+ joinchat_obj.open_whatsapp();
149
+ }
150
+ }
151
+
152
+ // Show button (and tooltip)
153
+ var classes = 'joinchat--show';
154
+ if (!is_viewed && (!has_cta || !chat_delay || joinchat_obj.settings.message_badge || !has_pageviews)) {
155
+ classes += ' joinchat--tooltip';
156
+ }
157
+ setTimeout(function () { joinchat_obj.$div.addClass(classes); }, button_delay);
158
+
159
+ // Show badge or chatbox
160
+ if (has_cta && !is_viewed && chat_delay) {
161
+ if (joinchat_obj.settings.message_badge) {
162
+ timeoutCTA = setTimeout(function () { joinchat_obj.$('.joinchat__badge').addClass('joinchat__badge--in'); }, button_delay + chat_delay);
163
+ } else if (has_pageviews) {
164
+ timeoutCTA = setTimeout(chatbox_show, button_delay + chat_delay);
165
+ }
166
+ }
167
+
168
+ // Open Join.chat on mouse over
169
+ if (has_chatbox && !joinchat_obj.is_mobile) {
170
+ joinchat_obj.$('.joinchat__button')
171
+ .on('mouseenter', function () { timeoutHover = setTimeout(chatbox_show, 1500); })
172
+ .on('mouseleave', function () { clearTimeout(timeoutHover); });
173
+ }
174
+
175
+ joinchat_obj.$('.joinchat__button').on('click', joinchat_click);
176
+ joinchat_obj.$('.joinchat__close').on('click', chatbox_hide);
177
+
178
+ // Only scroll Join.chat message box (no all body)
179
+ // TODO: disable also on touch
180
+ joinchat_obj.$('.joinchat__box__scroll').on('mousewheel DOMMouseScroll', function (e) {
181
+ e.preventDefault();
182
+ var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
183
+ this.scrollTop += (delta < 0 ? 1 : -1) * 30;
184
+ });
185
+
186
+ // Mobile enhancements
187
+ if (joinchat_obj.is_mobile) {
188
+ var timeoutKB, timeoutResize;
189
+
190
+ function form_focus_toggle() {
191
+ var type = (doc.activeElement.type || '').toLowerCase();
192
+
193
+ if (['date', 'datetime', 'email', 'month', 'number', 'password', 'search', 'tel', 'text', 'textarea', 'time', 'url', 'week'].indexOf(type) >= 0) {
194
+ if (joinchat_obj.chatbox) {
195
+ joinchat_obj.chatbox_hide();
196
+ setTimeout(function () { joinchat_obj.$div.removeClass('joinchat--show'); }, 400);
197
+ } else {
198
+ joinchat_obj.$div.removeClass('joinchat--show');
199
+ }
200
+ } else {
201
+ joinchat_obj.$div.addClass('joinchat--show');
202
+ }
203
+ }
204
+
205
+ // Hide on mobile when virtual keyboard is open (on fill forms)
206
+ $(doc).on('focus blur', 'input, textarea', function (e) {
207
+ if (!$(e.target).closest(joinchat_obj.$div).length) {
208
+ clearTimeout(timeoutKB);
209
+ timeoutKB = setTimeout(form_focus_toggle, 200);
210
+ }
211
+ });
212
+
213
+ // Ensure header is visible
214
+ $(win).on('resize', function () {
215
+ clearTimeout(timeoutResize);
216
+ timeoutResize = setTimeout(function () { joinchat_obj.$div[0].style.setProperty('--vh', window.innerHeight + 'px'); }, 200);
217
+ }).trigger('resize');
218
+ }
219
+
220
+ // Open chatbox or launch WhatsApp when click on nodes with classes "joinchat_open" "joinchat_app"
221
+ // or links with href "#joinchat" or "#whatsapp"
222
+ $(doc).on('click', '.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]', function (e) {
223
+ e.preventDefault();
224
+ if (!has_chatbox || $(this).is('.joinchat_app, a[href="#whatsapp"]')) joinchat_obj.open_whatsapp(); // WhatsApp direct
225
+ else chatbox_show(); // Open chatbox
226
+ });
227
+
228
+ // Close chatbox when click on nodes with class "joinchat_close"
229
+ $(doc).on('click', '.joinchat_close', function (e) {
230
+ e.preventDefault();
231
+ joinchat_obj.chatbox_hide();
232
+ });
233
+
234
+ // Open Join.chat when "joinchat_show" or "joinchat_force_show" on viewport
235
+ if (has_chatbox && 'IntersectionObserver' in win) {
236
+ var $show_on_scroll = $('.joinchat_show, .joinchat_force_show');
237
+
238
+ function joinchat_observed(objs) {
239
+ $.each(objs, function () {
240
+ if (this.intersectionRatio > 0 && (!is_viewed || $(this.target).hasClass('joinchat_force_show'))) {
241
+ chatbox_show();
242
+ observer.disconnect(); // Only one show for visit
243
+ return false;
244
+ }
245
+ });
246
+ }
247
+
248
+ if ($show_on_scroll.length > 0) {
249
+ var observer = new IntersectionObserver(joinchat_observed);
250
+ $show_on_scroll.each(function () { observer.observe(this); });
251
+ }
252
+ }
253
+
254
+ $(doc).trigger('joinchat:start');
255
+ }
256
+
257
  // Ready!!
258
  $(function () {
259
  joinchat_obj.$div = $('.joinchat');
260
+
261
+ // Exit if no joinchat div
262
+ if (!joinchat_obj.$div.length) return;
263
+
264
  joinchat_obj.settings = joinchat_obj.$div.data('settings');
265
  joinchat_obj.is_mobile = !!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);
266
 
280
 
281
  // In some strange cases data settings are empty
282
  if (typeof joinchat_obj.settings == 'undefined') {
283
+ try {
284
+ joinchat_obj.settings = JSON.parse(joinchat_obj.$div.attr('data-settings'));
285
+ } catch (error) {
286
+ joinchat_obj.settings = undefined;
287
+ console.error("Join.chat: can't get settings");
288
+ }
289
  }
290
 
291
  // Only works if joinchat is defined
292
+ if (!!joinchat_obj.settings && !!joinchat_obj.settings.telephone) {
293
  if (joinchat_obj.is_mobile || !joinchat_obj.settings.mobile_only) {
294
  joinchat_magic();
295
  } else {
302
  }
303
 
304
  joinchat_obj.store.setItem('joinchat_views', parseInt(joinchat_obj.store.getItem('joinchat_views') || 0) + 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  });
306
 
307
  }(jQuery, window, document));
public/js/joinchat.min.js CHANGED
@@ -1 +1 @@
1
- !function(u,d,m){"use strict";d.joinchat_obj=d.joinchat_obj||{},joinchat_obj=u.extend({$div:null,settings:null,store:null,chatbox:!1,is_mobile:!1},joinchat_obj),joinchat_obj.$=function(t){return u(t||this.$div,this.$div)},joinchat_obj.send_event=function(o,e){o=o||"",e=e||"click";var t=d[this.settings.ga_tracker]||d.ga||d.__gaTracker;"function"==typeof t&&"function"==typeof t.getAll?(t("set","transport","beacon"),t.getAll().forEach(function(t){t.send("event","JoinChat",e,o)})):"function"==typeof gtag&&gtag("event",e,{event_category:"JoinChat",event_label:o,transport_type:"beacon"}),"object"==typeof dataLayer&&dataLayer.push({event:"JoinChat",eventAction:e,eventLabel:o}),"function"==typeof fbq&&fbq("trackCustom","JoinChat",{eventAction:e,eventLabel:o})},joinchat_obj.whatsapp_link=function(t,o,e){return((e=void 0!==e?e:this.settings.whatsapp_web&&!this.is_mobile)?"https://web.whatsapp.com/send":"https://api.whatsapp.com/send")+"?phone="+encodeURIComponent(t)+"&text="+encodeURIComponent(o||"")},joinchat_obj.chatbox_show=function(){this.chatbox||(this.chatbox=!0,this.$div.addClass("joinchat--chatbox"),this.settings.message_badge&&this.$(".joinchat__badge").hasClass("joinchat__badge--in")&&this.$(".joinchat__badge").toggleClass("joinchat__badge--in joinchat__badge--out"),u(m).trigger("joinchat:show"))},joinchat_obj.chatbox_hide=function(){this.chatbox&&(this.chatbox=!1,this.$div.removeClass("joinchat--chatbox joinchat--tooltip"),this.settings.message_badge&&this.$(".joinchat__badge").removeClass("joinchat__badge--out"),u(m).trigger("joinchat:hide"))},joinchat_obj.save_hash=function(){var t=this.settings.message_hash||"none",o=(this.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean);-1===o.indexOf(t)&&(o.push(t),this.store.setItem("joinchat_hashes",o.join(",")))},joinchat_obj.open_whatsapp=function(t,o){t={link:this.whatsapp_link(t||this.settings.telephone,o||this.settings.message_send)},o=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");u(m).trigger("joinchat:open",[t,this.settings]),o.test(t.link)?(this.send_event(t.link),d.open(t.link,"joinchat","noopener")):console.error("Join.chat: the link doesn't seem safe, it must point to the current domain or whatsapp.com")},u(function(){joinchat_obj.$div=u(".joinchat"),joinchat_obj.settings=joinchat_obj.$div.data("settings"),joinchat_obj.is_mobile=!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);try{localStorage.setItem("test",1),localStorage.removeItem("test"),joinchat_obj.store=localStorage}catch(t){joinchat_obj.store={_data:{},setItem:function(t,o){this._data[t]=String(o)},getItem:function(t){return this._data.hasOwnProperty(t)?this._data[t]:null}}}if(void 0===joinchat_obj.settings)try{joinchat_obj.settings=JSON.parse(joinchat_obj.$div.attr("data-settings"))}catch(t){joinchat_obj.settings=void 0}joinchat_obj.$div.length&&joinchat_obj.settings&&joinchat_obj.settings.telephone&&(joinchat_obj.is_mobile||!joinchat_obj.settings.mobile_only?function(){u(m).trigger("joinchat:starting");var t,o,e=1e3*joinchat_obj.settings.button_delay,n=1e3*joinchat_obj.settings.message_delay,i=!!joinchat_obj.settings.message_hash,a=!!joinchat_obj.$(".joinchat__box").length,s=parseInt(joinchat_obj.store.getItem("joinchat_views")||1)>=joinchat_obj.settings.message_views,h=-1!==(joinchat_obj.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean).indexOf(joinchat_obj.settings.message_hash||"none");function c(){clearTimeout(o),joinchat_obj.chatbox_show()}function j(){joinchat_obj.save_hash(),joinchat_obj.chatbox_hide()}var _,r,b="joinchat--show";h||i&&n&&!joinchat_obj.settings.message_badge&&s||(b+=" joinchat--tooltip");setTimeout(function(){joinchat_obj.$div.addClass(b)},e),i&&!h&&n&&(joinchat_obj.settings.message_badge?o=setTimeout(function(){joinchat_obj.$(".joinchat__badge").addClass("joinchat__badge--in")},e+n):s&&(o=setTimeout(c,e+n)));a&&!joinchat_obj.is_mobile&&joinchat_obj.$(".joinchat__button").mouseenter(function(){t=setTimeout(c,1500)}).mouseleave(function(){clearTimeout(t)});{function l(){var t=(m.activeElement.type||"").toLowerCase();0<=["date","datetime","email","month","number","password","search","tel","text","textarea","time","url","week"].indexOf(t)?joinchat_obj.chatbox?(joinchat_obj.chatbox_hide(),setTimeout(function(){joinchat_obj.$div.removeClass("joinchat--show")},400)):joinchat_obj.$div.removeClass("joinchat--show"):joinchat_obj.$div.addClass("joinchat--show")}joinchat_obj.$(".joinchat__button").click(function(){a&&!joinchat_obj.chatbox?c():(j(),joinchat_obj.open_whatsapp())}),joinchat_obj.$(".joinchat__close").click(j),joinchat_obj.$(".joinchat__box__scroll").on("mousewheel DOMMouseScroll",function(t){t.preventDefault();t=t.originalEvent.wheelDelta||-t.originalEvent.detail;this.scrollTop+=30*(t<0?1:-1)}),joinchat_obj.is_mobile&&(u(m).on("focus blur","input, textarea",function(t){u(t.target).closest(joinchat_obj.$div).length||(clearTimeout(_),_=setTimeout(l,200))}),u(d).resize(function(){clearTimeout(r),r=setTimeout(function(){joinchat_obj.$div[0].style.setProperty("--vh",window.innerHeight+"px")},200)}).resize())}{var g,p;u(m).on("click",'.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]',function(t){t.preventDefault(),!a||u(this).is('.joinchat_app, a[href="#whatsapp"]')?joinchat_obj.open_whatsapp():c()}),u(m).on("click",".joinchat_close",function(t){t.preventDefault(),joinchat_obj.chatbox_hide()}),a&&"IntersectionObserver"in d&&0<(g=u(".joinchat_show, .joinchat_force_show")).length&&(p=new IntersectionObserver(function(t){u.each(t,function(){if(0<this.intersectionRatio&&(!h||u(this.target).hasClass("joinchat_force_show")))return c(),p.disconnect(),!1})}),g.each(function(){p.observe(this)}))}u(m).trigger("joinchat:start")}():u(m).on("click",'.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]',function(t){t.preventDefault(),joinchat_obj.open_whatsapp()})),joinchat_obj.store.setItem("joinchat_views",parseInt(joinchat_obj.store.getItem("joinchat_views")||0)+1)})}(jQuery,window,document);
1
+ !function(p,u,d){"use strict";function t(){p(d).trigger("joinchat:starting");var t,o,e=1e3*joinchat_obj.settings.button_delay,n=1e3*joinchat_obj.settings.message_delay,i=!!joinchat_obj.settings.message_hash,a=!!joinchat_obj.$(".joinchat__box").length,s=parseInt(joinchat_obj.store.getItem("joinchat_views")||1)>=joinchat_obj.settings.message_views,h=-1!==(joinchat_obj.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean).indexOf(joinchat_obj.settings.message_hash||"none");function c(){clearTimeout(o),joinchat_obj.chatbox_show()}function j(){joinchat_obj.save_hash(),joinchat_obj.chatbox_hide()}var _,r,b,l="joinchat--show";function g(){var t=(d.activeElement.type||"").toLowerCase();0<=["date","datetime","email","month","number","password","search","tel","text","textarea","time","url","week"].indexOf(t)?joinchat_obj.chatbox?(joinchat_obj.chatbox_hide(),setTimeout(function(){joinchat_obj.$div.removeClass("joinchat--show")},400)):joinchat_obj.$div.removeClass("joinchat--show"):joinchat_obj.$div.addClass("joinchat--show")}h||i&&n&&!joinchat_obj.settings.message_badge&&s||(l+=" joinchat--tooltip"),setTimeout(function(){joinchat_obj.$div.addClass(l)},e),i&&!h&&n&&(joinchat_obj.settings.message_badge?o=setTimeout(function(){joinchat_obj.$(".joinchat__badge").addClass("joinchat__badge--in")},e+n):s&&(o=setTimeout(c,e+n))),a&&!joinchat_obj.is_mobile&&joinchat_obj.$(".joinchat__button").on("mouseenter",function(){t=setTimeout(c,1500)}).on("mouseleave",function(){clearTimeout(t)}),joinchat_obj.$(".joinchat__button").on("click",function(){a&&!joinchat_obj.chatbox?c():(j(),joinchat_obj.open_whatsapp())}),joinchat_obj.$(".joinchat__close").on("click",j),joinchat_obj.$(".joinchat__box__scroll").on("mousewheel DOMMouseScroll",function(t){t.preventDefault();t=t.originalEvent.wheelDelta||-t.originalEvent.detail;this.scrollTop+=30*(t<0?1:-1)}),joinchat_obj.is_mobile&&(p(d).on("focus blur","input, textarea",function(t){p(t.target).closest(joinchat_obj.$div).length||(clearTimeout(_),_=setTimeout(g,200))}),p(u).on("resize",function(){clearTimeout(r),r=setTimeout(function(){joinchat_obj.$div[0].style.setProperty("--vh",window.innerHeight+"px")},200)}).trigger("resize")),p(d).on("click",'.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]',function(t){t.preventDefault(),!a||p(this).is('.joinchat_app, a[href="#whatsapp"]')?joinchat_obj.open_whatsapp():c()}),p(d).on("click",".joinchat_close",function(t){t.preventDefault(),joinchat_obj.chatbox_hide()}),a&&"IntersectionObserver"in u&&(0<(n=p(".joinchat_show, .joinchat_force_show")).length&&(b=new IntersectionObserver(function(t){p.each(t,function(){if(0<this.intersectionRatio&&(!h||p(this.target).hasClass("joinchat_force_show")))return c(),b.disconnect(),!1})}),n.each(function(){b.observe(this)}))),p(d).trigger("joinchat:start")}u.joinchat_obj=u.joinchat_obj||{},joinchat_obj=p.extend({$div:null,settings:null,store:null,chatbox:!1,is_mobile:!1},joinchat_obj),joinchat_obj.$=function(t){return p(t||this.$div,this.$div)},joinchat_obj.send_event=function(o,e){o=o||"",e=e||"click";var t=u[this.settings.ga_tracker]||u.ga||u.__gaTracker;"function"==typeof t&&"function"==typeof t.getAll?(t("set","transport","beacon"),t.getAll().forEach(function(t){t.send("event","JoinChat",e,o)})):"function"==typeof gtag&&gtag("event",e,{event_category:"JoinChat",event_label:o,transport_type:"beacon"}),"object"==typeof dataLayer&&dataLayer.push({event:"JoinChat",eventAction:e,eventLabel:o}),"function"==typeof fbq&&fbq("trackCustom","JoinChat",{eventAction:e,eventLabel:o})},joinchat_obj.whatsapp_link=function(t,o,e){return((e=void 0!==e?e:this.settings.whatsapp_web&&!this.is_mobile)?"https://web.whatsapp.com/send":"https://api.whatsapp.com/send")+"?phone="+encodeURIComponent(t)+"&text="+encodeURIComponent(o||"")},joinchat_obj.chatbox_show=function(){this.chatbox||(this.chatbox=!0,this.$div.addClass("joinchat--chatbox"),this.settings.message_badge&&this.$(".joinchat__badge").hasClass("joinchat__badge--in")&&this.$(".joinchat__badge").toggleClass("joinchat__badge--in joinchat__badge--out"),p(d).trigger("joinchat:show"))},joinchat_obj.chatbox_hide=function(){this.chatbox&&(this.chatbox=!1,this.$div.removeClass("joinchat--chatbox joinchat--tooltip"),this.settings.message_badge&&this.$(".joinchat__badge").removeClass("joinchat__badge--out"),p(d).trigger("joinchat:hide"))},joinchat_obj.save_hash=function(){var t=this.settings.message_hash||"none",o=(this.store.getItem("joinchat_hashes")||"").split(",").filter(Boolean);-1===o.indexOf(t)&&(o.push(t),this.store.setItem("joinchat_hashes",o.join(",")))},joinchat_obj.open_whatsapp=function(t,o){t={link:this.whatsapp_link(t||this.settings.telephone,o||this.settings.message_send)},o=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");p(d).trigger("joinchat:open",[t,this.settings]),o.test(t.link)?(this.send_event(t.link),u.open(t.link,"joinchat","noopener")):console.error("Join.chat: the link doesn't seem safe, it must point to the current domain or whatsapp.com")},p(function(){if(joinchat_obj.$div=p(".joinchat"),joinchat_obj.$div.length){joinchat_obj.settings=joinchat_obj.$div.data("settings"),joinchat_obj.is_mobile=!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i);try{localStorage.setItem("test",1),localStorage.removeItem("test"),joinchat_obj.store=localStorage}catch(t){joinchat_obj.store={_data:{},setItem:function(t,o){this._data[t]=String(o)},getItem:function(t){return this._data.hasOwnProperty(t)?this._data[t]:null}}}if(void 0===joinchat_obj.settings)try{joinchat_obj.settings=JSON.parse(joinchat_obj.$div.attr("data-settings"))}catch(t){joinchat_obj.settings=void 0,console.error("Join.chat: can't get settings")}joinchat_obj.settings&&joinchat_obj.settings.telephone&&(joinchat_obj.is_mobile||!joinchat_obj.settings.mobile_only?t():p(d).on("click",'.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]',function(t){t.preventDefault(),joinchat_obj.open_whatsapp()})),joinchat_obj.store.setItem("joinchat_views",parseInt(joinchat_obj.store.getItem("joinchat_views")||0)+1)}})}(jQuery,window,document);