WhatsApp Chat WP - Version 4.7.0

Version Description

Hello! We've recently acquired this plugin and included tons of new features.

Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WhatsApp Chat WP
Version 4.7.0
Comparing to
See all releases

Code changes from version 4.6.9 to 4.7.0

assets/frontend/js/qlwapp.js CHANGED
@@ -1,385 +1,399 @@
1
  (function ($, window, document, undefined) {
2
  'use strict';
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  var defaults = {};
5
 
6
  function Plugin(element, options) {
7
- this.$qlwapp = $(element);
8
- //this.settings = $.extend({}, defaults, options);
9
 
10
- this.init(this);
11
  }
12
 
13
  Plugin.prototype = {
14
- timeDateToString: function (time) {
15
- var minutes = '' + time.getMinutes();
16
- if (minutes.length === 1) {
17
- minutes = '0' + minutes;
18
- }
19
- return time.getHours() + ':' + minutes;
20
- },
21
- timeStringToInt: function (a, b) {
22
- return parseInt(a + b);
23
- },
24
- init: function (plugin) {
25
-
26
- var $qlwapp = this.$qlwapp;
27
-
28
- $qlwapp.on('qlwapp.init', function (e) {
29
- plugin.mobiledevice = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
30
- });
31
-
32
- $qlwapp.on('qlwapp.time', function (e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- var $contact = $(e.target),
35
- timefrom = $contact.data('timefrom') || false,
36
- timeto = $contact.data('timeto') || false,
37
- // timeout = $contact.data('timeout'),
38
- timezone = parseInt($contact.data('timezone')) || 0;
39
 
40
- // Don't scape timezone as could be 0
41
- if (!timeto || !timefrom || (timefrom === timeto)) {
42
- return true;
43
- }
44
 
45
- // Get offset between browser and contact timezone in minutes
46
- var timeCurrent = new Date(),
47
- n = timeCurrent.getTimezoneOffset(),
48
- timeZoneOffset = -n - timezone;
 
49
 
50
- // Convert user avaibility to browser local hour
51
- // Variables with a date are created by reference!
52
- var timeTo = new Date(),
53
- timeFrom = new Date();
54
 
55
- var hr, min;
 
 
 
 
 
 
 
 
 
56
 
57
- // Add offset timeonze to contact timefrom
58
- hr = plugin.timeStringToInt(timefrom[0], timefrom[1]);
59
- min = plugin.timeStringToInt(timefrom[3], timefrom[4]);
60
 
61
- timeFrom.setHours(hr);
62
- timeFrom.setMinutes(min + timeZoneOffset);
63
 
64
- // Add offset timezone to contact timeto
65
- hr = plugin.timeStringToInt(timeto[0], timeto[1]);
66
- min = plugin.timeStringToInt(timeto[3], timeto[4]);
67
 
68
- timeTo.setHours(hr);
69
- timeTo.setMinutes(min + timeZoneOffset);
 
70
 
71
- // Validate if browser current time is between contact times
72
- if (!(timeCurrent.getTime() >= timeFrom.getTime() && timeCurrent.getTime() <= timeTo.getTime())) {
73
- $contact.addClass('qlwapp-readonly');
74
- }
75
 
76
- if (!timezone) {
77
- return true;
78
- }
79
 
80
- $contact.find('.from').text(plugin.timeDateToString(timeFrom));
81
- $contact.find('.to').text(plugin.timeDateToString(timeTo));
82
 
83
- });
 
84
 
85
- $qlwapp.on('qlwapp.pro', function (e) {
86
 
87
- $qlwapp.find('.qlwapp-toggle').trigger('qlwapp.time');
 
88
 
89
- $qlwapp.find('.qlwapp-account').each(function (i, contact) {
90
- $(contact).trigger('qlwapp.time');
91
- });
92
- });
93
 
94
- /* // luego se veraa
95
- // Contacts time is over
96
- // -----------------------------------------------------------------------
97
- $qlwapp.on('qlwapp.pro', function (e) {
98
-
99
- var $container = $(e.delegateTarget),
100
- $box = $container.find('.qlwapp-box'),
101
- contactstimeout = $box.find('.qlwapp-footer').data('contactstimeout') || false;
102
-
103
- if ($box.length && contactstimeout) {
104
-
105
- var contacts = $qlwapp.find('.qlwapp-account').length,
106
- disabled = $qlwapp.find('.qlwapp-account.qlwapp-disabled').length,
107
- readonly = $qlwapp.find('.qlwapp-account.qlwapp-readonly').length;
108
-
109
- // reveer que pasa con el disabled del boton
110
- if (contacts === (disabled + readonly)) {
111
- if (contactstimeout === 'yes') {
112
- $qlwapp.addClass('qlwapp-readonly');
113
- }
114
- // else {
115
- // $qlwapp.removeClass('qlwapp-js-ready');
116
- // }
117
-
118
- }
119
- }
120
- });
121
- */
122
-
123
- $qlwapp.on('qlwapp.resize', function (e) {
124
- if ($(this).hasClass('qlwapp-show')) {
125
- $(this).trigger('qlwapp.toggle');
126
- }
127
- });
128
 
129
- $qlwapp.on('qlwapp.init', function (e) {
 
 
130
 
131
- if (!plugin.mobiledevice) {
132
- $qlwapp.addClass('desktop').removeClass('mobile');
133
- } else {
134
- $qlwapp.addClass('mobile').removeClass('desktop');
135
- }
136
 
137
- $qlwapp.addClass('qlwapp-js-ready');
138
- });
139
 
140
- // is Premium!
141
- // -----------------------------------------------------------------------
142
- $qlwapp.on('qlwapp.init', function (e) {
143
- if ($qlwapp.hasClass('qlwapp-premium')) {
144
- $qlwapp.trigger('qlwapp.pro');
145
- }
146
- });
147
- // Ready!
148
- // -----------------------------------------------------------------------
149
- $qlwapp.addClass('qlwapp-js-ready').trigger('qlwapp.init');
150
 
151
- // Height
152
- // -----------------------------------------------------------------------
153
 
154
- $qlwapp.on('qlwapp.height', function (e) {
155
 
156
- var $container = $(e.delegateTarget),
157
- $body = $container.find('.qlwapp-body'),
158
- $carousel = $body.find('.qlwapp-carousel');
159
 
160
- var $header = $container.find('.qlwapp-header'),
161
- $footer = $container.find('.qlwapp-footer'),
162
- height = ($(window).innerHeight() - $header.outerHeight() - $footer.outerHeight());
163
 
164
- if (!plugin.mobiledevice) {
165
- height = ($(window).innerHeight() * 0.7 - $header.outerHeight() - $footer.outerHeight());
166
- }
167
 
168
- $carousel.css({'max-height': height + 'px'});
169
 
170
- });
 
 
171
 
172
- // Toggle
173
- // -----------------------------------------------------------------------
 
174
 
175
- $qlwapp.on('qlwapp.toggle', function (e) {
176
 
177
- var $container = $(e.delegateTarget),
178
- $box = $container.find('.qlwapp-box');
179
 
180
- $container.addClass('qlwapp-transition');
 
181
 
182
- $box.removeClass('response texting');
 
183
 
184
- setTimeout(function () {
185
- $container.toggleClass('qlwapp-show').trigger('qlwapp.height');
186
- }, 10);
187
 
188
- setTimeout(function () {
189
- $container.toggleClass('qlwapp-transition');
190
- }, 300);
191
 
192
- });
 
 
 
 
193
 
194
- // Click
195
- // -----------------------------------------------------------------------
196
 
197
- $qlwapp.on('click', '[data-action=box], [data-action=close]', function (e) {
198
- e.preventDefault();
199
 
200
- $(e.delegateTarget).trigger('qlwapp.toggle');
 
 
 
 
 
 
 
 
 
201
 
202
- });
203
 
204
- // Whatsapp
205
- // -----------------------------------------------------------------------
206
 
207
- $qlwapp.on('click', '[data-action=open]', function (e) {
 
 
208
 
209
- var url = 'https://api.whatsapp.com/send';
 
 
 
 
 
 
210
 
211
- if (!plugin.mobiledevice) {
212
- url = 'https://web.whatsapp.com/send';
213
- }
214
 
215
- var $button = $(this),
216
- message = $button.data('message') || '',
217
- phone = $button.data('phone') || '';
 
 
 
 
218
 
219
- $(this).attr('href', url + '?phone=' + phone + '&text=' + message);
220
 
221
- });
 
222
 
223
- // Response
224
- // -----------------------------------------------------------------------
 
225
 
226
- $qlwapp.on('click', '[data-action=previous]', function (e) {
227
- e.preventDefault();
 
228
 
229
- var $container = $(e.delegateTarget),
230
- $box = $container.find('.qlwapp-box');//,
231
- //$user = $box.find('.qlwapp-user');
 
 
232
 
233
- $box.addClass('closing');
 
234
 
235
- setTimeout(function () {
236
- $box.removeClass('response').removeClass('closing');
237
- $box.removeClass('texting')
238
- //$user.empty();
239
- }, 300);
 
 
240
 
241
- });
242
 
243
- $qlwapp.on('click', '[data-action=chat]', function (e) {
244
- e.preventDefault();
245
-
246
- var $contact = $(this),
247
- $container = $(e.delegateTarget),
248
- $box = $container.find('.qlwapp-box'),
249
- avatar = $contact.find('.qlwapp-avatar img').attr('src'),
250
- name = $contact.find('.qlwapp-name').text(),
251
- label = $contact.find('.qlwapp-label').text(),
252
- time = $contact.find('.qlwapp-time').text(),
253
- //url = $contact.data('url'),
254
- message = $contact.data('message'),
255
- phone = $contact.data('phone');
256
-
257
- $box.addClass('response').addClass('opening');
258
-
259
- $container.trigger('qlwapp.height');
260
-
261
- setTimeout(function () {
262
- $box.removeClass('opening');
263
- }, 300);
264
-
265
- var $reply = $box.find('.qlwapp-reply'),
266
- $header = $box.find('.qlwapp-header'),
267
- $avatar = $header.find('.qlwapp-avatar img'),
268
- $number = $header.find('.qlwapp-number'),
269
- $name = $header.find('.qlwapp-name'),
270
- $label = $header.find('.qlwapp-label'),
271
- $message = $box.find('.qlwapp-message');
272
-
273
- var meta = time ? time + ' - ' + label : label;
274
-
275
- $reply.data('phone', phone);//.data('message', message);
276
- $avatar.attr('src', avatar);
277
- $avatar.attr('alt', name);
278
- $number.html(phone);
279
- $name.html(name);
280
- $label.html(meta);
281
- $message.html(message);
282
 
283
- });
 
 
 
284
 
285
- // Response
286
- // -----------------------------------------------------------------------
287
-
288
- $qlwapp.on('click', 'textarea', function (e) {
289
- $qlwapp.off('qlwapp.resize');
290
- });
291
-
292
- $qlwapp.on('keypress', 'textarea', function (e) {
293
- if (e.keyCode == 13) {
294
- $qlwapp.find('.qlwapp-reply').trigger('click');
295
- setTimeout(function () {
296
- window.location = $qlwapp.find('.qlwapp-reply').attr('href');
297
- }, 100);
298
- }
299
- });
300
-
301
- $qlwapp.on('keyup', '[data-action=response]', function (e) {
302
- e.preventDefault();
303
-
304
- var $textarea = $(this).find('textarea'),
305
- $pre = $(this).find('pre'),
306
- $reply = $(this).find('.qlwapp-reply'),
307
- $container = $(e.delegateTarget),
308
- $box = $container.find('.qlwapp-box'),
309
- //$user = $box.find('.qlwapp-user'),
310
- $buttons = $box.find('.qlwapp-buttons');
311
-
312
- $pre.html($textarea.val());
313
-
314
- setTimeout(function () {
315
- $box.addClass('texting').css({'padding-bottom': $pre.outerHeight()});
316
- $buttons.addClass('active');
317
- var message = $textarea.val();
318
- $reply.data('message', message);
319
-
320
- if (message == '') {
321
- $box.removeClass('texting');
322
- $buttons.removeClass('active');
323
- }
324
-
325
- }, 300);
326
-
327
- });
328
-
329
- //$qlwapp.trigger('qlwapp.init');
330
- }
331
  };
332
 
333
  $.fn.qlwapp = function (options) {
334
 
335
- var args = arguments;
336
-
337
- if (options === undefined || typeof options === 'object') {
338
- return this.each(function () {
339
- if (!$.data(this, 'plugin_qlwapp')) {
340
- $.data(this, 'plugin_qlwapp', new Plugin(this, options));
341
- }
342
- });
343
- } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
344
- // Cache the method call to make it possible to return a value
345
- var returns;
346
- this.each(function () {
347
- var instance = $.data(this, 'plugin_qlwapp');
348
- // Tests that there's already a plugin-instance and checks that the requested public method exists
349
- if (instance instanceof Plugin && typeof instance[options] === 'function') {
350
- // Call the method of our plugin instance, and pass it the supplied arguments.
351
- returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
352
- }
353
- // Allow instances to be destroyed via the 'destroy' method
354
- if (options === 'destroy') {
355
- $.data(this, 'plugin_qlwapp', null);
356
- }
357
- });
358
- // If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability.
359
- return returns !== undefined ? returns : this;
360
- }
361
  }
362
 
363
  function qlwapp_init() {
364
- $('div#qlwapp').qlwapp();
365
  }
366
 
367
  qlwapp_init();
368
 
369
  $(window).on('load', function () {
370
- qlwapp_init();
371
- //$('div#qlwapp').trigger('qlwapp.toggle');
372
  });
373
 
374
  $(window).on('click', function (e) {
375
- if (!$(e.target).closest('#qlwapp.qlwapp-show').length) {
376
- $('div#qlwapp.qlwapp-show').trigger('qlwapp.toggle');
377
- }
378
  });
379
 
380
  $(window).on('resize', function (e) {
381
- $('div#qlwapp').trigger('qlwapp.resize');
382
- $('div#qlwapp').trigger('qlwapp.init');
383
  });
384
 
385
  })(jQuery, window, document);
