PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.0
8.8.0 8.7.9 8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 All 536 releases
← All changes | js/qcld-wp-chatbot-front.js +979 -865 8.5.6 → 8.8.0 View file →
@@ -1,865 +1,979 @@
1 -jQuery(function ($) {
2 - //Global object passed by admin
3 - var wpChatBotVar = wp_chatbot_obj;
4 -
5 - var LoadwpwBotPlugin = 0;
6 - var textEditorHandler = 0;
7 - if( typeof(openingHourIsFn) !='undefined'){
8 - var openingHourIs = openingHourIsFn;
9 - }else{
10 - var openingHourIs = 0;
11 - }
12 -
13 - wpChatBotVar.exit_intent_handler = 0;
14 - wpChatBotVar.scroll_open_handler = 0;
15 - wpChatBotVar.auto_open_handler = 0;
16 - wpChatBotVar.re_target_handler = 0;
17 -
18 - $(document).ready(function () {
19 - if(typeof(wpbot_clear_cache) !=="undefined" && wpbot_clear_cache !=''){
20 - wpwKits.reset();
21 - LoadwpwBotPlugin = 0;
22 - }
23 - var botimage = jQuery('#wp-chatbot-ball').find('img').attr('qcld_agent');
24 - if ($('#wp-chatbot-shortcode-template-container').length == 0 && $('#wp-chatbot-chat-app-shortcode-container').length == 0) {
25 - //Main wpwbot area.
26 - //show it
27 - $('#wp-chatbot-ball-wrapper').css({
28 - 'display': 'block',
29 - });
30 - //wpChatBot icon position.
31 - $('#wp-chatbot-chat-container').css({
32 - 'right': wpChatBotVar.wp_chatbot_position_x + 'px',
33 - 'bottom': wpChatBotVar.wp_chatbot_position_y + 'px'
34 - })
35 - //Facebook Messenger desktop
36 - setTimeout(function () {
37 - $('.fb_dialog').css({
38 - 'right': parseInt(55 + parseInt(wpChatBotVar.wp_chatbot_position_x)) + 'px',
39 - 'bottom': parseInt(17 + parseInt(wpChatBotVar.wp_chatbot_position_y)) + 'px',
40 - 'visibility': 'visible'
41 - });
42 - }, 3000);
43 -
44 - //wpchatbot icon animation disable or enable
45 - //Disable wpwBot icon Animation
46 - if (wpChatBotVar.disable_icon_animation == 1) {
47 - $('.wp-chatbot-ball').addClass('wp-chatbot-animation-deactive');
48 - } else {
49 - $('.wp-chatbot-ball').addClass('wp-chatbot-animation-active');
50 -
51 - //wpchatbot icon animation timing
52 - //var itemHide = function(){
53 - // $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').css({
54 - // "opacity": 0,
55 - // })
56 - //};
57 - var itemHide = function () {
58 - $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeOut(1000);
59 - };
60 - setTimeout(function () {
61 - itemHide()
62 - }, 1000);
63 -
64 - //Click Animation
65 - $('.wp-chatbot-animation-active').click(function () {
66 - $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeIn(100);
67 - setTimeout(function () {
68 - itemHide()
69 - }, 1000);
70 - });
71 - }
72 -
73 - //window resize.
74 - var widowH = $(window).height();
75 - var widowW = $(window).width();
76 - if (widowW > 767) {
77 - var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
78 - //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
79 -
80 - $(window).resize(function () {
81 - var widowH = $(window).height();
82 - var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
83 - //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
84 - });
85 - };
86 -
87 - $(document).on('click', '#wp-chatbot-ball', function (event) {
88 -
89 - if($('.active-chat-board').length>0){
90 - if(wpChatBotVar.template=='template-06' || wpChatBotVar.template=='template-07'){
91 - $('#wp-chatbot-ball').show();
92 - }
93 - $('#wp-chatbot-ball').removeClass('wpbot_chatopen_iconanimation');
94 - $('#wp-chatbot-ball').addClass('wpbot_chatclose_iconanimation');
95 - $('#wp-chatbot-ball').find('img').attr('src', botimage)
96 - $('.wp-chatbot-ball').css('background', '#ffffff');
97 -
98 -
99 - }else{
100 -
101 - $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
102 - $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
103 - $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
104 - //$('.wp-chatbot-ball').css('background', 'unset');
105 -
106 -
107 - }
108 -
109 - var $boardContainer = $("#wp-chatbot-board-container");
110 - var animationDuration = 280;
111 - var isOpening = !$boardContainer.hasClass('active-chat-board');
112 - $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-close-anim');
113 - if (isOpening) {
114 - $boardContainer.addClass('active-chat-board');
115 - void $boardContainer[0].offsetWidth;
116 - $boardContainer.addClass('wp-chatbot-open-anim');
117 - wpwbot_board_action();
118 - setTimeout(function () {
119 - $boardContainer.removeClass('wp-chatbot-open-anim');
120 - }, 360);
121 - } else {
122 - void $boardContainer[0].offsetWidth;
123 - $boardContainer.addClass('wp-chatbot-close-anim');
124 - setTimeout(function () {
125 - $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
126 - wpwbot_board_action();
127 - }, animationDuration);
128 - }
129 -
130 - });
131 - //wpwBot proActive start
132 - //Attention on
133 - if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!="") {
134 - var MetaTitleInterval;
135 - var orginalTitle = document.title;
136 - $(document).on("mouseover", 'body', function (e) {
137 - document.title = orginalTitle;
138 - clearInterval(MetaTitleInterval);
139 - });
140 - }
141 - //Exit Intent
142 - if(wpChatBotVar.enable_exit_intent == 1){
143 - window.addEventListener("mouseout", function (e) {
144 - e = e ? e : window.event;
145 -
146 - // If this is an autocomplete element.
147 - if (e.target.tagName.toLowerCase() == "input")
148 - return;
149 -
150 - // Get the current viewport width.
151 - var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
152 -
153 - // If the current mouse X position is within 50px of the right edge
154 - // of the viewport, return.
155 - if (e.clientX >= (vpWidth - 50))
156 - return;
157 -
158 - // If the current mouse Y position is not within 50px of the top
159 - // edge of the viewport, return.
160 - if (e.clientY >= 50)
161 - return;
162 -
163 - // Reliable, works on mouse exiting window and
164 - // user switching active program
165 - var from = e.relatedTarget || e.toElement;
166 - if (!from)
167 - //if will open once if setup from backend.
168 - var exitIntentOpen=true;
169 - if($.cookie('exit_intent')=='yes' && wpChatBotVar.exit_intent_once==1) {
170 - exitIntentOpen=false;
171 - }
172 - if ($('.active-chat-board').length == 0 && exitIntentOpen==true) {
173 - if (wpChatBotVar.exit_intent_handler == 0) {
174 - $("#wp-chatbot-board-container").addClass('active-chat-board');
175 - wpChatBotVar.exit_intent_handler++;
176 - wpChatBotVar.re_target_handler = 1;
177 - wpwbot_board_action();
178 - //Shopper Name
179 - if(localStorage.getItem('shopper')){
180 - var shopper=localStorage.getItem('shopper');
181 - }else{
182 - var shopper=wpChatBotVar.shopper_demo_name;
183 - }
184 - setTimeout(function () {
185 - if (localStorage.getItem("wpwHitory")) {
186 - showing_proactive_msg( wpChatBotVar.ret_greet+' '+shopper +', '+wpChatBotVar.exit_intent_msg);
187 - } else {
188 - showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.exit_intent_msg)
189 - }
190 - $.cookie('exit_intent','yes');
191 - //pro active sound
192 - proactive_retargeting_sound();
193 - //Window foucus meta title change.
194 - window_focus_change_meta_title();
195 - }, 1000)
196 - }
197 - }
198 - });
199 - }
200 - if(wpChatBotVar.enable_scroll_open==1){
201 -
202 - $(document).on('scroll', function (event) {
203 - var OpenScroll=true;
204 - //if will open once if setup from backend.
205 - if( $.cookie('scroll_open')=='yes' && wpChatBotVar.scroll_open_once==1) {
206 - OpenScroll=false;
207 - }
208 - //it will be open only for single time.
209 - if ($('.active-chat-board').length ==0 && OpenScroll==true) {
210 - if (wpChatBotVar.scroll_open_handler == 0) {
211 - var scrollOpenVal = parseInt(($(document).height() * wpChatBotVar.scroll_open_percent) / 100);
212 - if ($(window).scrollTop() + $(window).height() > scrollOpenVal) {
213 - $("#wp-chatbot-board-container").addClass('active-chat-board');
214 - wpChatBotVar.scroll_open_handler++;
215 - wpChatBotVar.re_target_handler = 2;
216 - wpwbot_board_action();
217 - //Shopper Name
218 - if(localStorage.getItem('shopper')){
219 - var shopper=localStorage.getItem('shopper');
220 - }else{
221 - var shopper=wpChatBotVar.shopper_demo_name;
222 - }
223 - setTimeout(function () {
224 - if (localStorage.getItem("wpwHitory")) {
225 - showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg);
226 - } else {
227 - showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg)
228 - }
229 - $.cookie('scroll_open','yes');
230 - //pro active sound
231 - proactive_retargeting_sound();
232 - //Window foucus meta title change.
233 - window_focus_change_meta_title();
234 - }, 1000)
235 - }
236 - }
237 - }
238 -
239 - });
240 - }
241 - if(wpChatBotVar.enable_auto_open==1 ){
242 - //if will open once if setup from backend.
243 - var autoOpen=true;
244 - if($.cookie('auto_open')=='yes' && wpChatBotVar.auto_open_once==1) {
245 - autoOpen=false;
246 - }
247 - if( wpChatBotVar.auto_open_handler == 0 && autoOpen==true) {
248 - setTimeout(function (e) {
249 - if ($('.active-chat-board').length == 0) {
250 - $("#wp-chatbot-board-container").addClass('active-chat-board');
251 - wpChatBotVar.auto_open_handler++;
252 - wpChatBotVar.re_target_handler = 3;
253 - wpwbot_board_action();
254 - //Shopper Name
255 - if(localStorage.getItem('shopper')){
256 - var shopper=localStorage.getItem('shopper');
257 - }else{
258 - var shopper=wpChatBotVar.shopper_demo_name;
259 - }
260 - setTimeout(function () {
261 - if (localStorage.getItem("wpwHitory")) {
262 - showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.auto_open_msg);
263 - } else {
264 - showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.auto_open_msg)
265 - }
266 - $.cookie('auto_open','yes');
267 - //pro active sound
268 - proactive_retargeting_sound();
269 - //Window foucus meta title change.
270 - window_focus_change_meta_title();
271 - }, 1000)
272 - }
273 - }, parseInt(wpChatBotVar.auto_open_time * 1000));
274 - }
275 - }
276 - //Retargeting for Cart to complete checkout.
277 - if(wpChatBotVar.enable_ret_user_show==1 && localStorage.getItem("wpwHitory") && $.cookie('return_user')!='yes') {
278 -
279 - $.cookie('return_user','yes');
280 - var data = {'action': 'qcld_wb_chatbot_only_cart'};
281 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
282 - if (response.items > 0) {
283 - if ($('.active-chat-board').length == 0) {
284 - setTimeout(function () {
285 - $("#wp-chatbot-board-container").addClass('active-chat-board');
286 - wpwbot_board_action();
287 - showing_proactive_msg(wpChatBotVar.checkout_msg);
288 - setTimeout(function () {
289 - showing_proactive_msg(response.html);
290 - //Window foucus meta title change.
291 - window_focus_change_meta_title();
292 - }, 2000);
293 - }, 1000);
294 - }
295 - }
296 - });
297 - }else{
298 - $.cookie('return_user','yes');
299 - }
300 -
301 - if(wpChatBotVar.enable_inactive_time_show==1 && localStorage.getItem("wpwHitory") ) {
302 - var timeoutID;
303 -
304 - function setup() {
305 - this.addEventListener("mousemove", resetTimer, false);
306 - this.addEventListener("mousedown", resetTimer, false);
307 - this.addEventListener("keypress", resetTimer, false);
308 - this.addEventListener("DOMMouseScroll", resetTimer, false);
309 - this.addEventListener("mousewheel", resetTimer, false);
310 - this.addEventListener("touchmove", resetTimer, false);
311 - this.addEventListener("MSPointerMove", resetTimer, false);
312 -
313 - startTimer();
314 - }
315 - setup();
316 -
317 - function startTimer() {
318 - // wait as set from admin seconds before calling goInactive
319 - timeoutID = window.setTimeout(goInactive, parseInt(wpChatBotVar.inactive_time*1000));
320 - }
321 -
322 - function resetTimer(e) {
323 - window.clearTimeout(timeoutID);
324 -
325 - goActive();
326 - }
327 -
328 - function goInactive() {
329 - if(wpChatBotVar.ret_inactive_user_once==1 && $.cookie('return_inactive_user')!='yes') {
330 - $.cookie('return_inactive_user','yes');
331 - var data = {'action': 'qcld_wb_chatbot_only_cart'};
332 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
333 - if (response.items > 0) {
334 - if ($('.active-chat-board').length == 0) {
335 - setTimeout(function () {
336 - $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
337 - $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
338 - $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
339 - $("#wp-chatbot-board-container").addClass('active-chat-board');
340 - wpwbot_board_action();
341 - showing_proactive_msg(wpChatBotVar.checkout_msg);
342 - setTimeout(function () {
343 - showing_proactive_msg(response.html);
344 - //Window foucus meta title change.
345 - window_focus_change_meta_title();
346 - }, 2000);
347 - }, 2000);
348 - }
349 - }
350 - });
351 - }else{
352 - $.cookie('return_inactive_user','yes');
353 - }
354 - }
355 -
356 - function goActive() {
357 - // do something
358 -
359 - startTimer();
360 - }
361 - }
362 - //Proactive retargeting sound for auto open. scroll open and
363 - function proactive_retargeting_sound() {
364 - if(wpChatBotVar.enable_ret_sound==1){
365 - var promise = document.querySelector('#wp-chatbot-proactive-audio').play();
366 - if (promise !== undefined) {
367 - promise.then(function (success) {
368 - //success to play
369 - }).catch(function (error) {
370 - //some error
371 - //console.log(error);
372 - });
373 - }
374 - }
375 - }
376 -
377 - //When user will be out of window and news retargetting will be shown. where opening hour, title and meta need to be set.
378 - function window_focus_change_meta_title() {
379 - if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!="" && openingHourIs==0) {
380 - var showInactive = 0;
381 - MetaTitleInterval = setInterval(function () {
382 - if (showInactive == 0) {
383 - document.title = wpChatBotVar.meta_label;
384 - showInactive = 1;
385 - } else {
386 - document.title = orginalTitle;
387 - showInactive = 0;
388 - }
389 - }, 1000);
390 - }
391 - }
392 -
393 - //wpwBot proActive end
394 - function wpwbot_board_action() {
395 - if (widowW <= 1024 && wpChatBotVar.mobile_full_screen==1 ) {//For mobile
396 - if ($('#wp-chatbot-mobile-close').length <= 0) {
397 - $('.wp-chatbot-board-container').append('<div id="wp-chatbot-mobile-close">X</div>');
398 - }
399 - $('.wp-chatbot-ball-inner').slimScroll({
400 - height: '100hv',
401 - start: 'bottom'
402 - }).parent().find('.slimScrollBar').css({'top': $('.wp-chatbot-ball-inner').height() + 'px'});
403 - $('#wp-chatbot-chat-container').css({'bottom': '0', 'left': '0', 'right': '0'});
404 - $('#wp-chatbot-ball').hide();
405 - //Maintain inner chat box height
406 - var widowH = $(window).height();
407 - var headerH = $('.wp-chatbot-header').outerHeight();
408 - var footerH = $('.wp-chatbot-footer').outerHeight();
409 - var AppContentInner = widowH - footerH - headerH;
410 - //alert(footerH);
411 - $('.wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
412 - $('.wp-chatbot-ball-inner').css({'max-height': AppContentInner + 'px'})
413 - $(this).hide();
414 - } else {
415 - // $('.wp-chatbot-header').append('<div id="wp-chatbot-desktop-close"><span class="dashicons dashicons-no"></span></div>');
416 - $('.wp-chatbot-ball-inner').slimScroll({
417 - height: '55hv',
418 - start: 'bottom'
419 - }).parent().find('.slimScrollBar').css({'top': $('.wp-chatbot-ball-inner').height() + 'px'});
420 - }
421 -
422 -
423 - //Here is the Plugin to be load only for once.
424 - if (LoadwpwBotPlugin == 0) {
425 - $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime});
426 - LoadwpwBotPlugin++;
427 - var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
428 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
429 - //
430 - });
431 - }
432 - //If product detials is open then it will be closed.
433 - $('.wp-chatbot-product-container').removeClass('active-chatbot-product-details');
434 - //Show and close notification message on ball click
435 - if ($('.active-chat-board').length != 0) {
436 - $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-sliding');
437 - //chatbox will be open and notificaion will be closed
438 - $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
439 - //clearInterval(notificationInterval);
440 - } else {
441 - if (!sessionStorage.getItem('wpChatbotNotification')) {
442 - $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-disable');
443 - $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
444 -
445 - }
446 - /// clearInterval(notificationInterval);
447 - }
448 - //Messenger handling.
449 - if ($('.active-chat-board').length > 0) {
450 - $('#wp-chatbot-integration-container').show();
451 - } else {
452 - $('#wp-chatbot-integration-container').hide();
453 - }
454 - }
455 - function showing_proactive_msg(msg){
456 - var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
457 - var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
458 - var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
459 - var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
460 - var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
461 - var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
462 - var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
463 - console.log(globalwpw.settings);
464 - console.log(enableleReactions);
465 - //first open then chatboard
466 - if(localStorage.getItem("wpwHitory") && ! $('.wp-chatbot-operation-option[data-option="chat"]').parent().hasClass('wp-chatbot-operation-active')){
467 - $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
468 - $('.wp-chatbot-operation-option').each(function(){
469 - if($(this).attr('data-option')=='chat'){
470 - $(this).parent().addClass('wp-chatbot-operation-active');
471 - }else{
472 - $(this).parent().removeClass('wp-chatbot-operation-active');
473 - }
474 - });
475 - }
476 - var msgContent='<li class="wp-chatbot-msg">' +
477 - '<div class="wp-chatbot-avatar">'+
478 - '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
479 - '</div>'+
480 - '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
481 - +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
482 - '<div class="qcld-like-dislike-icon">' +
483 - (enableleReactions == 1
484 - ? '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up" ></i></a>' +
485 - '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>'
486 - : '') +
487 -
488 - (eanleeReport == 1
489 - ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
490 - : '') +
491 -
492 - (enableshare == 1
493 - ? '<div class="qcld-share">' +
494 - '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share" aria-hidden="true"></i></a>' +
495 - '<div class="share-menu" style="display:none;">' +
496 - '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
497 - '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
498 - '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
499 - '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
500 - '</div>' +
501 - '</div>'
502 - : '') +
503 - '</div>' +
504 - '</li>';
505 -
506 - $('#wp-chatbot-messages-container').append(msgContent);
507 - //Scroll to the last message
508 - $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow').parent().find('.slimScrollBar').css({'top':$('.wp-chatbot-ball-inner').height()+'px'});
509 - setTimeout(function(){
510 - $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(msg).css({'background-color':wpChatBotVar.proactive_bg_color});
511 - //scroll to the last message
512 - $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow').parent().find('.slimScrollBar').css({'top':$('.wp-chatbot-ball-inner').height()+'px'});
513 - }, 2000);
514 - }
515 - function showing_proactive_double_msg(secondMsg) {
516 - var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
517 - var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
518 - var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
519 - var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
520 - var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
521 - var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
522 - var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
523 - console.log(globalwpw.settings);
524 - console.log(enableleReactions);
525 - //first open then chatboard
526 - if(localStorage.getItem("wpwHitory")){
527 - $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
528 - $('.wp-chatbot-operation-option').each(function(){
529 - if($(this).attr('data-option')=='chat'){
530 - $(this).parent().addClass('wp-chatbot-operation-active');
531 - }else{
532 - $(this).parent().removeClass('wp-chatbot-operation-active');
533 - }
534 - });
535 - }
536 - var fristMsg="<strong>"+wpChatBotVar.agent+" </strong> "+wpChatBotVar.agent_join[0];
537 - var msgContent='<li class="wp-chatbot-msg">' +
538 - '<div class="wp-chatbot-avatar">'+
539 - '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
540 - '</div>'+
541 - '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
542 - +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
543 - '<div class="qcld-like-dislike-icon">' +
544 - (enableleReactions == 1
545 - ? '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up"></i></a>' +
546 - '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>'
547 - : '') +
548 -
549 - (eanleeReport == 1
550 - ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
551 - : '') +
552 -
553 - (enableshare == 1
554 - ? '<div class="qcld-share">' +
555 - '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share"></i></a>' +
556 - '<div class="share-menu" style="display:none;">' +
557 - '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
558 - '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
559 - '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
560 - '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
561 - '</div>' +
562 - '</div>'
563 - : '') +
564 - '</div>' +
565 - '</li>';
566 - $('#wp-chatbot-messages-container').append(msgContent);
567 - //Scroll to the last message
568 - $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow').parent().find('.slimScrollBar').css({'top':$('.wp-chatbot-ball-inner').height()+'px'});
569 -
570 - setTimeout(function(){
571 - $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(fristMsg);
572 - //Second Message with interval
573 - $('#wp-chatbot-messages-container').append(msgContent);
574 - //Scroll to the last message
575 - $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow').parent().find('.slimScrollBar').css({'top':$('.wp-chatbot-ball-inner').height()+'px'});
576 - setTimeout(function(){
577 - $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(secondMsg).css({'background-color':wpChatBotVar.proactive_bg_color});
578 - //Scroll to the last message
579 - $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow').parent().find('.slimScrollBar').css({'top':$('.wp-chatbot-ball-inner').height()+'px'});
580 -
581 - }, 2000);
582 -
583 - }, 2000);
584 - }
585 - $(document).on('click', '#wp-chatbot-mobile-close, #wp-chatbot-desktop-close', function (event) {
586 - var $boardContainer = $("#wp-chatbot-board-container");
587 - if ($boardContainer.hasClass('active-chat-board')) {
588 - $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-anim');
589 - void $boardContainer[0].offsetWidth;
590 - $boardContainer.addClass('wp-chatbot-close-anim');
591 - setTimeout(function () {
592 - $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
593 - }, 280);
594 - }
595 - $("#wp-chatbot-notification-container").removeClass('wp-chatbot-notification-container-disable').addClass('wp-chatbot-notification-container-sliding');
596 - $('#wp-chatbot-chat-container').css({
597 - 'right': wpChatBotVar.wp_chatbot_position_x + 'px',
598 - 'bottom': wpChatBotVar.wp_chatbot_position_y + 'px',
599 - 'top': 'auto', 'left': 'auto'
600 - });
601 - $('#wp-chatbot-ball').find('img').attr('src', botimage)
602 - $('.wp-chatbot-ball').css('background', '#ffffff');
603 - $('#wp-chatbot-ball').show();
604 - //Facebook Messenger.
605 - if ($('.active-chat-board').length > 0) {
606 - $('#wp-chatbot-integration-container').show();
607 - } else {
608 - $('#wp-chatbot-integration-container').hide();
609 - }
610 - });
611 - function wpbotSyncExpandIconState() {
612 - var $boardContainer = $('#wp-chatbot-board-container');
613 - var isExpanded = $boardContainer.hasClass('wp-chatbot-expanded');
614 - $('#wp-chatbot-desktop-expand').attr('title', isExpanded ? 'Collapse' : 'Expand').find('span')
615 - .removeClass('dashicons dashicons-fullscreen-exit-alt')
616 - .addClass('dashicons ' + (isExpanded ? 'dashicons-editor-contract' : 'dashicons-editor-expand'));
617 - }
618 -
619 - wpbotSyncExpandIconState();
620 -
621 - $(document).on('click', '#wp-chatbot-desktop-expand', function (event) {
622 - event.preventDefault();
623 - var $boardContainer = $('#wp-chatbot-board-container');
624 - $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-anim');
625 - $boardContainer.toggleClass('wp-chatbot-expanded');
626 - var isExpanded = $boardContainer.hasClass('wp-chatbot-expanded');
627 - if (isExpanded) {
628 - void $boardContainer[0].offsetWidth;
629 - $boardContainer.addClass('wp-chatbot-expand-anim');
630 - } else {
631 - void $boardContainer[0].offsetWidth;
632 - $boardContainer.addClass('wp-chatbot-collapse-anim');
633 - }
634 - wpbotSyncExpandIconState();
635 - setTimeout(function () {
636 - $boardContainer.removeClass('wp-chatbot-expand-anim wp-chatbot-collapse-anim');
637 - }, 360);
638 - });
639 -
640 -
641 - $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
642 - /***
643 - * Notification Message
644 - */
645 - if ($('#wp-chatbot-notification-container').length > 0) {
646 - if (sessionStorage.getItem('wpChatbotNotification') && sessionStorage.getItem('wpChatbotNotification') == 'removed') {
647 - //if remove on the session.
648 - $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
649 - } else {
650 - //Notification comes with slideIn effect
651 - $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
652 - //handling welcome & return user welcome msg.
653 - if ($.cookie("shopper")) {
654 - var shopper = $.cookie("shopper");
655 - var welcomeMsg = wpChatBotVar.welcome_back[0] + ' <strong>' + shopper + '!</strong>';
656 - } else {
657 - var welcomeMsg = wpChatBotVar.welcome[0] + ' <strong>' + wpChatBotVar.host + '!</strong>';
658 -
659 - }
660 - $('.wp-chatbot-notification-welcome').html(welcomeMsg);
661 - //Notifications msgs handling.
662 - var notifications = wpChatBotVar.notifications;
663 - if (notifications.length > 1) {
664 - var totalNotMsg = wpChatBotVar.notifications.length;
665 - var notMsgIndex = 0;
666 - var intervalTime = parseInt(wpChatBotVar.notification_interval) * 1000;
667 - var notificationInterval = setInterval(function (e) {
668 - notMsgIndex++;
669 - if (totalNotMsg <= notMsgIndex) {
670 - notMsgIndex = 0;
671 - }
672 - //show new notification time after every intervalTime
673 - $('.wp-chatbot-notification-message').css({'opacity': 1}).html(notifications[notMsgIndex]);
674 - }, intervalTime);
675 - }
676 -
677 - $(".wp-chatbot-notification-close").click(function () {
678 - $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
679 - //clearInterval(notificationInterval);
680 - sessionStorage.setItem('wpChatbotNotification', 'removed');
681 - });
682 - }
683 - }
684 - }
685 - else if ($('#wp-chatbot-shortcode-template-container').length > 0) { //Page shortcode area.
686 - $('#wp-chatbot-chat-container').css({'display': 'none'});
687 - $('#wp-chatbot-ball').hide();
688 - //Add Scroll to chat ui
689 - $('.wp-chatbot-ball-inner').slimScroll({
690 - height: '60hv',
691 - start: 'bottom'
692 - }).parent().find('.slimScrollBar').css({'top': $('.wp-chatbot-ball-inner').height() + 'px'});
693 - //Add scroll to cart part
694 - var recentViewHeight = $('.wp-chatbot-container').outerHeight();
695 - if ($('.chatbot-shortcode-template-02').length == 0) {
696 - $('.wp-chatbot-cart-body').slimScroll({height: '200px', start: 'top'});
697 - $('.wp-chatbot-widget .wp-chatbot-products').slimScroll({height: '435px', start: 'top'});
698 - }
699 -
700 - //Remove style of template
701 - $("#qcld-wp-chatbot-style-css").attr("disabled", "disabled");
702 - //Here is the Plugin to be load only for once.
703 - if (LoadwpwBotPlugin == 0) {
704 - $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
705 - LoadwpwBotPlugin++;
706 - var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
707 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
708 - //
709 - });
710 - }
711 -
712 -
713 - }
714 - else if ($('#wp-chatbot-chat-app-shortcode-container').length > 0) { //App shortcode area.
715 -
716 - textEditorHandler = 1;
717 - //App UI (ball inner)
718 - setTimeout(function () {
719 - var widowH = $(window).height();
720 - //var headerH = $('.wp-chatbot-header').outerHeight();
721 - var footerH = $('.wp-chatbot-footer').outerHeight();
722 -
723 - var AppContentInner = widowH - footerH;
724 - //alert(footerH);
725 - $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
726 - }, 300);
727 - $(window).resize(function () {
728 - setTimeout(function () {
729 - var widowH = $(window).height();
730 - //var headerH = $('.wp-chatbot-header').outerHeight();
731 - var footerH = $('.wp-chatbot-footer').outerHeight();
732 - var AppContentInner = widowH - footerH;
733 - //alert(footerH);
734 - $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
735 - }, 300)
736 - });
737 -
738 - $('#wp-chatbot-ball').hide();
739 - //Add Scroll to chat ui
740 - $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
741 - $("#wp-chatbot-board-container").addClass('active-chat-board');
742 - $('.wp-chatbot-ball-inner').slimScroll({
743 - height: '55hv',
744 - start: 'bottom'
745 - }).parent().find('.slimScrollBar').css({'top': $(window).height() + 'px'});
746 - if (LoadwpwBotPlugin == 0) {
747 - $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
748 - LoadwpwBotPlugin++;
749 - var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
750 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
751 - //
752 - });
753 - }
754 - //Handling app cart and checkout
755 - $('#wp-chatbot-cart-short-code').hide();
756 - $('#wp-chatbot-checkout-short-code').hide();
757 - $(document).on('click', '.wp-chatbot-cart-link', function (event) {
758 - $('.wp-chatbot-messages-wrapper').hide();
759 - $('#wp-chatbot-checkout-short-code').hide();
760 - $('#wp-chatbot-cart-short-code').show();
761 - event.preventDefault();
762 - $('#wp-chatbot-cart-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
763 - var data = {'action': 'qcld_wb_chatbot_cart_page'};
764 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
765 - $("#wp-chatbot-cart-short-code").html(response);
766 - });
767 - });
768 - $(document).on('click', '.wp-chatbot-checkout-link, .checkout-button', function (event) {
769 - event.preventDefault();
770 - $('.wp-chatbot-messages-wrapper').hide();
771 - $('#wp-chatbot-cart-short-code').hide();
772 - $('#wp-chatbot-checkout-short-code').show();
773 -
774 -
775 - $('#wp-chatbot-checkout-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
776 - var data = {'action': 'qcld_wb_chatbot_checkout_page'};
777 - jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
778 - if (response.status == 'yes') {
779 - window.location.href = response.html;
780 - } else {
781 - $("#wp-chatbot-checkout-short-code").html(response.html);
782 - }
783 -
784 - });
785 - });
786 - //Preventing url redirect from cart page.
787 - $(document).on('click', '#wp-chatbot-chat-app-shortcode-container .wpcommerce-cart-form a', function (e) {
788 - e.preventDefault();
789 - });
790 - }
791 - //For variable product configuration
792 - $(document).on('change', "#wp-chatbot-product-variable select ", function () {
793 - var variations = JSON.parse($("#wp-chatbot-variation-data").attr('data-product-variation'));
794 - var item_conditions = [];
795 -
796 - var totalAttr = $("#wp-chatbot-product-variable select").length;
797 - var i = 1;
798 - $("#wp-chatbot-product-variable select").each(function (index, element) {
799 - var myVal = $(this).find('option:selected').val();
800 - if (myVal != "") {
801 - item_conditions.push({
802 - 'left': 'item["variation_data"]["' + $(this).attr('name') + '"][0]',
803 - 'right': myVal
804 - })
805 - }
806 - });
807 - var newVariation = [];
808 - for (var a = 0; variations.length > a; a++) {
809 - var item = variations[a];
810 - var item_condition = "";
811 - for (var i = 0; item_conditions.length > i; i++) {
812 -
813 - if (i > 0) {
814 - item_condition += ' && ' + '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
815 - } else {
816 - item_condition += '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
817 - }
818 - }
819 - if (eval(item_condition)) {
820 - newVariation[0] = item;
821 - }
822 - }
823 - if (newVariation.length > 0) {
824 - $('#wp-chatbot-variation-add-to-cart').attr('variation_id', newVariation[0]['variation_id']);
825 - var priceSets = "";
826 - if (newVariation[0]['variation_data']['_sale_price'][0] != "") {
827 - priceSets += '<strike>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strike> <strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_sale_price'][0] + '</strong>'
828 - } else {
829 - priceSets += '<strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strong>';
830 - }
831 - $('#wp-chatbot-product-price').html(priceSets);
832 - }
833 - });
834 -
835 - if ($('.active-chat-board').length > 0) {
836 - $('#wp-chatbot-integration-container').show();
837 - } else {
838 - $('#wp-chatbot-integration-container').hide();
839 - }
840 - //Facebook Messenger Integration
841 - /* if(wpChatBotVar.enable_messenger == 1){
842 - $(document).on('click','.fb_dialog',function (e) {
843 - $('#wp-chatbot-board-container').removeClass('active-chat-board');
844 - $('.fb_dialog').css({'display': 'inline'});
845 - setTimeout(function (e) {
846 - $('.fb-customerchat >span').css({'display': 'inline'});
847 - $('.fb_dialog').trigger('click'); //.css({'display': 'none'});
848 - },300);
849 - $('#wp-chatbot-integration-container').hide();
850 - });
851 - }*/
852 - //skype
853 - if (wpChatBotVar.enable_skype == 1) {
854 - $(document).on('click', '.inetegration-skype-btn', function (e) {
855 - $('#wp-chatbot-board-container').removeClass('active-chat-board');
856 - // $('.lwc-button-icon').trigger('click');
857 - $('#wp-chatbot-integration-container').hide();
858 - });
859 -
860 - }
861 -
862 -
863 - });
864 -
865 -});
1 +jQuery(function ($) {
2 + //Global object passed by admin
3 + var wpChatBotVar = wp_chatbot_obj;
4 +
5 + var LoadwpwBotPlugin = 0;
6 + var textEditorHandler = 0;
7 + if( typeof(openingHourIsFn) !='undefined'){
8 + var openingHourIs = openingHourIsFn;
9 + }else{
10 + var openingHourIs = 0;
11 + }
12 +
13 + /**
14 + * Hide slimScroll bar when content fits; otherwise pin bar to the bottom correctly.
15 + * slimScroll shows the bar when scrollHeight < clientHeight due to its size math.
16 + */
17 + window.wpbotSyncSlimScrollBar = function ($inner) {
18 + $inner = ($inner && $inner.jquery) ? $inner : $('.wp-chatbot-ball-inner');
19 + $inner.each(function () {
20 + var el = this;
21 + var $el = $(el);
22 + var $wrap = $el.parent();
23 + if (!$wrap.hasClass('slimScrollDiv')) {
24 + return;
25 + }
26 + var $bar = $wrap.children('.slimScrollBar');
27 + var $rail = $wrap.children('.slimScrollRail');
28 + if (!$bar.length) {
29 + return;
30 + }
31 + if (el.scrollHeight <= el.clientHeight + 2) {
32 + $wrap.addClass('wpbot-no-scroll');
33 + $bar.stop(true, true).hide().css({ opacity: 0 });
34 + $rail.stop(true, true).hide();
35 + return;
36 + }
37 + $wrap.removeClass('wpbot-no-scroll');
38 + var barH = Math.max(($el.outerHeight() / el.scrollHeight) * $el.outerHeight(), 30);
39 + barH = Math.min(barH, $el.outerHeight());
40 + var maxTop = Math.max(0, $el.outerHeight() - barH);
41 + var ratio = el.scrollHeight > el.clientHeight
42 + ? el.scrollTop / (el.scrollHeight - el.clientHeight)
43 + : 1;
44 + $bar.css({
45 + height: barH + 'px',
46 + top: (ratio * maxTop) + 'px',
47 + display: 'block',
48 + opacity: 0.4
49 + });
50 + clearTimeout($bar.data('wpbotBarHideTimer'));
51 + $bar.data('wpbotBarHideTimer', setTimeout(function () {
52 + if (!$bar.is(':hover')) {
53 + $bar.fadeOut('slow');
54 + }
55 + }, 1000));
56 + });
57 + };
58 +
59 + wpChatBotVar.exit_intent_handler = 0;
60 + wpChatBotVar.scroll_open_handler = 0;
61 + wpChatBotVar.auto_open_handler = 0;
62 + wpChatBotVar.re_target_handler = 0;
63 +
64 + $(document).ready(function () {
65 + if(typeof(wpbot_clear_cache) !=="undefined" && wpbot_clear_cache !=''){
66 + wpwKits.reset();
67 + LoadwpwBotPlugin = 0;
68 + }
69 + var botimage = jQuery('#wp-chatbot-ball').find('img').attr('qcld_agent');
70 +
71 + // Custom Icon Video / YouTube: start playback after configured delay
72 + var wpbotIconVideo = wpChatBotVar.icon_video || '';
73 + var wpbotVideoDelay = parseInt(wpChatBotVar.icon_video_delay, 10) || 0;
74 + if (wpbotIconVideo !== '') {
75 + var $wpbotVidEl = $('#wp-chatbot-ball-icon-video');
76 + if ($wpbotVidEl.length) {
77 + if (wpbotVideoDelay > 0) {
78 + $wpbotVidEl.hide();
79 + setTimeout(function () {
80 + $wpbotVidEl.show();
81 + if ($wpbotVidEl.is('video')) {
82 + try { $wpbotVidEl[0].play(); } catch(e){}
83 + }
84 + }, wpbotVideoDelay * 1000);
85 + } else {
86 + if ($wpbotVidEl.is('video')) {
87 + try { $wpbotVidEl[0].play(); } catch(e){}
88 + }
89 + }
90 + }
91 + }
92 +
93 + if ($('#wp-chatbot-shortcode-template-container').length == 0 && $('#wp-chatbot-chat-app-shortcode-container').length == 0) {
94 + //Main wpwbot area.
95 + //show it
96 + $('#wp-chatbot-ball-wrapper').css({
97 + 'display': 'block',
98 + });
99 + //wpChatBot icon position.
100 + $('#wp-chatbot-chat-container').css({
101 + 'right': wpChatBotVar.wp_chatbot_position_x + 'px',
102 + 'bottom': wpChatBotVar.wp_chatbot_position_y + 'px'
103 + })
104 + //Facebook Messenger desktop
105 + setTimeout(function () {
106 + $('.fb_dialog').css({
107 + 'right': parseInt(55 + parseInt(wpChatBotVar.wp_chatbot_position_x)) + 'px',
108 + 'bottom': parseInt(17 + parseInt(wpChatBotVar.wp_chatbot_position_y)) + 'px',
109 + 'visibility': 'visible'
110 + });
111 + }, 3000);
112 +
113 + //wpchatbot icon animation disable or enable
114 + //Disable wpwBot icon Animation
115 + if (wpChatBotVar.disable_icon_animation == 1) {
116 + $('.wp-chatbot-ball').addClass('wp-chatbot-animation-deactive');
117 + } else {
118 + $('.wp-chatbot-ball').addClass('wp-chatbot-animation-active');
119 +
120 + //wpchatbot icon animation timing
121 + //var itemHide = function(){
122 + // $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').css({
123 + // "opacity": 0,
124 + // })
125 + //};
126 + var itemHide = function () {
127 + $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeOut(1000);
128 + };
129 + setTimeout(function () {
130 + itemHide()
131 + }, 1000);
132 +
133 + //Click Animation
134 + $('.wp-chatbot-animation-active').click(function () {
135 + $('.wp-chatbot-animation-active .wp-chatbot-ball-animation-switch').fadeIn(100);
136 + setTimeout(function () {
137 + itemHide()
138 + }, 1000);
139 + });
140 + }
141 +
142 + //window resize.
143 + var widowH = $(window).height();
144 + var widowW = $(window).width();
145 + if (widowW > 767) {
146 + var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
147 + //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
148 +
149 + $(window).resize(function () {
150 + var widowH = $(window).height();
151 + var ballConH = parseInt(widowH * 0.5)+ parseInt(114);
152 + //$('.wp-chatbot-ball-inner').css({'height': ballConH + 'px'})
153 + });
154 + };
155 +
156 + $(document).on('click', '#wp-chatbot-ball', function (event) {
157 +
158 + if($('.active-chat-board').length>0){
159 + if(wpChatBotVar.template=='template-06' || wpChatBotVar.template=='template-07'){
160 + $('#wp-chatbot-ball').show();
161 + }
162 + $('#wp-chatbot-ball').removeClass('wpbot_chatopen_iconanimation');
163 + $('#wp-chatbot-ball').addClass('wpbot_chatclose_iconanimation');
164 + // Restore: hide close icon, show video OR image
165 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', botimage);
166 + if (wpbotIconVideo !== '') {
167 + $('#wp-chatbot-ball-icon-video').show();
168 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').hide();
169 + $('#wp-chatbot-ball').find('img.wpbot-close-icon-overlay').hide();
170 + } else {
171 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').show();
172 + }
173 + $('.wp-chatbot-ball').css('background', '#ffffff');
174 +
175 +
176 + }else{
177 +
178 + $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
179 + $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
180 + // Show close icon; hide video OR image
181 + if (wpbotIconVideo !== '') {
182 + $('#wp-chatbot-ball-icon-video').hide();
183 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png').show();
184 + } else {
185 + $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
186 + }
187 + //$('.wp-chatbot-ball').css('background', 'unset');
188 +
189 +
190 + }
191 +
192 + var $boardContainer = $("#wp-chatbot-board-container");
193 + var animationDuration = 280;
194 + var isOpening = !$boardContainer.hasClass('active-chat-board');
195 + $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-close-anim');
196 + if (isOpening) {
197 + $boardContainer.addClass('active-chat-board');
198 + void $boardContainer[0].offsetWidth;
199 + $boardContainer.addClass('wp-chatbot-open-anim');
200 + wpwbot_board_action();
201 + setTimeout(function () {
202 + $boardContainer.removeClass('wp-chatbot-open-anim');
203 + }, 360);
204 + } else {
205 + void $boardContainer[0].offsetWidth;
206 + $boardContainer.addClass('wp-chatbot-close-anim');
207 + setTimeout(function () {
208 + $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
209 + wpwbot_board_action();
210 + }, animationDuration);
211 + }
212 +
213 + });
214 + //wpwBot proActive start
215 + //Attention on
216 + if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!="") {
217 + var MetaTitleInterval;
218 + var orginalTitle = document.title;
219 + $(document).on("mouseover", 'body', function (e) {
220 + document.title = orginalTitle;
221 + clearInterval(MetaTitleInterval);
222 + });
223 + }
224 + //Exit Intent
225 + if(wpChatBotVar.enable_exit_intent == 1){
226 + window.addEventListener("mouseout", function (e) {
227 + e = e ? e : window.event;
228 +
229 + // If this is an autocomplete element.
230 + if (e.target.tagName.toLowerCase() == "input")
231 + return;
232 +
233 + // Get the current viewport width.
234 + var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
235 +
236 + // If the current mouse X position is within 50px of the right edge
237 + // of the viewport, return.
238 + if (e.clientX >= (vpWidth - 50))
239 + return;
240 +
241 + // If the current mouse Y position is not within 50px of the top
242 + // edge of the viewport, return.
243 + if (e.clientY >= 50)
244 + return;
245 +
246 + // Reliable, works on mouse exiting window and
247 + // user switching active program
248 + var from = e.relatedTarget || e.toElement;
249 + if (!from)
250 + //if will open once if setup from backend.
251 + var exitIntentOpen=true;
252 + if($.cookie('exit_intent')=='yes' && wpChatBotVar.exit_intent_once==1) {
253 + exitIntentOpen=false;
254 + }
255 + if ($('.active-chat-board').length == 0 && exitIntentOpen==true) {
256 + if (wpChatBotVar.exit_intent_handler == 0) {
257 + $("#wp-chatbot-board-container").addClass('active-chat-board');
258 + wpChatBotVar.exit_intent_handler++;
259 + wpChatBotVar.re_target_handler = 1;
260 + wpwbot_board_action();
261 + //Shopper Name
262 + if(localStorage.getItem('shopper')){
263 + var shopper=localStorage.getItem('shopper');
264 + }else{
265 + var shopper=wpChatBotVar.shopper_demo_name;
266 + }
267 + setTimeout(function () {
268 + if (localStorage.getItem("wpwHitory")) {
269 + showing_proactive_msg( wpChatBotVar.ret_greet+' '+shopper +', '+wpChatBotVar.exit_intent_msg);
270 + } else {
271 + showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.exit_intent_msg)
272 + }
273 + $.cookie('exit_intent','yes');
274 + //pro active sound
275 + proactive_retargeting_sound();
276 + //Window foucus meta title change.
277 + window_focus_change_meta_title();
278 + }, 1000)
279 + }
280 + }
281 + });
282 + }
283 + if(wpChatBotVar.enable_scroll_open==1){
284 +
285 + $(document).on('scroll', function (event) {
286 + var OpenScroll=true;
287 + //if will open once if setup from backend.
288 + if( $.cookie('scroll_open')=='yes' && wpChatBotVar.scroll_open_once==1) {
289 + OpenScroll=false;
290 + }
291 + //it will be open only for single time.
292 + if ($('.active-chat-board').length ==0 && OpenScroll==true) {
293 + if (wpChatBotVar.scroll_open_handler == 0) {
294 + var scrollOpenVal = parseInt(($(document).height() * wpChatBotVar.scroll_open_percent) / 100);
295 + if ($(window).scrollTop() + $(window).height() > scrollOpenVal) {
296 + $("#wp-chatbot-board-container").addClass('active-chat-board');
297 + wpChatBotVar.scroll_open_handler++;
298 + wpChatBotVar.re_target_handler = 2;
299 + wpwbot_board_action();
300 + //Shopper Name
301 + if(localStorage.getItem('shopper')){
302 + var shopper=localStorage.getItem('shopper');
303 + }else{
304 + var shopper=wpChatBotVar.shopper_demo_name;
305 + }
306 + setTimeout(function () {
307 + if (localStorage.getItem("wpwHitory")) {
308 + showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg);
309 + } else {
310 + showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.scroll_open_msg)
311 + }
312 + $.cookie('scroll_open','yes');
313 + //pro active sound
314 + proactive_retargeting_sound();
315 + //Window foucus meta title change.
316 + window_focus_change_meta_title();
317 + }, 1000)
318 + }
319 + }
320 + }
321 +
322 + });
323 + }
324 + if(wpChatBotVar.enable_auto_open==1 ){
325 + //if will open once if setup from backend.
326 + var autoOpen=true;
327 + if($.cookie('auto_open')=='yes' && wpChatBotVar.auto_open_once==1) {
328 + autoOpen=false;
329 + }
330 + if( wpChatBotVar.auto_open_handler == 0 && autoOpen==true) {
331 + setTimeout(function (e) {
332 + if ($('.active-chat-board').length == 0) {
333 + $("#wp-chatbot-board-container").addClass('active-chat-board');
334 + wpChatBotVar.auto_open_handler++;
335 + wpChatBotVar.re_target_handler = 3;
336 + wpwbot_board_action();
337 + //Shopper Name
338 + if(localStorage.getItem('shopper')){
339 + var shopper=localStorage.getItem('shopper');
340 + }else{
341 + var shopper=wpChatBotVar.shopper_demo_name;
342 + }
343 + setTimeout(function () {
344 + if (localStorage.getItem("wpwHitory")) {
345 + showing_proactive_msg(wpChatBotVar.ret_greet+' '+ shopper+', '+wpChatBotVar.auto_open_msg);
346 + } else {
347 + showing_proactive_double_msg(wpChatBotVar.ret_greet+' '+shopper+', '+wpChatBotVar.auto_open_msg)
348 + }
349 + $.cookie('auto_open','yes');
350 + //pro active sound
351 + proactive_retargeting_sound();
352 + //Window foucus meta title change.
353 + window_focus_change_meta_title();
354 + }, 1000)
355 + }
356 + }, parseInt(wpChatBotVar.auto_open_time * 1000));
357 + }
358 + }
359 + //Retargeting for Cart to complete checkout.
360 + if(wpChatBotVar.enable_ret_user_show==1 && localStorage.getItem("wpwHitory") && $.cookie('return_user')!='yes') {
361 +
362 + $.cookie('return_user','yes');
363 + var data = {'action': 'qcld_wb_chatbot_only_cart'};
364 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
365 + if (response.items > 0) {
366 + if ($('.active-chat-board').length == 0) {
367 + setTimeout(function () {
368 + $("#wp-chatbot-board-container").addClass('active-chat-board');
369 + wpwbot_board_action();
370 + showing_proactive_msg(wpChatBotVar.checkout_msg);
371 + setTimeout(function () {
372 + showing_proactive_msg(response.html);
373 + //Window foucus meta title change.
374 + window_focus_change_meta_title();
375 + }, 2000);
376 + }, 1000);
377 + }
378 + }
379 + });
380 + }else{
381 + $.cookie('return_user','yes');
382 + }
383 +
384 + if(wpChatBotVar.enable_inactive_time_show==1 && localStorage.getItem("wpwHitory") ) {
385 + var timeoutID;
386 +
387 + function setup() {
388 + this.addEventListener("mousemove", resetTimer, false);
389 + this.addEventListener("mousedown", resetTimer, false);
390 + this.addEventListener("keypress", resetTimer, false);
391 + this.addEventListener("DOMMouseScroll", resetTimer, false);
392 + this.addEventListener("mousewheel", resetTimer, false);
393 + this.addEventListener("touchmove", resetTimer, false);
394 + this.addEventListener("MSPointerMove", resetTimer, false);
395 +
396 + startTimer();
397 + }
398 + setup();
399 +
400 + function startTimer() {
401 + // wait as set from admin seconds before calling goInactive
402 + timeoutID = window.setTimeout(goInactive, parseInt(wpChatBotVar.inactive_time*1000));
403 + }
404 +
405 + function resetTimer(e) {
406 + window.clearTimeout(timeoutID);
407 +
408 + goActive();
409 + }
410 +
411 + function goInactive() {
412 + if(wpChatBotVar.ret_inactive_user_once==1 && $.cookie('return_inactive_user')!='yes') {
413 + $.cookie('return_inactive_user','yes');
414 + var data = {'action': 'qcld_wb_chatbot_only_cart'};
415 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
416 + if (response.items > 0) {
417 + if ($('.active-chat-board').length == 0) {
418 + setTimeout(function () {
419 + $('#wp-chatbot-ball').removeClass('wpbot_chatclose_iconanimation');
420 + $('#wp-chatbot-ball').addClass('wpbot_chatopen_iconanimation');
421 + if (wpbotIconVideo !== '') {
422 + $('#wp-chatbot-ball-icon-video').hide();
423 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png').show();
424 + } else {
425 + $('#wp-chatbot-ball').find('img').attr('src', wpChatBotVar.imgurl+'wpbot-close-icon.png');
426 + }
427 + $("#wp-chatbot-board-container").addClass('active-chat-board');
428 + wpwbot_board_action();
429 + showing_proactive_msg(wpChatBotVar.checkout_msg);
430 + setTimeout(function () {
431 + showing_proactive_msg(response.html);
432 + //Window foucus meta title change.
433 + window_focus_change_meta_title();
434 + }, 2000);
435 + }, 2000);
436 + }
437 + }
438 + });
439 + }else{
440 + $.cookie('return_inactive_user','yes');
441 + }
442 + }
443 +
444 + function goActive() {
445 + // do something
446 +
447 + startTimer();
448 + }
449 + }
450 + //Proactive retargeting sound for auto open. scroll open and
451 + function proactive_retargeting_sound() {
452 + if(wpChatBotVar.enable_ret_sound==1){
453 + var promise = document.querySelector('#wp-chatbot-proactive-audio').play();
454 + if (promise !== undefined) {
455 + promise.then(function (success) {
456 + //success to play
457 + }).catch(function (error) {
458 + //some error
459 + //console.log(error);
460 + });
461 + }
462 + }
463 + }
464 +
465 + //When user will be out of window and news retargetting will be shown. where opening hour, title and meta need to be set.
466 + function window_focus_change_meta_title() {
467 + if(wpChatBotVar.enable_meta_title==1 && wpChatBotVar.meta_label!="" && openingHourIs==0) {
468 + var showInactive = 0;
469 + MetaTitleInterval = setInterval(function () {
470 + if (showInactive == 0) {
471 + document.title = wpChatBotVar.meta_label;
472 + showInactive = 1;
473 + } else {
474 + document.title = orginalTitle;
475 + showInactive = 0;
476 + }
477 + }, 1000);
478 + }
479 + }
480 +
481 + //wpwBot proActive end
482 + function wpwbot_board_action() {
483 + var currentW = $(window).width();
484 + var isBoardOpen = $('#wp-chatbot-board-container').hasClass('active-chat-board');
485 + if (currentW <= 480 && wpChatBotVar.mobile_full_screen==1 && isBoardOpen) {//For mobile
486 + if ($('#wp-chatbot-mobile-close').length <= 0) {
487 + $('.wp-chatbot-board-container').append('<div id="wp-chatbot-mobile-close">X</div>');
488 + }
489 + $('.wp-chatbot-ball-inner').slimScroll({
490 + height: '100hv',
491 + start: 'bottom'
492 + });
493 + wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
494 + $('#wp-chatbot-chat-container').addClass('wp-chatbot-mobile-fs-open').css({
495 + 'bottom': '0',
496 + 'left': '0',
497 + 'right': '0',
498 + 'width': '100%',
499 + 'max-width': '100%'
500 + });
501 + $('#wp-chatbot-board-container').css({'width': '100%', 'max-width': '100%'});
502 + $('#wp-chatbot-ball').hide();
503 + //Maintain inner chat box height
504 + var widowH = $(window).height();
505 + var headerH = $('.wp-chatbot-header').outerHeight();
506 + var footerH = $('.wp-chatbot-footer').outerHeight();
507 + var AppContentInner = widowH - footerH - headerH;
508 + //alert(footerH);
509 + $('.wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
510 + $('.wp-chatbot-ball-inner').css({'max-height': AppContentInner + 'px'})
511 + $(this).hide();
512 + } else {
513 + if (!isBoardOpen) {
514 + $('#wp-chatbot-chat-container').removeClass('wp-chatbot-mobile-fs-open');
515 + }
516 + // $('.wp-chatbot-header').append('<div id="wp-chatbot-desktop-close"><span class="dashicons dashicons-no"></span></div>');
517 + $('.wp-chatbot-ball-inner').slimScroll({
518 + height: '55hv',
519 + start: 'bottom'
520 + });
521 + wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
522 + }
523 +
524 +
525 + //Here is the Plugin to be load only for once.
526 + if (LoadwpwBotPlugin == 0) {
527 + $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler, preLoadingTime: wpChatBotVar.botpreloadingtime});
528 + LoadwpwBotPlugin++;
529 + var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
530 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
531 + //
532 + });
533 + }
534 + //If product detials is open then it will be closed.
535 + $('.wp-chatbot-product-container').removeClass('active-chatbot-product-details');
536 + //Show and close notification message on ball click
537 + if ($('.active-chat-board').length != 0) {
538 + $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-sliding');
539 + //chatbox will be open and notificaion will be closed
540 + $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
541 + //clearInterval(notificationInterval);
542 + } else {
543 + if (!sessionStorage.getItem('wpChatbotNotification')) {
544 + $('#wp-chatbot-notification-container').removeClass('wp-chatbot-notification-container-disable');
545 + $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
546 +
547 + }
548 + /// clearInterval(notificationInterval);
549 + }
550 + //Messenger handling.
551 + if ($('.active-chat-board').length > 0) {
552 + $('#wp-chatbot-integration-container').show();
553 + } else {
554 + $('#wp-chatbot-integration-container').hide();
555 + }
556 + }
557 + function showing_proactive_msg(msg){
558 + var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
559 + var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
560 + var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
561 + var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
562 + var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
563 + var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
564 + var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
565 + console.log(globalwpw.settings);
566 + console.log(enableleReactions);
567 + //first open then chatboard
568 + if(localStorage.getItem("wpwHitory") && ! $('.wp-chatbot-operation-option[data-option="chat"]').parent().hasClass('wp-chatbot-operation-active')){
569 + $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
570 + $('.wp-chatbot-operation-option').each(function(){
571 + if($(this).attr('data-option')=='chat'){
572 + $(this).parent().addClass('wp-chatbot-operation-active');
573 + }else{
574 + $(this).parent().removeClass('wp-chatbot-operation-active');
575 + }
576 + });
577 + }
578 + var msgContent='<li class="wp-chatbot-msg">' +
579 + '<div class="wp-chatbot-avatar">'+
580 + '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
581 + '</div>'+
582 + '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
583 + +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
584 + '<div class="qcld-like-dislike-icon">' +
585 + (enableleReactions == 1
586 + ? '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>' +
587 + '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up" ></i></a>'
588 + : '') +
589 +
590 + (eanleeReport == 1
591 + ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
592 + : '') +
593 +
594 + (enableshare == 1
595 + ? '<div class="qcld-share">' +
596 + '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share" aria-hidden="true"></i></a>' +
597 + '<div class="share-menu" style="display:none;">' +
598 + '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
599 + '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
600 + '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
601 + '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
602 + '</div>' +
603 + '</div>'
604 + : '') +
605 + '</div>' +
606 + '</li>';
607 +
608 + $('#wp-chatbot-messages-container').append(msgContent);
609 + //Scroll to the last message
610 + $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
611 + setTimeout(function(){
612 + $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(msg).css({'background-color':wpChatBotVar.proactive_bg_color});
613 + //scroll to the last message
614 + $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
615 + }, 2000);
616 + }
617 + function showing_proactive_double_msg(secondMsg) {
618 + var enableleReactions = globalwpw.settings.obj.skip_chat_reactions_menu;
619 + var eanleeReport = globalwpw.settings.obj.enable_chat_report_menu;
620 + var enableshare = globalwpw.settings.obj.enable_chat_share_menu;
621 + var likeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_like_text;
622 + var disLikeTxt = globalwpw.settings.obj.qlcd_wp_chatbot_dislike_text;
623 + var reportTxt = globalwpw.settings.obj.qlcd_wp_chatbot_report_text;
624 + var sharetTxt = globalwpw.settings.obj.qlcd_wp_chatbot_share_text;
625 + console.log(globalwpw.settings);
626 + console.log(enableleReactions);
627 + //first open then chatboard
628 + if(localStorage.getItem("wpwHitory")){
629 + $('.wp-chatbot-messages-wrapper').html(localStorage.getItem("wpwHitory"));
630 + $('.wp-chatbot-operation-option').each(function(){
631 + if($(this).attr('data-option')=='chat'){
632 + $(this).parent().addClass('wp-chatbot-operation-active');
633 + }else{
634 + $(this).parent().removeClass('wp-chatbot-operation-active');
635 + }
636 + });
637 + }
638 + var fristMsg="<strong>"+wpChatBotVar.agent+" </strong> "+wpChatBotVar.agent_join[0];
639 + var msgContent='<li class="wp-chatbot-msg">' +
640 + '<div class="wp-chatbot-avatar">'+
641 + '<img src="'+wpChatBotVar.agent_image_path+'" alt="">'+
642 + '</div>'+
643 + '<div class="wp-chatbot-agent">'+ wpChatBotVar.agent+'</div>'
644 + +'<div class="wp-chatbot-paragraph"><img class="wp-chatbot-comment-loader" src="'+wpChatBotVar.image_path+'comment.gif" alt="Typing..." /></div>'+
645 + '<div class="qcld-like-dislike-icon">' +
646 + (enableleReactions == 1
647 + ? '<a href="#" title="' + (disLikeTxt?.en_US || 'Dislike') + '"><i class="dashicons dashicons-thumbs-down"></i></a>' +
648 + '<a href="#" title="' + (likeTxt?.en_US || 'Like') + '"><i class="dashicons dashicons-thumbs-up"></i></a>'
649 + : '') +
650 +
651 + (eanleeReport == 1
652 + ? '<a href="#" title="' + (reportTxt?.en_US || 'Report') + '"><i class="dashicons dashicons-admin-comments"></i></a>'
653 + : '') +
654 +
655 + (enableshare == 1
656 + ? '<div class="qcld-share">' +
657 + '<a href="#" class="share-toggle" title="' + (sharetTxt?.en_US || 'Share') + '"><i class="dashicons dashicons-share"></i></a>' +
658 + '<div class="share-menu" style="display:none;">' +
659 + '<a href="#" class="share-fb"><i class="dashicons dashicons-facebook"></i></a>' +
660 + '<a href="#" class="share-wa"><i class="dashicons dashicons-whatsapp"></i></a>' +
661 + '<a href="#" class="share-x"><i class="dashicons dashicons-twitter"></i></a>' +
662 + '<a href="#" class="share-email"><i class="dashicons dashicons-email-alt"></i></a>' +
663 + '</div>' +
664 + '</div>'
665 + : '') +
666 + '</div>' +
667 + '</li>';
668 + $('#wp-chatbot-messages-container').append(msgContent);
669 + //Scroll to the last message
670 + $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
671 +
672 + setTimeout(function(){
673 + $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(fristMsg);
674 + //Second Message with interval
675 + $('#wp-chatbot-messages-container').append(msgContent);
676 + //Scroll to the last message
677 + $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
678 + setTimeout(function(){
679 + $('#wp-chatbot-messages-container li:last .wp-chatbot-paragraph').html(secondMsg).css({'background-color':wpChatBotVar.proactive_bg_color});
680 + //Scroll to the last message
681 + $('.wp-chatbot-ball-inner').animate({ scrollTop: $('.wp-chatbot-messages-wrapper').prop("scrollHeight")}, 'slow', function () { wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner')); });
682 +
683 + }, 2000);
684 +
685 + }, 2000);
686 + }
687 + $(document).on('click', '#wp-chatbot-mobile-close, #wp-chatbot-desktop-close', function (event) {
688 + var $boardContainer = $("#wp-chatbot-board-container");
689 + if ($boardContainer.hasClass('active-chat-board')) {
690 + $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-anim');
691 + void $boardContainer[0].offsetWidth;
692 + $boardContainer.addClass('wp-chatbot-close-anim');
693 + setTimeout(function () {
694 + $boardContainer.removeClass('active-chat-board wp-chatbot-close-anim');
695 + }, 280);
696 + }
697 + $("#wp-chatbot-notification-container").removeClass('wp-chatbot-notification-container-disable').addClass('wp-chatbot-notification-container-sliding');
698 + $('#wp-chatbot-chat-container').removeClass('wp-chatbot-mobile-fs-open').css({
699 + 'right': wpChatBotVar.wp_chatbot_position_x + 'px',
700 + 'bottom': wpChatBotVar.wp_chatbot_position_y + 'px',
701 + 'top': 'auto', 'left': 'auto',
702 + 'width': '', 'max-width': ''
703 + });
704 + $('#wp-chatbot-board-container').css({'width': '', 'max-width': ''});
705 + // Restore icon: show video OR image when chat is closed via X button
706 + if (wpbotIconVideo !== '') {
707 + $('#wp-chatbot-ball').find('img#wp-chatbot-ball-icon-img').attr('src', botimage).hide();
708 + $('#wp-chatbot-ball-icon-video').show();
709 + } else {
710 + $('#wp-chatbot-ball').find('img').attr('src', botimage);
711 + }
712 + $('.wp-chatbot-ball').css('background', '#ffffff');
713 + $('#wp-chatbot-ball').show();
714 + //Facebook Messenger.
715 + if ($('.active-chat-board').length > 0) {
716 + $('#wp-chatbot-integration-container').show();
717 + } else {
718 + $('#wp-chatbot-integration-container').hide();
719 + }
720 + });
721 + function wpbotSyncExpandIconState() {
722 + var $boardContainer = $('#wp-chatbot-board-container');
723 + var isExpanded = $boardContainer.hasClass('wp-chatbot-expanded');
724 + $('#wp-chatbot-desktop-expand').attr('title', isExpanded ? 'Collapse' : 'Expand').find('span')
725 + .removeClass('dashicons dashicons-fullscreen-exit-alt')
726 + .addClass('dashicons ' + (isExpanded ? 'dashicons-editor-contract' : 'dashicons-editor-expand'));
727 + }
728 +
729 + wpbotSyncExpandIconState();
730 +
731 + $(document).on('click', '#wp-chatbot-desktop-expand', function (event) {
732 + event.preventDefault();
733 + var $boardContainer = $('#wp-chatbot-board-container');
734 + // Size toggle only — CSS width/height transition. No opacity/scale anims (they flash white).
735 + $boardContainer.removeClass('wp-chatbot-open-anim wp-chatbot-expand-anim wp-chatbot-collapse-anim wp-chatbot-close-anim');
736 + $boardContainer.toggleClass('wp-chatbot-expanded');
737 + wpbotSyncExpandIconState();
738 + // Keep slimScroll in sync after height change
739 + setTimeout(function () {
740 + var $inner = $boardContainer.find('.wp-chatbot-ball-inner');
741 + if (!$inner.length || !$inner[0]) {
742 + return;
743 + }
744 + var computedH = window.getComputedStyle($inner[0]).height;
745 + if (computedH) {
746 + $inner.slimScroll({ height: computedH, start: 'bottom' });
747 + wpbotSyncSlimScrollBar($inner);
748 + }
749 + }, 40);
750 + });
751 +
752 +
753 + $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
754 + /***
755 + * Notification Message
756 + */
757 + if ($('#wp-chatbot-notification-container').length > 0) {
758 + if (sessionStorage.getItem('wpChatbotNotification') && sessionStorage.getItem('wpChatbotNotification') == 'removed') {
759 + //if remove on the session.
760 + $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
761 + } else {
762 + //Notification comes with slideIn effect
763 + $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-sliding');
764 + //handling welcome & return user welcome msg.
765 + if ($.cookie("shopper")) {
766 + var shopper = $.cookie("shopper");
767 + var welcomeMsg = wpChatBotVar.welcome_back[0] + ' <strong>' + shopper + '!</strong>';
768 + } else {
769 + var welcomeMsg = wpChatBotVar.welcome[0] + ' <strong>' + wpChatBotVar.host + '!</strong>';
770 +
771 + }
772 + $('.wp-chatbot-notification-welcome').html(welcomeMsg);
773 + //Notifications msgs handling.
774 + var notifications = wpChatBotVar.notifications;
775 + if (notifications.length > 1) {
776 + var totalNotMsg = wpChatBotVar.notifications.length;
777 + var notMsgIndex = 0;
778 + var intervalTime = parseInt(wpChatBotVar.notification_interval) * 1000;
779 + var notificationInterval = setInterval(function (e) {
780 + notMsgIndex++;
781 + if (totalNotMsg <= notMsgIndex) {
782 + notMsgIndex = 0;
783 + }
784 + //show new notification time after every intervalTime
785 + $('.wp-chatbot-notification-message').css({'opacity': 1}).html(notifications[notMsgIndex]);
786 + }, intervalTime);
787 + }
788 +
789 + $(".wp-chatbot-notification-close").click(function () {
790 + $('#wp-chatbot-notification-container').addClass('wp-chatbot-notification-container-disable');
791 + //clearInterval(notificationInterval);
792 + sessionStorage.setItem('wpChatbotNotification', 'removed');
793 + });
794 + }
795 + }
796 + }
797 + else if ($('#wp-chatbot-shortcode-template-container').length > 0) { //Page shortcode area.
798 + $('#wp-chatbot-chat-container').css({'display': 'none'});
799 + $('#wp-chatbot-ball').hide();
800 + //Add Scroll to chat ui
801 + $('.wp-chatbot-ball-inner').slimScroll({
802 + height: '60hv',
803 + start: 'bottom'
804 + });
805 + wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
806 + //Add scroll to cart part
807 + var recentViewHeight = $('.wp-chatbot-container').outerHeight();
808 + if ($('.chatbot-shortcode-template-02').length == 0) {
809 + $('.wp-chatbot-cart-body').slimScroll({height: '200px', start: 'top'});
810 + $('.wp-chatbot-widget .wp-chatbot-products').slimScroll({height: '435px', start: 'top'});
811 + }
812 +
813 + //Remove style of template
814 + $("#qcld-wp-chatbot-style-css").attr("disabled", "disabled");
815 + //Here is the Plugin to be load only for once.
816 + if (LoadwpwBotPlugin == 0) {
817 + $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
818 + LoadwpwBotPlugin++;
819 + var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
820 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
821 + //
822 + });
823 + }
824 +
825 +
826 + }
827 + else if ($('#wp-chatbot-chat-app-shortcode-container').length > 0) { //App shortcode area.
828 +
829 + textEditorHandler = 1;
830 + //App UI (ball inner)
831 + setTimeout(function () {
832 + var widowH = $(window).height();
833 + //var headerH = $('.wp-chatbot-header').outerHeight();
834 + var footerH = $('.wp-chatbot-footer').outerHeight();
835 +
836 + var AppContentInner = widowH - footerH;
837 + //alert(footerH);
838 + $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
839 + }, 300);
840 + $(window).resize(function () {
841 + setTimeout(function () {
842 + var widowH = $(window).height();
843 + //var headerH = $('.wp-chatbot-header').outerHeight();
844 + var footerH = $('.wp-chatbot-footer').outerHeight();
845 + var AppContentInner = widowH - footerH;
846 + //alert(footerH);
847 + $('#wp-chatbot-chat-app-shortcode-container .wp-chatbot-ball-inner').css({'height': AppContentInner + 'px'})
848 + }, 300)
849 + });
850 +
851 + $('#wp-chatbot-ball').hide();
852 + //Add Scroll to chat ui
853 + $("#qcld-wp-chatbot-shortcode-style-css").attr("disabled", "disabled");
854 + $("#wp-chatbot-board-container").addClass('active-chat-board');
855 + $('.wp-chatbot-ball-inner').slimScroll({
856 + height: '55hv',
857 + start: 'bottom'
858 + }).parent();
859 + wpbotSyncSlimScrollBar($('.wp-chatbot-ball-inner'));
860 + if (LoadwpwBotPlugin == 0) {
861 + $.wpwbot({obj: wpChatBotVar, editor_handler: textEditorHandler});
862 + LoadwpwBotPlugin++;
863 + var data = {'action': 'qcld_wb_chatbot_session_count', 'nonce': wpChatBotVar.session_nonce};
864 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
865 + //
866 + });
867 + }
868 + //Handling app cart and checkout
869 + $('#wp-chatbot-cart-short-code').hide();
870 + $('#wp-chatbot-checkout-short-code').hide();
871 + $(document).on('click', '.wp-chatbot-cart-link', function (event) {
872 + $('.wp-chatbot-messages-wrapper').hide();
873 + $('#wp-chatbot-checkout-short-code').hide();
874 + $('#wp-chatbot-cart-short-code').show();
875 + event.preventDefault();
876 + $('#wp-chatbot-cart-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
877 + var data = {'action': 'qcld_wb_chatbot_cart_page'};
878 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
879 + $("#wp-chatbot-cart-short-code").html(response);
880 + });
881 + });
882 + $(document).on('click', '.wp-chatbot-checkout-link, .checkout-button', function (event) {
883 + event.preventDefault();
884 + $('.wp-chatbot-messages-wrapper').hide();
885 + $('#wp-chatbot-cart-short-code').hide();
886 + $('#wp-chatbot-checkout-short-code').show();
887 +
888 +
889 + $('#wp-chatbot-checkout-short-code').html('<img class="wp-chatbot-comment-loader" src="' + wpChatBotVar.image_path + 'comment.gif" alt="..." />');
890 + var data = {'action': 'qcld_wb_chatbot_checkout_page'};
891 + jQuery.post(wpChatBotVar.ajax_url, data, function (response) {
892 + if (response.status == 'yes') {
893 + window.location.href = response.html;
894 + } else {
895 + $("#wp-chatbot-checkout-short-code").html(response.html);
896 + }
897 +
898 + });
899 + });
900 + //Preventing url redirect from cart page.
901 + $(document).on('click', '#wp-chatbot-chat-app-shortcode-container .wpcommerce-cart-form a', function (e) {
902 + e.preventDefault();
903 + });
904 + }
905 + //For variable product configuration
906 + $(document).on('change', "#wp-chatbot-product-variable select ", function () {
907 + var variations = JSON.parse($("#wp-chatbot-variation-data").attr('data-product-variation'));
908 + var item_conditions = [];
909 +
910 + var totalAttr = $("#wp-chatbot-product-variable select").length;
911 + var i = 1;
912 + $("#wp-chatbot-product-variable select").each(function (index, element) {
913 + var myVal = $(this).find('option:selected').val();
914 + if (myVal != "") {
915 + item_conditions.push({
916 + 'left': 'item["variation_data"]["' + $(this).attr('name') + '"][0]',
917 + 'right': myVal
918 + })
919 + }
920 + });
921 + var newVariation = [];
922 + for (var a = 0; variations.length > a; a++) {
923 + var item = variations[a];
924 + var item_condition = "";
925 + for (var i = 0; item_conditions.length > i; i++) {
926 +
927 + if (i > 0) {
928 + item_condition += ' && ' + '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
929 + } else {
930 + item_condition += '"' + eval(item_conditions[i].left).toLowerCase() + '"' + '==' + '"' + item_conditions[i].right.toLowerCase() + '"';
931 + }
932 + }
933 + if (eval(item_condition)) {
934 + newVariation[0] = item;
935 + }
936 + }
937 + if (newVariation.length > 0) {
938 + $('#wp-chatbot-variation-add-to-cart').attr('variation_id', newVariation[0]['variation_id']);
939 + var priceSets = "";
940 + if (newVariation[0]['variation_data']['_sale_price'][0] != "") {
941 + priceSets += '<strike>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strike> <strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_sale_price'][0] + '</strong>'
942 + } else {
943 + priceSets += '<strong>' + wpChatBotVar.currency_symbol + newVariation[0]['variation_data']['_regular_price'][0] + '</strong>';
944 + }
945 + $('#wp-chatbot-product-price').html(priceSets);
946 + }
947 + });
948 +
949 + if ($('.active-chat-board').length > 0) {
950 + $('#wp-chatbot-integration-container').show();
951 + } else {
952 + $('#wp-chatbot-integration-container').hide();
953 + }
954 + //Facebook Messenger Integration
955 + /* if(wpChatBotVar.enable_messenger == 1){
956 + $(document).on('click','.fb_dialog',function (e) {
957 + $('#wp-chatbot-board-container').removeClass('active-chat-board');
958 + $('.fb_dialog').css({'display': 'inline'});
959 + setTimeout(function (e) {
960 + $('.fb-customerchat >span').css({'display': 'inline'});
961 + $('.fb_dialog').trigger('click'); //.css({'display': 'none'});
962 + },300);
963 + $('#wp-chatbot-integration-container').hide();
964 + });
965 + }*/
966 + //skype
967 + if (wpChatBotVar.enable_skype == 1) {
968 + $(document).on('click', '.inetegration-skype-btn', function (e) {
969 + $('#wp-chatbot-board-container').removeClass('active-chat-board');
970 + // $('.lwc-button-icon').trigger('click');
971 + $('#wp-chatbot-integration-container').hide();
972 + });
973 +
974 + }
975 +
976 +
977 + });
978 +
979 +});