| 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 |
}); |
| 866 |
|