1
  (function ($, window, document, undefined) {
2
  'use strict';
3
 
4
+ $.fn.simulateClick = function () {
5
+ return this.each(function () {
6
+ if ('createEvent' in document) {
7
+ var doc = this.ownerDocument,
8
+ evt = doc.createEvent('MouseEvents');
9
+ evt.initMouseEvent('click', true, true, doc.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
10
+ this.dispatchEvent(evt);
11
+ } else {
12
+ this.click(); // IE Boss!
13
+ }
14
+ });
15
+ }
16
+
17
  var defaults = {};
18
 
19
  function Plugin(element, options) {
20
+ this.$qlwapp = $(element);
21
+ //this.settings = $.extend({}, defaults, options);
22
 
23
+ this.init(this);
24
  }
25
 
26
  Plugin.prototype = {
27
+ timeDateToString: function (time) {
28
+ var minutes = '' + time.getMinutes();
29
+ if (minutes.length === 1) {
30
+ minutes = '0' + minutes;
31
+ }
32
+ return time.getHours() + ':' + minutes;
33
+ },
34
+ timeStringToInt: function (a, b) {
35
+ return parseInt(a + b);
36
+ },
37
+ init: function (plugin) {
38
+
39
+ var $qlwapp = this.$qlwapp;
40
+
41
+ $qlwapp.on('qlwapp.init', function (e) {
42
+ plugin.mobiledevice = (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
43
+ });
44
+
45
+ $qlwapp.on('qlwapp.time', function (e) {
46
+
47
+ var $contact = $(e.target),
48
+ timefrom = $contact.data('timefrom') || false,
49
+ timeto = $contact.data('timeto') || false,
50
+ // timeout = $contact.data('timeout'),
51
+ timezone = parseInt($contact.data('timezone')) || 0;
52
+
53
+ // Don't scape timezone as could be 0
54
+ if (!timeto || !timefrom || (timefrom === timeto)) {
55
+ return true;
56
+ }
57
+
58
+ // Get offset between browser and contact timezone in minutes
59
+ var timeCurrent = new Date(),
60
+ n = timeCurrent.getTimezoneOffset(),
61
+ timeZoneOffset = -n - timezone;
62
+
63
+ // Convert user avaibility to browser local hour
64
+ // Variables with a date are created by reference!
65
+ var timeTo = new Date(),
66
+ timeFrom = new Date();
67
+
68
+ var hr, min;
69
+
70
+ // Add offset timeonze to contact timefrom
71
+ hr = plugin.timeStringToInt(timefrom[0], timefrom[1]);
72
+ min = plugin.timeStringToInt(timefrom[3], timefrom[4]);
73
+
74
+ timeFrom.setHours(hr);
75
+ timeFrom.setMinutes(min + timeZoneOffset);
76
+
77
+ // Add offset timezone to contact timeto
78
+ hr = plugin.timeStringToInt(timeto[0], timeto[1]);
79
+ min = plugin.timeStringToInt(timeto[3], timeto[4]);
80
+
81
+ timeTo.setHours(hr);
82
+ timeTo.setMinutes(min + timeZoneOffset);
83
+
84
+ // Validate if browser current time is between contact times
85
+ if (!(timeCurrent.getTime() >= timeFrom.getTime() && timeCurrent.getTime() <= timeTo.getTime())) {
86
+ $contact.addClass('qlwapp-readonly');
87
+ }
88
+
89
+ if (!timezone) {
90
+ return true;
91
+ }
92
+
93
+ $contact.find('.from').text(plugin.timeDateToString(timeFrom));
94
+ $contact.find('.to').text(plugin.timeDateToString(timeTo));
95
+
96
+ });
97
+
98
+ $qlwapp.on('qlwapp.pro', function (e) {
99
+
100
+ $qlwapp.find('.qlwapp-toggle').trigger('qlwapp.time');
101
+
102
+ $qlwapp.find('.qlwapp-account').each(function (i, contact) {
103
+ $(contact).trigger('qlwapp.time');
104
+ });
105
+ });
106
+
107
+ /* // luego se veraa
108
+ // Contacts time is over
109
+ // -----------------------------------------------------------------------
110
+ $qlwapp.on('qlwapp.pro', function (e) {
111
+
112
+ var $container = $(e.delegateTarget),
113
+ $box = $container.find('.qlwapp-box'),
114
+ contactstimeout = $box.find('.qlwapp-footer').data('contactstimeout') || false;
115
+
116
+ if ($box.length && contactstimeout) {
117
+
118
+ var contacts = $qlwapp.find('.qlwapp-account').length,
119
+ disabled = $qlwapp.find('.qlwapp-account.qlwapp-disabled').length,
120
+ readonly = $qlwapp.find('.qlwapp-account.qlwapp-readonly').length;
121
+
122
+ // reveer que pasa con el disabled del boton
123
+ if (contacts === (disabled + readonly)) {
124
+ if (contactstimeout === 'yes') {
125
+ $qlwapp.addClass('qlwapp-readonly');
126
+ }
127
+ // else {
128
+ // $qlwapp.removeClass('qlwapp-js-ready');
129
+ // }
130
+
131
+ }
132
+ }
133
+ });
134
+ */
135
 
136
+ $qlwapp.on('qlwapp.resize', function (e) {
137
+ if ($(this).hasClass('qlwapp-show')) {
138
+ $(this).trigger('qlwapp.toggle');
139
+ }
140
+ });
141
 
142
+ $qlwapp.on('qlwapp.init', function (e) {
 
 
 
143
 
144
+ if (!plugin.mobiledevice) {
145
+ $qlwapp.addClass('desktop').removeClass('mobile');
146
+ } else {
147
+ $qlwapp.addClass('mobile').removeClass('desktop');
148
+ }
149
 
150
+ $qlwapp.addClass('qlwapp-js-ready');
151
+ });
 
 
152
 
153
+ // is Premium!
154
+ // -----------------------------------------------------------------------
155
+ $qlwapp.on('qlwapp.init', function (e) {
156
+ if ($qlwapp.hasClass('qlwapp-premium')) {
157
+ $qlwapp.trigger('qlwapp.pro');
158
+ }
159
+ });
160
+ // Ready!
161
+ // -----------------------------------------------------------------------
162
+ $qlwapp.addClass('qlwapp-js-ready').trigger('qlwapp.init');
163
 
164
+ // Height
165
+ // -----------------------------------------------------------------------
 
166
 
167
+ $qlwapp.on('qlwapp.height', function (e) {
 
168
 
169
+ var $container = $(e.delegateTarget),
170
+ $body = $container.find('.qlwapp-body'),
171
+ $carousel = $body.find('.qlwapp-carousel');
172
 
173
+ var $header = $container.find('.qlwapp-header'),
174
+ $footer = $container.find('.qlwapp-footer'),
175
+ height = ($(window).innerHeight() - $header.outerHeight() - $footer.outerHeight());
176
 
177
+ if (!plugin.mobiledevice) {
178
+ height = ($(window).innerHeight() * 0.7 - $header.outerHeight() - $footer.outerHeight());
179
+ }
 
180
 
181
+ $carousel.css({ 'max-height': height + 'px' });
 
 
182
 
183
+ });
 
184
 
185
+ // Toggle
186
+ // -----------------------------------------------------------------------
187
 
188
+ $qlwapp.on('qlwapp.toggle', function (e) {
189
 
190
+ var $container = $(e.delegateTarget),
191
+ $box = $container.find('.qlwapp-box');
192
 
193
+ $container.addClass('qlwapp-transition');
 
 
 
194
 
195
+ $box.removeClass('response texting');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ setTimeout(function () {
198
+ $container.toggleClass('qlwapp-show').trigger('qlwapp.height');
199
+ }, 10);
200
 
201
+ setTimeout(function () {
202
+ $container.toggleClass('qlwapp-transition');
203
+ }, 300);
 
 
204
 
205
+ });
 
206
 
207
+ // Click
208
+ // -----------------------------------------------------------------------
 
 
 
 
 
 
 
 
209
 
210
+ $qlwapp.on('click', '[data-action=box], [data-action=close]', function (e) {
211
+ e.preventDefault();
212
 
213
+ $(e.delegateTarget).trigger('qlwapp.toggle');
214
 
215
+ });
 
 
216
 
217
+ // Whatsapp
218
+ // -----------------------------------------------------------------------
 
219
 
220
+ $qlwapp.on('click', '[data-action=open]', function (e) {
 
 
221
 
222
+ var url = 'https://api.whatsapp.com/send';
223
 
224
+ if (!plugin.mobiledevice) {
225
+ url = 'https://web.whatsapp.com/send';
226
+ }
227
 
228
+ var $button = $(this),
229
+ message = $button.data('message') || '',
230
+ phone = $button.data('phone') || '';
231
 
232
+ $(this).attr('href', url + '?phone=' + phone + '&text=' + message);
233
 
234
+ });
 
235
 
236
+ // Response
237
+ // -----------------------------------------------------------------------
238
 
239
+ $qlwapp.on('click', '[data-action=previous]', function (e) {
240
+ e.preventDefault();
241
 
242
+ var $container = $(e.delegateTarget),
243
+ $box = $container.find('.qlwapp-box');//,
244
+ //$user = $box.find('.qlwapp-user');
245
 
246
+ $box.addClass('closing');
 
 
247
 
248
+ setTimeout(function () {
249
+ $box.removeClass('response').removeClass('closing');
250
+ $box.removeClass('texting')
251
+ //$user.empty();
252
+ }, 300);
253
 
254
+ });
 
255
 
256
+ $qlwapp.on('click', '[data-action=chat]', function (e) {
257
+ e.preventDefault();
258
 
259
+ var $contact = $(this),
260
+ $container = $(e.delegateTarget),
261
+ $box = $container.find('.qlwapp-box'),
262
+ avatar = $contact.find('.qlwapp-avatar img').attr('src'),
263
+ name = $contact.find('.qlwapp-name').text(),
264
+ label = $contact.find('.qlwapp-label').text(),
265
+ time = $contact.find('.qlwapp-time').text(),
266
+ //url = $contact.data('url'),
267
+ message = $contact.data('message'),
268
+ phone = $contact.data('phone');
269
 
270
+ $box.addClass('response').addClass('opening');
271
 
272
+ $container.trigger('qlwapp.height');
 
273
 
274
+ setTimeout(function () {
275
+ $box.removeClass('opening');
276
+ }, 300);
277
 
278
+ var $reply = $box.find('.qlwapp-reply'),
279
+ $header = $box.find('.qlwapp-header'),
280
+ $avatar = $header.find('.qlwapp-avatar img'),
281
+ $number = $header.find('.qlwapp-number'),
282
+ $name = $header.find('.qlwapp-name'),
283
+ $label = $header.find('.qlwapp-label'),
284
+ $message = $box.find('.qlwapp-message');
285
 
286
+ var meta = time ? time + ' - ' + label : label;
 
 
287
 
288
+ $reply.data('phone', phone);//.data('message', message);
289
+ $avatar.attr('src', avatar);
290
+ $avatar.attr('alt', name);
291
+ $number.html(phone);
292
+ $name.html(name);
293
+ $label.html(meta);
294
+ $message.html(message);
295
 
296
+ });
297
 
298
+ // Response
299
+ // -----------------------------------------------------------------------
300
 
301
+ $qlwapp.on('click', 'textarea', function (e) {
302
+ $qlwapp.off('qlwapp.resize');
303
+ });
304
 
305
+ $qlwapp.on('keypress', 'textarea', function (e) {
306
+ if (e.keyCode == 13) {
307
+ setTimeout(function () {
308
 
309
+ $qlwapp.find('.qlwapp-reply').simulateClick('click');
310
+ //window.location = $qlwapp.find('.qlwapp-reply').attr('href');
311
+ }, 100);
312
+ }
313
+ });
314
 
315
+ $qlwapp.on('keyup', '[data-action=response]', function (e) {
316
+ e.preventDefault();
317
 
318
+ var $textarea = $(this).find('textarea'),
319
+ $pre = $(this).find('pre'),
320
+ $reply = $(this).find('.qlwapp-reply'),
321
+ $container = $(e.delegateTarget),
322
+ $box = $container.find('.qlwapp-box'),
323
+ //$user = $box.find('.qlwapp-user'),
324
+ $buttons = $box.find('.qlwapp-buttons');
325
 
326
+ $pre.html($textarea.val());
327
 
328
+ setTimeout(function () {
329
+ $box.addClass('texting').css({ 'padding-bottom': $pre.outerHeight() });
330
+ $buttons.addClass('active');
331
+ var message = $textarea.val();
332
+ $reply.data('message', message);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
 
334
+ if (message == '') {
335
+ $box.removeClass('texting');
336
+ $buttons.removeClass('active');
337
+ }
338
 
339
+ }, 300);
340
+
341
+ });
342
+
343
+ //$qlwapp.trigger('qlwapp.init');
344
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  };
346
 
347
  $.fn.qlwapp = function (options) {
348
 
349
+ var args = arguments;
350
+
351
+ if (options === undefined || typeof options === 'object') {
352
+ return this.each(function () {
353
+ if (!$.data(this, 'plugin_qlwapp')) {
354
+ $.data(this, 'plugin_qlwapp', new Plugin(this, options));
355
+ }
356
+ });
357
+ } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
358
+ // Cache the method call to make it possible to return a value
359
+ var returns;
360
+ this.each(function () {
361
+ var instance = $.data(this, 'plugin_qlwapp');
362
+ // Tests that there's already a plugin-instance and checks that the requested public method exists
363
+ if (instance instanceof Plugin && typeof instance[options] === 'function') {
364
+ // Call the method of our plugin instance, and pass it the supplied arguments.
365
+ returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
366
+ }
367
+ // Allow instances to be destroyed via the 'destroy' method
368
+ if (options === 'destroy') {
369
+ $.data(this, 'plugin_qlwapp', null);
370
+ }
371
+ });
372
+ // If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability.
373
+ return returns !== undefined ? returns : this;
374
+ }
375
  }
376
 
377
  function qlwapp_init() {
378
+ $('div#qlwapp').qlwapp();
379
  }
380
 
381
  qlwapp_init();
382
 
383
  $(window).on('load', function () {
384
+ qlwapp_init();
385
+ //$('div#qlwapp').trigger('qlwapp.toggle');
386
  });
387
 
388
  $(window).on('click', function (e) {
389
+ if (!$(e.target).closest('#qlwapp.qlwapp-show').length) {
390
+ $('div#qlwapp.qlwapp-show').trigger('qlwapp.toggle');
391
+ }
392
  });
393
 
394
  $(window).on('resize', function (e) {
395
+ $('div#qlwapp').trigger('qlwapp.resize');
396
+ $('div#qlwapp').trigger('qlwapp.init');
397
  });
398
 
399
  })(jQuery, window, document);
assets/frontend/js/qlwapp.min.js CHANGED
@@ -1,2 +1 @@
1
-
2
- (function(d,c,a,g){var e={};function b(i,h){this.$qlwapp=d(i);this.init(this)}b.prototype={timeDateToString:function(i){var h=""+i.getMinutes();if(h.length===1){h="0"+h}return i.getHours()+":"+h},timeStringToInt:function(i,h){return parseInt(i+h)},init:function(i){var h=this.$qlwapp;h.on("qlwapp.init",function(j){i.mobiledevice=(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))});h.on("qlwapp.time",function(p){var j=d(p.target),r=j.data("timefrom")||false,s=j.data("timeto")||false,o=parseInt(j.data("timezone"))||0;if(!s||!r||(r===s)){return true}var v=new Date(),l=v.getTimezoneOffset(),q=-l-o;var u=new Date(),k=new Date();var t,m;t=i.timeStringToInt(r[0],r[1]);m=i.timeStringToInt(r[3],r[4]);k.setHours(t);k.setMinutes(m+q);t=i.timeStringToInt(s[0],s[1]);m=i.timeStringToInt(s[3],s[4]);u.setHours(t);u.setMinutes(m+q);if(!(v.getTime()>=k.getTime()&&v.getTime()<=u.getTime())){j.addClass("qlwapp-readonly")}if(!o){return true}j.find(".from").text(i.timeDateToString(k));j.find(".to").text(i.timeDateToString(u))});h.on("qlwapp.pro",function(j){h.find(".qlwapp-toggle").trigger("qlwapp.time");h.find(".qlwapp-account").each(function(l,k){d(k).trigger("qlwapp.time")})});h.on("qlwapp.resize",function(j){if(d(this).hasClass("qlwapp-show")){d(this).trigger("qlwapp.toggle")}});h.on("qlwapp.init",function(j){if(!i.mobiledevice){h.addClass("desktop").removeClass("mobile")}else{h.addClass("mobile").removeClass("desktop")}h.addClass("qlwapp-js-ready")});h.on("qlwapp.init",function(j){if(h.hasClass("qlwapp-premium")){h.trigger("qlwapp.pro")}});h.addClass("qlwapp-js-ready").trigger("qlwapp.init");h.on("qlwapp.height",function(o){var p=d(o.delegateTarget),n=p.find(".qlwapp-body"),m=n.find(".qlwapp-carousel");var l=p.find(".qlwapp-header"),k=p.find(".qlwapp-footer"),j=(d(c).innerHeight()-l.outerHeight()-k.outerHeight());if(!i.mobiledevice){j=(d(c).innerHeight()*0.7-l.outerHeight()-k.outerHeight())}m.css({"max-height":j+"px"})});h.on("qlwapp.toggle",function(k){var l=d(k.delegateTarget),j=l.find(".qlwapp-box");l.addClass("qlwapp-transition");j.removeClass("response texting");setTimeout(function(){l.toggleClass("qlwapp-show").trigger("qlwapp.height")},10);setTimeout(function(){l.toggleClass("qlwapp-transition")},300)});h.on("click","[data-action=box], [data-action=close]",function(j){j.preventDefault();d(j.delegateTarget).trigger("qlwapp.toggle")});h.on("click","[data-action=open]",function(n){var k="https://api.whatsapp.com/send";if(!i.mobiledevice){k="https://web.whatsapp.com/send"}var m=d(this),l=m.data("message")||"",j=m.data("phone")||"";d(this).attr("href",k+"?phone="+j+"&text="+l)});h.on("click","[data-action=previous]",function(k){k.preventDefault();var l=d(k.delegateTarget),j=l.find(".qlwapp-box");j.addClass("closing");setTimeout(function(){j.removeClass("response").removeClass("closing");j.removeClass("texting")},300)});h.on("click","[data-action=chat]",function(w){w.preventDefault();var n=d(this),t=d(w.delegateTarget),u=t.find(".qlwapp-box"),v=n.find(".qlwapp-avatar img").attr("src"),A=n.find(".qlwapp-name").text(),q=n.find(".qlwapp-label").text(),p=n.find(".qlwapp-time").text(),r=n.data("message"),o=n.data("phone");u.addClass("response").addClass("opening");t.trigger("qlwapp.height");setTimeout(function(){u.removeClass("opening")},300);var k=u.find(".qlwapp-reply"),x=u.find(".qlwapp-header"),j=x.find(".qlwapp-avatar img"),m=x.find(".qlwapp-number"),l=x.find(".qlwapp-name"),z=x.find(".qlwapp-label"),y=u.find(".qlwapp-message");var s=p?p+" - "+q:q;k.data("phone",o);j.attr("src",v);j.attr("alt",A);m.html(o);l.html(A);z.html(s);y.html(r)});h.on("click","textarea",function(j){h.off("qlwapp.resize")});h.on("keypress","textarea",function(j){if(j.keyCode==13){h.find(".qlwapp-reply").trigger("click");setTimeout(function(){c.location=h.find(".qlwapp-reply").attr("href")},100)}});h.on("keyup","[data-action=response]",function(m){m.preventDefault();var p=d(this).find("textarea"),o=d(this).find("pre"),j=d(this).find(".qlwapp-reply"),n=d(m.delegateTarget),l=n.find(".qlwapp-box"),k=l.find(".qlwapp-buttons");o.html(p.val());setTimeout(function(){l.addClass("texting").css({"padding-bottom":o.outerHeight()});k.addClass("active");var q=p.val();j.data("message",q);if(q==""){l.removeClass("texting");k.removeClass("active")}},300)})}};d.fn.qlwapp=function(i){var h=arguments;if(i===g||typeof i==="object"){return this.each(function(){if(!d.data(this,"plugin_qlwapp")){d.data(this,"plugin_qlwapp",new b(this,i))}})}else{if(typeof i==="string"&&i[0]!=="_"&&i!=="init"){var j;this.each(function(){var k=d.data(this,"plugin_qlwapp");if(k instanceof b&&typeof k[i]==="function"){j=k[i].apply(k,Array.prototype.slice.call(h,1))}if(i==="destroy"){d.data(this,"plugin_qlwapp",null)}});return j!==g?j:this}}};function f(){d("div#qlwapp").qlwapp()}f();d(c).on("load",function(){f()});d(c).on("click",function(h){if(!d(h.target).closest("#qlwapp.qlwapp-show").length){d("div#qlwapp.qlwapp-show").trigger("qlwapp.toggle")}});d(c).on("resize",function(h){d("div#qlwapp").trigger("qlwapp.resize");d("div#qlwapp").trigger("qlwapp.init")})})(jQuery,window,document);
1
+ !function($,window,document,undefined){"use strict";function Plugin(element,options){this.$qlwapp=$(element),this.init(this)}function qlwapp_init(){$("div#qlwapp").qlwapp()}$.fn.simulateClick=function(){return this.each((function(){if("createEvent"in document){var doc=this.ownerDocument,evt=doc.createEvent("MouseEvents");evt.initMouseEvent("click",!0,!0,doc.defaultView,1,0,0,0,0,!1,!1,!1,!1,0,null),this.dispatchEvent(evt)}else this.click()}))},Plugin.prototype={timeDateToString:function(time){var minutes=""+time.getMinutes();return 1===minutes.length&&(minutes="0"+minutes),time.getHours()+":"+minutes},timeStringToInt:function(a,b){return parseInt(a+b)},init:function(plugin){var $qlwapp=this.$qlwapp;$qlwapp.on("qlwapp.init",(function(e){plugin.mobiledevice=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)})),$qlwapp.on("qlwapp.time",(function(e){var $contact=$(e.target),timefrom=$contact.data("timefrom")||!1,timeto=$contact.data("timeto")||!1,timezone=parseInt($contact.data("timezone"))||0;if(!timeto||!timefrom||timefrom===timeto)return!0;var timeCurrent=new Date,n,timeZoneOffset=-timeCurrent.getTimezoneOffset()-timezone,timeTo=new Date,timeFrom=new Date,hr,min;if(hr=plugin.timeStringToInt(timefrom[0],timefrom[1]),min=plugin.timeStringToInt(timefrom[3],timefrom[4]),timeFrom.setHours(hr),timeFrom.setMinutes(min+timeZoneOffset),hr=plugin.timeStringToInt(timeto[0],timeto[1]),min=plugin.timeStringToInt(timeto[3],timeto[4]),timeTo.setHours(hr),timeTo.setMinutes(min+timeZoneOffset),timeCurrent.getTime()>=timeFrom.getTime()&&timeCurrent.getTime()<=timeTo.getTime()||$contact.addClass("qlwapp-readonly"),!timezone)return!0;$contact.find(".from").text(plugin.timeDateToString(timeFrom)),$contact.find(".to").text(plugin.timeDateToString(timeTo))})),$qlwapp.on("qlwapp.pro",(function(e){$qlwapp.find(".qlwapp-toggle").trigger("qlwapp.time"),$qlwapp.find(".qlwapp-account").each((function(i,contact){$(contact).trigger("qlwapp.time")}))})),$qlwapp.on("qlwapp.resize",(function(e){$(this).hasClass("qlwapp-show")&&$(this).trigger("qlwapp.toggle")})),$qlwapp.on("qlwapp.init",(function(e){plugin.mobiledevice?$qlwapp.addClass("mobile").removeClass("desktop"):$qlwapp.addClass("desktop").removeClass("mobile"),$qlwapp.addClass("qlwapp-js-ready")})),$qlwapp.on("qlwapp.init",(function(e){$qlwapp.hasClass("qlwapp-premium")&&$qlwapp.trigger("qlwapp.pro")})),$qlwapp.addClass("qlwapp-js-ready").trigger("qlwapp.init"),$qlwapp.on("qlwapp.height",(function(e){var $container=$(e.delegateTarget),$body,$carousel=$container.find(".qlwapp-body").find(".qlwapp-carousel"),$header=$container.find(".qlwapp-header"),$footer=$container.find(".qlwapp-footer"),height=$(window).innerHeight()-$header.outerHeight()-$footer.outerHeight();plugin.mobiledevice||(height=.7*$(window).innerHeight()-$header.outerHeight()-$footer.outerHeight()),$carousel.css({"max-height":height+"px"})})),$qlwapp.on("qlwapp.toggle",(function(e){var $container=$(e.delegateTarget),$box=$container.find(".qlwapp-box");$container.addClass("qlwapp-transition"),$box.removeClass("response texting"),setTimeout((function(){$container.toggleClass("qlwapp-show").trigger("qlwapp.height")}),10),setTimeout((function(){$container.toggleClass("qlwapp-transition")}),300)})),$qlwapp.on("click","[data-action=box], [data-action=close]",(function(e){e.preventDefault(),$(e.delegateTarget).trigger("qlwapp.toggle")})),$qlwapp.on("click","[data-action=open]",(function(e){var url="https://api.whatsapp.com/send";plugin.mobiledevice||(url="https://web.whatsapp.com/send");var $button=$(this),message=$button.data("message")||"",phone=$button.data("phone")||"";$(this).attr("href",url+"?phone="+phone+"&text="+message)})),$qlwapp.on("click","[data-action=previous]",(function(e){e.preventDefault();var $container,$box=$(e.delegateTarget).find(".qlwapp-box");$box.addClass("closing"),setTimeout((function(){$box.removeClass("response").removeClass("closing"),$box.removeClass("texting")}),300)})),$qlwapp.on("click","[data-action=chat]",(function(e){e.preventDefault();var $contact=$(this),$container=$(e.delegateTarget),$box=$container.find(".qlwapp-box"),avatar=$contact.find(".qlwapp-avatar img").attr("src"),name=$contact.find(".qlwapp-name").text(),label=$contact.find(".qlwapp-label").text(),time=$contact.find(".qlwapp-time").text(),message=$contact.data("message"),phone=$contact.data("phone");$box.addClass("response").addClass("opening"),$container.trigger("qlwapp.height"),setTimeout((function(){$box.removeClass("opening")}),300);var $reply=$box.find(".qlwapp-reply"),$header=$box.find(".qlwapp-header"),$avatar=$header.find(".qlwapp-avatar img"),$number=$header.find(".qlwapp-number"),$name=$header.find(".qlwapp-name"),$label=$header.find(".qlwapp-label"),$message=$box.find(".qlwapp-message"),meta=time?time+" - "+label:label;$reply.data("phone",phone),$avatar.attr("src",avatar),$avatar.attr("alt",name),$number.html(phone),$name.html(name),$label.html(meta),$message.html(message)})),$qlwapp.on("click","textarea",(function(e){$qlwapp.off("qlwapp.resize")})),$qlwapp.on("keypress","textarea",(function(e){13==e.keyCode&&setTimeout((function(){$qlwapp.find(".qlwapp-reply").simulateClick("click")}),100)})),$qlwapp.on("keyup","[data-action=response]",(function(e){e.preventDefault();var $textarea=$(this).find("textarea"),$pre=$(this).find("pre"),$reply=$(this).find(".qlwapp-reply"),$container,$box=$(e.delegateTarget).find(".qlwapp-box"),$buttons=$box.find(".qlwapp-buttons");$pre.html($textarea.val()),setTimeout((function(){$box.addClass("texting").css({"padding-bottom":$pre.outerHeight()}),$buttons.addClass("active");var message=$textarea.val();$reply.data("message",message),""==message&&($box.removeClass("texting"),$buttons.removeClass("active"))}),300)}))}},$.fn.qlwapp=function(options){var args=arguments,returns;return void 0===options||"object"==typeof options?this.each((function(){$.data(this,"plugin_qlwapp")||$.data(this,"plugin_qlwapp",new Plugin(this,options))})):"string"==typeof options&&"_"!==options[0]&&"init"!==options?(this.each((function(){var instance=$.data(this,"plugin_qlwapp");instance instanceof Plugin&&"function"==typeof instance[options]&&(returns=instance[options].apply(instance,Array.prototype.slice.call(args,1))),"destroy"===options&&$.data(this,"plugin_qlwapp",null)})),void 0!==returns?returns:this):void 0},qlwapp_init(),$(window).on("load",(function(){qlwapp_init()})),$(window).on("click",(function(e){$(e.target).closest("#qlwapp.qlwapp-show").length||$("div#qlwapp.qlwapp-show").trigger("qlwapp.toggle")})),$(window).on("resize",(function(e){$("div#qlwapp").trigger("qlwapp.resize"),$("div#qlwapp").trigger("qlwapp.init")}))}(jQuery,window,document);
 
changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  = 4.6.9 =
2
  * Fix. premium compatibility
3
 
1
+ = 4.7.0. =
2
+ * Fix. WordPress 5.5 compatibility
3
+ * Fix. open whatsapp in new tab on enter
4
+
5
  = 4.6.9 =
6
  * Fix. premium compatibility
7
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: quadlayers
3
  Donate link: https://quadlayers.com/portfolio/whatsapp-chat/
4
  Tags: whatsapp, whatsapp chat, whatsapp business, whatsapp support, click to chat, whatsapp group, directly message whatsapp, floating whatsapp, whatsapp message, help desk
5
  Requires at least: 3.0
6
- Tested up to: 5.4.2
7
- Stable tag: 4.6.9
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
3
  Donate link: https://quadlayers.com/portfolio/whatsapp-chat/
4
  Tags: whatsapp, whatsapp chat, whatsapp business, whatsapp support, click to chat, whatsapp group, directly message whatsapp, floating whatsapp, whatsapp message, help desk
5
  Requires at least: 3.0
6
+ Tested up to: 5.5.0
7
+ Stable tag: 4.7.0
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
wp-whatsapp-chat.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: WP Social Chat
5
  * Description: Social Chat allows your visitors to contact you or your team through WhatsApp chat with a single click.
6
  * Plugin URI: https://quadlayers.com/portfolio/whatsapp-chat/
7
- * Version: 4.6.9
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
@@ -17,7 +17,7 @@ if (!defined('ABSPATH')) {
17
  }
18
 
19
  define('QLWAPP_PLUGIN_NAME', 'WP Social Chat');
20
- define('QLWAPP_PLUGIN_VERSION', '4.6.9');
21
  define('QLWAPP_PLUGIN_FILE', __FILE__);
22
  define('QLWAPP_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR);
23
  define('QLWAPP_PREFIX', 'qlwapp');
4
  * Plugin Name: WP Social Chat
5
  * Description: Social Chat allows your visitors to contact you or your team through WhatsApp chat with a single click.
6
  * Plugin URI: https://quadlayers.com/portfolio/whatsapp-chat/
7
+ * Version: 4.7.0
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
17
  }
18
 
19
  define('QLWAPP_PLUGIN_NAME', 'WP Social Chat');
20
+ define('QLWAPP_PLUGIN_VERSION', '4.7.0');
21
  define('QLWAPP_PLUGIN_FILE', __FILE__);
22
  define('QLWAPP_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR);
23
  define('QLWAPP_PREFIX', 'qlwapp');