1/** 2 * Custom JavaScript code 3 */ 4 5// Preloader 6window.addEventListener('load', function () { 7 document.body.classList.add('preloaderdone'); 8}); 9 10window.setTimeout(function () { 11 document.body.classList.add('preloaderdone'); 12}, 1250); 13 14 15 16(function ($) { 17 $(document).ready(function () { 18 console.log('custom-alt.js loaded'); 19 20 21 22 /* Filter boxes */ 23 $('.filter-box-title').click(function () { 24 $('.filter-box-content').slideToggle(); 25 if ($('.filter-box-content').css('display') == 'none') { 26 $('.filter-box-title .widget-title').addClass('widget-closed'); 27 } else { 28 $('.filter-box-title .widget-title').removeClass('widget-closed'); 29 } 30 }); 31 32 /* Attribute filter boxes */ 33 $('.woocommerce-widget-layered-nav-list').each(function () { 34 var list = $(this).find('.woocommerce-widget-layered-nav-list__item--chosen '); 35 if (list.length > 0) { 36 $(this).slideDown(); 37 $(this).prev().addClass('widget-closed'); 38 39 } 40 }); 41 42 $('.widget-title').on('click', function () { 43 var parent_id = '#' + $(this).parent().attr('id'); 44 45 if ($(parent_id + ' .woocommerce-widget-layered-nav-list').css('display') == 'none') { 46 $(parent_id + ' .woocommerce-widget-layered-nav-list').slideDown(); 47 $(this).addClass('widget-closed'); 48 } else { 49 $(this).removeClass('widget-closed'); 50 $(parent_id + ' .woocommerce-widget-layered-nav-list').slideUp(); 51 } 52 }); 53 54 $('.sub-cat-toggle-btn, .sub-sub-cat-toggle-btn').on('click', function (e) { 55 e.preventDefault(); 56 var sub_cat = $(this).data('target'); 57 58 $(sub_cat + '.subcategory-listing').slideToggle(); 59 }); 60 $('.subcategory-listing').each(function () { 61 var active_sub_cat = $(this).find('.active'); 62 if (active_sub_cat.length > 0) { 63 $(this).slideDown(); 64 } 65 }) 66 67 $('.see-more').on('click', function (e) { 68 e.preventDefault(); 69 $('.collapsed-category').slideToggle() 70 $(this).hide(); 71 $('.see-less').show(); 72 }); 73 74 $('.see-less').on('click', function (e) { 75 e.preventDefault(); 76 $('.collapsed-category').slideToggle() 77 $(this).hide(); 78 $('.see-more').show(); 79 }) 80 81 82 83 /* Quantity increase / decrease */ 84 $("body").on("click", ".qty-selector input[type='button']", function () { 85 var qtyBox_parent = $(this).parent(); 86 var qtyToUpdate = "#" + qtyBox_parent.find('.qty').attr('id'); 87 var qty = parseInt($(qtyToUpdate).val()); 88 89 if ($(this).hasClass('qty-increase')) { 90 $(qtyToUpdate).val(qty + 1); 91 } else if ($(this).hasClass('qty-decrease')) { 92 if (qty > 1) { 93 $(qtyToUpdate).val(qty - 1); 94 } 95 } 96 if ($('body').hasClass('woocommerce-cart')) { 97 $('.qty').trigger('change'); 98 } 99 }); 100 101 102 /* For tabs */ 103 $('#tab-description').addClass('active-tab'); 104 $('.yi-tab .tablinks').on('click', function () { 105 var tabToOpen = $(this).data('target'); 106 console.log(tabToOpen); 107 $('.tablinks').removeClass('active'); 108 $(this).addClass('active'); 109 $('.wc-tab').removeClass('active-tab'); 110 $("#" + tabToOpen).addClass('active-tab'); 111 }); 112 113 114 /* Quick order popup */ 115 $('.add-more-item').on('click', function (e) { 116 e.preventDefault(); 117 var htmlToAdd = '<div class="item-group row mx-auto"><div class="col-7"><input type="text" class="form-group item-code" name="item-code" onkeyup="searchItem(this.value);" placeholder="Item code"></div><div class="col-2 p-0"><input type="number" min="1" class="form-group item-qty" name="item-qty" placeholder="Qty"></div></div>'; 118 $('.quick-order-items').append(htmlToAdd); 119 }); 120 121 $('.menu-item-175, .menu-item-16183').on('click', function (e) { 122 e.preventDefault(); 123 $('.yi-quick-order-popup').show(); 124 }); 125 $('.close-btn').on('click', function (e) { 126 e.preventDefault(); 127 $('.yi-quick-order-popup').hide(); 128 }); 129 130 131 /* Related products on PDP */ 132 $('.similar-product-slick').slick({ 133 dots: false, 134 infinite: false, 135 slidesToShow: 5, 136 slidesToScroll: 2, 137 appendArrows: $('#featured-slider-arrows'), 138 centerMode: false, 139 responsive: [{ 140 breakpoint: 768, 141 settings: { 142 slidesToShow: 1 143 } 144 }] 145 }); 146 147 /* Order confirmation page view order details section */ 148 $('body').on('click', '.view-order-btn', function (e) { 149 e.preventDefault(); 150 var order_to_show = $(this).data('target'); 151 152 $(order_to_show).slideToggle(); 153 $(order_to_show).toggleClass('open'); 154 155 if ($(order_to_show).hasClass('open')) { 156 /// $(this).text('Hide details'); 157 $(this).parents('.woocommerce-order-overview__order').addClass('active'); 158 } else { 159 /// $(this).text('View details'); 160 $(this).parents('.woocommerce-order-overview__order').removeClass('active'); 161 } 162 163 }); 164 165 /** Update Cart page */ 166 var timeout; 167 jQuery('body').on('change keyup mouseup', 'input.qty', function () { 168 if (timeout != undefined) clearTimeout(timeout); 169 if (jQuery(this).val() == '') return; 170 timeout = setTimeout(function () { 171 jQuery('[name="update_cart"]').trigger('click'); 172 }, 1000); 173 }); 174 175 $('body').on('click', '.apply_coupon-btn', function () { 176 $('#coupon_code').val($('#_coupon_code').val()); 177 $('[name="apply_coupon"]').trigger('click'); 178 }); 179 180 /** List Management */ 181 182 /* Disable Add to list button if variations are not selected 183 if (typeof $('input[name="variation_id"]').val() !== undefined) { 184 if ($('input[name="variation_id"]').val() == '0') { 185 $('.yi-add-to-list-btn').attr('disabled', true); 186 } 187 } 188 $(".single_variation_wrap").on("show_variation", function (event, variation) { 189 if ($('input[name="variation_id"]').val() != '0') { 190 $('.yi-add-to-list-btn').attr('disabled', false); 191 } 192 }); */ 193 194 /* Hide list box */ 195 $('.add-product-list-content .close').on('click', function (e) { 196 e.preventDefault(); 197 $('#addListPopup').hide(); 198 199 // Let's get Back UI to default state 200 $('.add-product-list-body .ajax-response').text(""); 201 $('.save_btn').removeClass('save-create-list-btn'); 202 $('.save_btn').addClass('save-list-btn'); 203 $('.save_btn').text('Save'); 204 $('.create-list-btn').show(); 205 $("#listname-input").hide(); 206 207 }); 208 209 /* Show list box */ 210 $('body').on('click', '.yi-add-to-list-btn', function (e) { 211 e.preventDefault(); 212 if (wordpress_user != '') { 213 // Check if current product is variable 214 if ($('.product-type-variable').length) { 215 if ($('input[name="variation_id"]').val() == '0') { 216 alert('Select product variation to add to list'); 217 } else { 218 $('#addListPopup').show(); 219 } 220 } else { 221 // Show popup for simple product 222 $('#addListPopup').show(); 223 } 224 } else { 225 alert('Please login to create lists'); 226 } 227 228 }); 229 230 var listToAdd = {}; 231 232 /* Add Item to existing list */ 233 $('body').on('click', '.shopping-list-item', function () { 234 $('.shopping-list-item').removeClass('active'); // Unselect other lists. 235 236 $(this).addClass('active'); // Mark current list as selected. 237 var product_id = $('.single_add_to_cart_button').val(); 238 if (!product_id) { 239 if (typeof $('input[name="variation_id"]').val() !== undefined) { 240 product_id = $('input[name="variation_id"]').val(); 241 } 242 } 243 var list_id = $(this).data('listid'); 244 listToAdd = { 245 'action': 'add_item_shop_list', 246 'list_id': list_id, 247 'item': product_id 248 } 249 if ($('.save_btn').hasClass('.save-create-list-btn')) { 250 // No need to create list if user selects list 251 $('.save_btn').removeClass('.save-create-list-btn'); 252 } 253 254 }); 255 256 /* Ajax call to add item in existing list */ 257 $('body').on('click', '.save-list-btn', function (e) { 258 e.preventDefault(); 259 if (listToAdd) { 260 $.ajax({ 261 type: 'POST', 262 url: ajaxurl, 263 data: listToAdd, 264 dataType: 'json', 265 success: function (data) { 266 if (data.status == 'success') { 267 $('.add-product-list-body .ajax-response').text(data.msg); 268 $('.add-product-list-body .ajax-response').removeClass('error'); 269 } else { 270 $('.add-product-list-body .ajax-response').text(data.msg) 271 $('.add-product-list-body .ajax-response').addClass('error'); 272 } 273 } 274 }); 275 } else { 276 $('.add-product-list-body .ajax-response').text('Please select list'); 277 $('.add-product-list-body .ajax-response').addClass('error'); 278 } 279 }); 280 281 /* Ajax call to remove item from list */ 282 $('body').on('click', '.my-list-close-icon span', function (e) { 283 e.preventDefault(); 284 console.log("Delete item called"); 285 var product_id = $(this).data('productid'); 286 var list_id = $(this).data('listid'); 287 var formData = { 288 'action': 'remove_item_shop_list', 289 'list_id': list_id, 290 'item': product_id 291 } 292 console.log(formData); 293 const response = confirm("Are you sure you want to delete this product from list?"); 294 if (response) { 295 $.ajax({ 296 type: 'POST', 297 url: ajaxurl, 298 data: formData, 299 dataType: 'json', 300 success: function (data) { 301 if (data.status == 'success') { 302 $("#product-" + product_id).fadeOut(300); 303 } else { 304 alert(data.msg) 305 } 306 } 307 308 }); 309 } 310 }); 311 312 $("body").on("click", ".create-list-btn", function (e) { 313 e.preventDefault(); 314 var total_no_of_lists = $(".total_lists").val(); 315 if (total_no_of_lists < 50) { 316 $("#listname-input").fadeIn(); 317 $(".save_btn").addClass("save-create-list-btn"); 318 $(".save_btn").removeClass("save-list-btn"); 319 $(".save_btn").text("Add & Save"); 320 $(this).fadeOut(); 321 } else { 322 alert( 323 "Whoops! You've reach the maximum number of lists allowed. Please delete a list before creating a new one. Thank y
323ou!" 324 ); 325 } 326 }); 327 328 $('body').on('click', '.save-create-list-btn', function (e) { 329 e.preventDefault(); 330 331 if ($('.ajax-response').hasClass('error')) { 332 $('.ajax-response').removeClass('error'); 333 } 334 var list_name = $("#listname-input").val(); 335 var product_id = $('.single_add_to_cart_button').val(); 336 if (!product_id) { 337 if (typeof $('input[name="variation_id"]').val() !== undefined) { 338 product_id = $('input[name="variation_id"]').val(); 339 } 340 } 341 console.log('Prod ID:: ' + product_id) 342 343 var action = $(this).data('source'); 344 if(list_name.length == 50){ 345 console.log(list_name.length); 346 $('.ajax-response').text(list_name + ' is more than 50 characters'); 347 $('.ajax-response').addClass('error'); 348 return false; 349 } 350 var isDuplicate = false; 351 var is_valid = false; 352 $('.shopping-list-item').each(function () { 353 var temp = $(this).html(); 354 if (temp == list_name) { 355 isDuplicate = true; 356 return false; // Break loop 357 } 358 }); 359 if (list_name.length > 50) { 360 is_valid = true; 361 } 362 if (isDuplicate) { 363 $('.ajax-response').text(list_name + ' is already created'); 364 $('.ajax-response').addClass('error'); 365 } else if (is_valid) { 366 $(".ajax-response").text( 367 "List Name should be less than 50 characters." 368 ); 369 $(".ajax-response").addClass("error"); 370 } else { 371 var formData = { 372 'action': 'create_shop_list', 373 'list_name': list_name, 374 'username': wordpress_user, 375 'list_item': product_id 376 } 377 if (list_name) { 378 $.ajax({ 379 type: 'POST', 380 url: ajaxurl, 381 data: formData, 382 dataType: 'json', 383 success: function (data) { 384 if (data.status == 'success') { 385 var html = "<li class='shopping-list-item' data-listid='" + data.list_id + "'>" + list_name + "</li>" 386 $('.user-shopping-lists').append(html); 387 $('.no-list-found').fadeOut(); 388 if ($('body').hasClass('single-product')) { 389 $('.ajax-response').text('New List created and products added to list '); 390 $('#listname-input').val(''); 391 } else { 392 $('#listname-input').val(''); 393 $('.ajax-response').text('New List created'); 394 window.location.reload(); 395 } 396 } else { 397 $('.add-product-list-body .ajax-response').text(data.msg); 398 $('.ajax-response').addClass('error'); 399 } 400 } 401 402 }); 403 } else { 404 $('.add-product-list-body .ajax-response').text('Please enter list name'); 405 $('.ajax-response').addClass('error'); 406 } 407 } 408 }); 409 410 $('body').on('click', '.my-list-icon', function (e) { 411 e.preventDefault(); 412 }); 413 414 /* Service for list page - Add to cart AJAX */ 415 $('.yi-custom-add-to-cart').on('click', function (e) { 416 e.preventDefault(); 417 var prodcut_id = $(this).data('productid'); 418 var form_data = { 419 action: "yi_add_to_cart", 420 product_id: prodcut_id, 421 qty: 1 422 }; 423 var response_element = $(this).parent().find('.cart-ajax-response'); 424 var loader = $(this).find('.loader'); 425 loader.fadeIn(); 426 $.ajax({ 427 type: 'POST', 428 url: ajaxurl, 429 data: form_data, 430 dataType: 'json', 431 success: function (data) { 432 if (data.status == 'success') { 433 response_element.fadeIn(); 434 response_element.text('Added to cart'); 435 loader.fadeOut(); 436 } 437 } 438 }); 439 }); 440 441 /** Add Entire list to cart */ 442 jQuery(".add_product_list_to_cart").click(function () { 443 444 var loader = jQuery(this).find(".loader"); 445 var list_count = 0; 446 447 var list_products = []; 448 var list_products_qty = []; 449 var coupon = '';
450 coupon = jQuery(this).data('coupon'); 451 jQuery("#product-list-form tr").each(function () { 452 var product = jQuery(this).find(".yi-custom-add-to-cart"); 453 454// alert(product.data("productid")); 455// alert(product.data("productqty")); 456 if (product) { 457 list_products.push(product.data("productid")); 458 list_products_qty.push(product.data("productqty")); 459 } 460 }); 461 462 console.log(list_products); 463 var products_to_add = JSON.stringify(list_products); 464 var products_qty_to_add = JSON.stringify(list_products_qty); 465 466 var formData = { 467 action: "add_product_list_to_cart", 468 products: products_to_add, 469 products_qty: products_qty_to_add, 470 coupon: coupon 471 }; 472 jQuery.ajax({ 473 type: "POST", 474 url: ajaxurl, 475 data: formData, 476 dataType: "json", 477 beforeSend: function () { 478 loader.fadeIn(); 479 }, 480 success: function (data) { 481 console.log(data); 482 loader.fadeOut(); 483 if (data.status == "success") { 484 window.location.href = "/cart"; 485 } else { 486 alert(data.msg); 487 } 488 }, 489 }); 490 }); 491 492 /* Ajax call to delete entire LIST */ 493 $('body').on('click', '.delete-list-btn', function (e) { 494 e.preventDefault(); 495 const response = confirm("Are you sure you want to delete this list?"); 496 if (response) { 497 var listToDelete = $(this).data('listid'); 498 if (listToDelete) { 499 var formData = { 500 'action': 'delete_shop_list', 501 'list_id': listToDelete 502 } 503 $.ajax({ 504 type: 'POST', 505 url: ajaxurl, 506 data: formData, 507 dataType: 'json', 508 success: function (data) { 509 if (data.status == 'success') { 510 $('list-' + listToDelete).fadeOut(); 511 window.location.reload() 512 } else { 513 $('list-' + listToDelete).fadeOut(); 514 window.location.href = "/my-list" 515 } 516 } 517 518 }); 519 } 520 } 521 }); 522 523 /** Add Entire list to cart */ 524// $('.add_list_to_cart').on('click', function () { 525// var loader = $(this).find('.loader'); 526 527// var list_products = []; 528 529// $('.my-list-product-box').each(function () { 530 531// var product = $(this).find('.yi-custom-add-to-cart'); 532 533// if (product) { 534// list_products.push(product.data('productid')); 535// } 536 537// }); 538// var products_to_add = JSON.stringify(list_products); 539 540// var formData = { 541// action: 'add_list_to_cart', 542// products: products_to_add 543// } 544 545// $.ajax({ 546// type: 'POST', 547// url: ajaxurl, 548// data: formData, 549// dataType: 'json', 550// beforeSend: function () { 551// loader.fadeIn(); 552// }, 553// success: function (data) { 554// loader.fadeOut(); 555// if (data.status == 'success') { 556// window.location.href = '/cart'; 557// } 558// } 559 560// }); 561 562// }); 563 /** Add Entire list to cart */ 564 $(".add_list_to_cart").on("click", function () { 565 var loader = $(this).find(".loader"); 566 567 // if ($("#add_list_to_cart").is(":checked")) { 568 // alert($("input[type='checkbox']").val()); 569 // } 570 var list_array = [];var list_count = 0; 571 $("input:checkbox[name=list_id]:checked").each(function () { 572 list_array.push($(this).data("listid")); 573 list_count++; 574 }); 575 if(list_count<=5){ 576 if (list_count > 0) { 577 578 var lists_to_add = JSON.stringify(list_array); 579 var formData = { 580 action: "add_lists_to_cart", 581 lists: lists_to_add, 582 }; 583 } else { 584 var list_products = []; 585 586 $(".my-list-product-box").each(function () { 587 var product = $(this).find(".yi-custom-add-to-cart"); 588 589 if (product) { 590 list_products.push(product.data("productid")); 591 } 592 }); 593 var products_to_add = JSON.stringify(list_products); 594 595 var formData = { 596 action: "add_list_to_cart", 597 products: products_to_add, 598 }; 599 } 600 $.ajax({ 601 type: "POST", 602 url: ajaxurl, 603 data: formData, 604 dataType: "json", 605 beforeSend: function () { 606 loader.fadeIn(); 607 }, 608 success: function (data) { 609 loader.fadeOut(); 610 if (data.status == "success") { 611 window.location.href = "/cart"; 612 } else { 613 alert(data.msg); 614 } 615 }, 616 }); 617 }else{ 618 alert("You can select maximum 5 lists at a time."); 619 } 620 }); 621 /** Edit list functionality */ 622 $('body').on('click', '.edit-list-cta', function (e) { 623 e.preventDefault(); 624 625 //var parent = $(this).parents('.my-list-card'); 626 //var editInputField = parent.find('.edit-list-input'); 627 var editInputField = $(this).parent().parent().siblings().find(".edit-list-input"); 628 if (editInputField) { 629 editInputField.attr('readonly', false); 630 editInputField.addClass('editable'); 631 editInputField.focus(); 632 } 633 634 }); 635 $('body').on('click focus', '.my-list-card .edit-list-input.editable', function (e) { 636 e.preventDefault(); 637 }); 638 $('body').on('click', '.my-list-card .edit-list-submit', function (e) { 639 e.preventDefault(); 640 var currentEle = $(this); 641 var ele = $(this).parents('.my-list-card').find('.edit-list-input'); 642 var listNewName = ele.val(); 643 var listId = ele.data('listid'); 644 var formData = { 645 action: 'update_shop_list_name', 646 name: listNewName, 647 list_id: listId 648 } 649 console.log(formData); 650 if (listNewName.length > 18) { 651 alert("List Name should be less than 18 characters."); 652 } else { 653 $.ajax({ 654 type: 'POST', 655 url: ajaxurl, 656 data: formData, 657 dataType: 'json', 658 beforeSend: function () { 659 currentEle.removeClass('fa-check'); 660 currentEle.addClass('fa-spinner fa-spin'); 661 }, 662 success: function (data) { 663 currentEle.addClass('fa-check'); 664 currentEle.removeClass('fa-spinner fa-spin'); 665 ele.attr('readonly', true); 666 ele.removeClass('editable'); 667 } 668 669 }); 670 } 671 }); 672 673 674 /* Set Redirection Parameters for Login/Register on cart page*/ 675 if ($('body').hasClass('woocommerce-cart')) { 676 var old_url = $('#loginlink').attr('href'); 677 var newUrl = old_url + "?redirect_to=cart"; 678 $('#loginlink').attr('href', newUrl); 679 old_url = $('#registerlink').attr('href'); 680 newUrl = old_url + "?redirect_to=cart"; 681 $('#registerlink').attr('href', newUrl); 682 } 683 /* Set Redirection Parameters for Login/Register on checkout page*/ 684 if ($('body').hasClass('woocommerce-checkout')) { 685 var old_url = $('#loginlink').attr('href'); 686 var newUrl = old_url + "?redirect_to=checkout"; 687 $('#loginlink').attr('href', newUrl); 688 old_url = $('#registerlink').attr('href'); 689 newUrl = old_url + "?redirect_to=checkout"; 690 $('#registerlink').attr('href', newUrl); 691 } 692 693 /* Reorder section in mobile design */ 694 if ($(window).width() <= 720) { 695 if ($('body').hasClass('woocommerce-checkout')) { 696 $('#payment').insertBefore('.shop_table'); 697 } 698 } 699 700 701 /* Order by button option remove */ 702 $(".orderby option[value='menu_order']").remove(); 703 $(".orderby option[value='rating']").remove(); 704 $(".orderby option[value='date']").attr('selected', true); 705 706 707 708 709 /**Fade out cart product when user removes*/ 710 $('.product-remove').on('click', function () { 711 $(this).parents('.yi-box').fadeOut(600); 712 setTimeout(function () { 713 // location.reload(); 714 }, 1000); 715 }); 716 717 /** Edit profile function */ 718 $('body').on('click', '#edit-profile-cta', function () { 719 $('.profile-content input').attr('readonly', false); 720 $('.profile-content select').attr('disabled', false); 721 $('#user_firstname').focus(); 722 $('.update-profile-btn.btn-ui').fadeIn(); 723 $('.update-profile-otherdata-btn.btn-ui').fadeIn(); 724 }); 725 726 /** Profile update AJAX call */ 727 $('body').on('click', '.update-profile-btn', function () { 728 729 var fname = $('#user_firstname').val(); 730 var lname = $('#user_lastname').val(); 731 var companyName = $('#company_name').val(); 732 // var practice_company_name = $('#practice_company_name').val(); 733 var practice_type = $('#practice_type').val(); 734 735 if (!fname || fname.length < 1) { 736 alert('Please enter Firstname'); 737 return; 738 } else if (!lname || lname.length < 1) { 739 alert('Please enter Lastname'); 740 return; 741 } else if (!companyName || companyName.length < 1) { 742 alert('Please enter Company name'); 743 return; 744 } 745 /* else if (!practice_company_name || practice_company_name.length < 1) { 746 alert('Please enter Practice/Company Name'); 747 return; 748 } */ 749 else if (!practice_type || practice_type.length < 1) { 750 alert('Please enter Practice_type'); 751 return; 752 } else { 753 754 var formData = { 755 action: 'ifs_customer_profile_update', 756 first_name: fname, 757 last_name: lname, 758 practice_type: $('#practice_type').val(), 759 companyName: companyName, 760 company_role: $('#company_role').val() 761 } 762 763 $.ajax({ 764 type: 'POST', 765 url: ajaxurl, 766 data: formData, 767 dataType: 'json', 768 success: function (data) { 769 if (data.status == 'success') { 770 window.scrollTo({ top: 150, behavior: 'smooth' }); 771 $('.ajax-response').text(data.message); 772 $('.ajax-response').fadeIn(300); 773 774 } else { 775 window.scrollTo({ top: 150, behavior: 'smooth' }); 776 $('.ajax-response').text(data.message); 777 $('.ajax-response').fadeIn(300); 778 } 779 } 780 781 }); 782 } 783 }); 784 785 /** Profile other data update AJAX call */ 786 $('body').on('click', '.update-profile-otherdata-btn', function () { 787 var formData = { 788 action: 'ifs_customer_profile_otherdata_update', 789 number_of_locataion: $('#number_of_locataion').val(), 790 number_of_dentists: $('#number_of_dentists').val(), 791 number_of_hygienists: $('#number_of_hygienists').val(), 792 patients_per_week: $('#patients_per_week').val(), 793 ortho_starts_per_year: $('#ortho_starts_per_year').val(), 794 root_canals_per_year: $('#root_canals_per_year').val(), 795 interest_product: $('#interest_product').val(), 796 practitioner_license_number: $('#practitioner_license_number').val(), 797 affiliation: $('#affiliation').val() 798 } 799 800 $.ajax({ 801 type: 'POST', 802 url: ajaxurl, 803 data: formData, 804 dataType: 'json', 805 success: function (data) { 806 if (data.status == 'success') { 807 window.scrollTo({ top: 150, behavior: 'smooth' }); 808 $('.ajax-response').text(data.message); 809 $('.ajax-response').fadeIn(300); 810 } else { 811 window.scrollTo({ top: 150, behavior: 'smooth' }); 812 $('.ajax-response').text(data.message); 813 $('.ajax-response').fadeIn(300); 814 } 815 } 816 817 }); 818 }); 819 820 821 $('body').on('click', 'a[href="#"]', function (e) { 822 e.preventDefault(); 823 }) 824 /** Support drop down */ 825 /*$('body').on('click', '.menu-item-174, .menu-item-16187, .main-header-nav .menu-item-has-children', function (e) { 826 // e.stopPropagation (); 827 828 $(this).find('.sub-menu').toggleClass('active'); 829 830 var sub_menu_indicator = $('#menu-item-174 > a'); 831 832 if ($(window).width() <= 720) { 833 sub_menu_indicator = $('.mobile-only .menu-item-174 > a'); 834 } 835 console.log(sub_menu_indicator); 836 837 if (sub_menu_indicator.hasClass('indicate-open')) { 838 sub_menu_indicator.removeClass('indicate-open'); 839 } else { 840 sub_menu_indicator.addClass('indicate-open'); 841 } 842 843 });*/ 844 845 $('body').on('click', '.main-header-nav .menu-item-has-children, .mobile-slideout-section .menu-item-has-children', function (e) { 846 // e.stopPropagation (); 847 848 $(this).find('.sub-menu').toggleClass('active'); 849 850 var sub_menu_indicator = $(this).children('a'); 851 852 if ($(window).width() <= 720) { 853 // sub_menu_indicator = $('.mobile-only .menu-item-174 > a'); 854 } 855 console.log(sub_menu_indicator); 856 857 if (sub_menu_indicator.hasClass('indicate-open')) { 858 sub_menu_indicator.removeClass('indicate-open'); 859 } else { 860 sub_menu_indicator.addClass('indicate-open'); 861 } 862 863 e.stopPropagation(); 864 865 }); 866 867 /* $('.menu-item-174 .sub-menu').on('click', function (e) { 868 e.preventDefault(); 869 e.stopPropagation(); 870 }) */ 871 /* Hide menu on outside click */ 872 $(document).on('click', function (event) { 873 874 var $target = $(event.target); 875 876 /* if( !$target.closest('.menu-item-174').length && $('.menu-item-174 .sub-menu').hasClass('active')) { 877 878 $('.menu-item-174 .sub-menu').removeClass('active'); 879 var sub_menu_indicator = $('#menu-item-174 > a'); 880 881 if( sub_menu_indicator.hasClass('indicate-open') ){ 882 sub_menu_indicator.removeClass('indicate-open'); 883 } 884 else { 885 sub_menu_indicator.addClass('indicate-open'); 886 } 887 } */ 888 if ($('.live-search-results').hasClass('active')) { 889 $('.live-search-results').hide(); 890 $('.live-search-results').removeClass('active') 891 } 892 893 if ( $('.main-header-nav .menu-item-has-children .sub-menu').hasClass('active') ) { 894 $('.main-header-nav .menu-item-has-children .sub-menu.active').removeClass('active'); 895 $('.main-header-nav .menu-item-has-children > a').removeClass('indicate-open'); 896 } 897 898 899 }); 900 /* hide line that appears after search box input clear */ 901 $('#global_search_box').on('input', function (e) { 902 if ($(this).val().length < 1 || e.keyCode == '27') { 903 $('.live-search-results').hide(); 904 $('.live-search-results').removeClass('active') 905 } else { 906 $('.live-search-results').show(); 907 $('.live-search-results').addClass('active') 908 } 909 }); 910 911
912 /* Update title and SKU when product variation changed */ 913 function custom_update_title(e = 'none', variation) { 914 var form_data = { 915 action: "yi_variation_product_data", 916 variation_id: $('input.variation_id').val(), 917 product_id: $('input[name="product_id"]').val() 918 }; 919 920 /* 921 $.ajax({ 922 type: 'POST', 923 url: ajaxurl, 924 data: form_data, 925 dataType: 'json', 926 success: function (data) { 927 if (data.status == 'success') { 928 $('#yi_sku_code').text('Item #' + data.SKU); 929 $('.product_title.entry-title.yi-prod-title').text(data.title); 930 931 // console.log(data.sale_price); 932 // console.log(data.regular_price); 933 934 if (e == 'show_variation') { 935 $('.yi-product-price.js-generated .yi-sale-price').html("$" + data.sale_price); 936 $('.yi-product-price.js-generated .yi-regular-price').html("$" + data.regular_price); 937 $('.yi-product-price.js-generated #variation_regular_price_yi').html("$" + data.regular_price); 938 $('.yi-price-range').hide(); 939 $('.yi-product-price.js-generated').html(data.price_html); 940 $('.yi-product-price.js-generated').show(); 941 942 943 } 944 else { 945 $('.yi-product-price.js-generated').hide(); 946 $('.yi-price-range').show(); 947 } 948 } 949 } 950 }); 951 */ 952 953 954 /* 955 * product variation from product variation form data 956 */ 957 958 /*var all_variations = $('.variations_form.cart').data('product_variations'); 959 var selectedVariation = _.filter(all_variations , { 'variation_id': form_data.variation_id } ); 960 console.log( all_variations ); 961 console.log( selectedVariation );*/ 962 963 964 if (variation && e == 'show_variation') { 965 966 console.log('selected variation', variation); 967 968 var variationSku = variation['sku']; 969 var currentProductSku = $('.yi-product-price[data-variable-sku]').data('variable-sku'); 970 var variable_product_prices = window.yi_variable_product_prices && window.yi_variable_product_prices[currentProductSku] 971 ? window.yi_variable_product_prices[currentProductSku] 972 : (typeof variable_product_prices_template !== 'undefined' ? variable_product_prices_template : variable_product_prices); 973 974 $('#yi_sku_code').text('Item #' + variationSku); 975 976 if (variable_product_prices[variationSku] == undefined) { 977 console.log('call for price.'); 978 979 price_html = '<div class="call-for-price-message">Call for Price</div>'; 980 981 $('.woocommerce-variation-add-to-cart').hide(); 982 983 } else { 984 985 // PRICING BREAK: Showing the form back again 986 $('.woocommerce-variation-add-to-cart').show(); 987 988 // PRICE BREAK: Addition of default_quantity_pricing 989 var prices_list = { 990 "sale": variable_product_prices[variationSku]['sale_price'], 991 "agreement": variable_product_prices[variationSku]['agreement_price'], 992 "group": variable_product_prices[variationSku]['group_price'], 993 "pricelist": variable_product_prices[variationSku]['pricelist_price'], 994 "default": variable_product_prices[variationSku]['default_price'], 995 "default_quantity_pricing": json_get_default_qty_price( variationSku ) 996 }; 997 998 var best_price = 0; 999 var default_price = prices_list['default']; 1000 var price_html = ''; 1001 var best_prices = []; 1002 1003 1004 1005 var selectedPrice = ''; 1006 1007 1008 if (prices_list['default']) { 1009 best_price = prices_list['default']; 1010 best_prices.push(best_price); 1011 } 1012 1013 // PRICE BREAK: Adding default qty pricing 1014 if ( prices_list['default_quantity_pricing'] ) { 1015 best_price = prices_list['default_quantity_pricing']; 1016 best_prices.push( best_price ); 1017 } 1018 1019 if (prices_list['sale']) { 1020 best_price = prices_list['sale']; 1021 best_prices.push(best_price); 1022 1023 selectedPrice = 'sale'; 1024 } 1025 1026 if (prices_list['agreement']) { 1027 best_price = prices_list['agreement']; 1028 best_prices.push(best_price); 1029 1030 } 1031 1032 if (prices_list['group']) { 1033 best_price = prices_list['group']; 1034 best_prices.push(best_price); 1035 1036 } 1037 1038 if (prices_list['pricelist']) { 1039 best_price = prices_list['pricelist']; 1040 best_prices.push(best_price); 1041 } 1042 1043 var lowest_best_price = _.min(best_prices); 1044 var highest_price = _.max(best_prices); 1045 1046 if (highest_price < default_price) {
1047 highest_price = default_price; 1048 } 1049 1050 console.log('Best prices', best_prices); 1051 console.log('Default Price', default_price); 1052 1053 console.log('Lowest price', lowest_best_price); 1054 1055 if ( 1056 lowest_best_price < default_price && [0, 15.55].indexOf(lowest_best_price) < 0 1057 ) { 1058 $('.yi-product-price.js-generated .yi-sale-price').html("$" + lowest_best_price.toFixed(2)); 1059 1060 $('.yi-product-price.js-generated .yi-regular-price').html("$" + default_price.toFixed(2)); 1061 $('.yi-product-price.js-generated #variation_regular_price_yi').html("$" + default_price.toFixed(2)); 1062 1063 1064 price_html = '<div class="best_price_html">' + 1065 '<label>Your best price: </label>' + 1066 '<div class="m-0 best-price-strikethrough">' + 1067 ' <span class="m-0 product-price-value woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>' + lowest_best_price.toFixed(2) + '</span>' + 1068 ' <del class="yi-regular-price "><span class="woocommerce-Price-currencySymbol">$</span>' + default_price.toFixed(2) + '</del>' + 1069 '</div>' + 1070 '</div>'; 1071 1072 } else { 1073 price_html = '<div class="general-price"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>' + default_price.toFixed(2) + '</bdi></span></div>'; 1074 } 1075 1076 } 1077 1078 $('.yi-price-range').hide(); 1079 1080 $('.yi-product-price.js-generated').html(price_html); 1081 $('.yi-product-price.js-generated').show(); 1082 1083 1084 /* 1085 * BUY MORE SAVE MORE BUTTON HIDE 1086 */ 1087 tsw_get_pricing_slab( variationSku ); 1088 1089 /* 1090 * last chance label / show hide on variation change 1091 */ 1092 if (variation['last_chance'] != undefined) { 1093 if (variation['last_chance'] == 'yes') { 1094 var lastChanceHtmlAlready = $('.product-type-variable > .custom-labels .last-chance-label').length; 1095 1096 if (lastChanceHtmlAlready) { 1097 } else { 1098 var lastChanceLabel = '<div class="custom-label blue last-chance-label"> Last Chance </div>'; 1099 $('.product-type-variable > .custom-labels').append(lastChanceLabel); 1100 } 1101 1102 $('.product-type-variable > .custom-labels .last-chance-label').fadeIn(); 1103 } else { 1104 $('.product-type-variable > .custom-labels .last-chance-label').fadeOut(); 1105 } 1106 } else { 1107 $('.product-type-variable > .custom-labels .last-chance-label').fadeOut(); 1108 } 1109 1110 1111 } else { 1112 $('#yi_sku_code').text('Item #' + $('[data-parent-sku]').data('parent-sku')); 1113 1114 $('.yi-price-range').show(); 1115 $('.yi-product-price.js-generated').hide(); 1116 1117 } 1118 1119 1120 } 1121 1122 1123 // PRICING BREAK: Qty change 1124 $('body').on('change', '.woocommerce-variation-add-to-cart [name="quantity"]', function(e) { 1125 1126 window.setTimeout(function(){ 1127 var form_data = { 1128 action: "yi_variation_product_data", 1129 variation_id: $('input.variation_id').val(), 1130 product_id: $('input[name="product_id"]').val() 1131 }; 1132 1133 var variation = { 1134 'sku' : jQuery('.sku_wrapper .sku').text() 1135 }; 1136 var currentProductSku = $('.yi-product-price[data-variable-sku]').data('variable-sku'); 1137 var variable_product_prices = window.yi_variable_product_prices && window.yi_variable_product_prices[currentProductSku] 1138 ? window.yi_variable_product_prices[currentProductSku] 1139 : (typeof variable_product_prices_template !== 'undefined' ? variable_product_prices_template : window.variable_product_prices); 1140 1141 if ( 1142 variation && 1143 variable_product_prices && 1144 variable_product_prices[ variation.sku ] 1145 ) { 1146 1147 console.log('selected variation', variation); 1148 1149 var variationSku = variation['sku']; 1150 1151 $('#yi_sku_code').text('Item #' + variationSku); 1152 1153 if ( variable_product_prices[variationSku] == undefined ) { 1154 1155 // console.log('call for price.'); 1156 // price_html = '<div class="call-for-price-message">Call for Price</div>'; 1157 1158 // $('.woocommerce-variation-add-to-cart').hide(); 1159 console.log('Do nothing here.'); 1160 1161 } else { 1162 1163 // PRICING BREAK: Showing the form back again 1164 $('.woocommerce-variation-add-to-cart').show(); 1165 1166 // PRICE BREAK: Addition of default_quantity_pricing 1167 var prices_list = { 1168 "sale": variable_product_prices[variationSku]['sale_price'], 1169 "agreement": variable_product_prices[variationSku]['agreement_price'], 1170 "group": variable_product_prices[variationSku]['group_price'], 1171 "pricelist": variable_product_prices[variationSku]['pricelist_price'], 1172 "default": variable_product_prices[variationSku]['default_price'], 1173 "default_quantity_pricing": json_get_default_qty_price( variationSku ) 1174 }; 1175 1176 var best_price = 0; 1177 var default_price = prices_list['default']; 1178 var price_html = ''; 1179 var best_prices = []; 1180 1181 1182 1183 var selectedPrice = ''; 1184 1185 1186 1187 if (prices_list['default']) { 1188 best_price = prices_list['default']; 1189 best_prices.push(best_price); 1190 } 1191 1192 // PRICE BREAK: Adding default qty pricing 1193 if ( prices_list['default_quantity_pricing'] ) { 1194 best_price = prices_list['default_quantity_pricing']; 1195 best_prices.push( best_price ); 1196 } 1197 1198 if (prices_list['sale']) { 1199 best_price = prices_list['sale']; 1200 best_prices.push(best_price); 1201 1202 selectedPrice = 'sale'; 1203 } 1204 1205 if (prices_list['agreement']) { 1206 best_price = prices_list['agreement']; 1207 best_prices.push(best_price); 1208 1209 } 1210 1211 if (prices_list['group']) { 1212 best_price = prices_list['group']; 1213 best_prices.push(best_price); 1214 1215 } 1216 1217 if (prices_list['pricelist']) { 1218 best_price = prices_list['pricelist']; 1219 best_prices.push(best_price); 1220 } 1221 1222 var lowest_best_price = _.min(best_prices); 1223 var highest_price = _.max(best_prices); 1224 1225 if (highest_price < default_price) {
1226 highest_price = default_price; 1227 } 1228 1229 console.log('Best prices', best_prices); 1230 console.log('Default Price', default_price); 1231 1232 console.log('Lowest price', lowest_best_price); 1233 1234 if ( 1235 lowest_best_price < default_price && 1236 [0, 15.55].indexOf(lowest_best_price) < 0 1237 ) { 1238 1239 $('.woocommerce-variation-add-to-cart').show(); 1240 1241 $('.yi-product-price.js-generated .yi-sale-price').html("$" + lowest_best_price.toFixed(2)); 1242 1243 $('.yi-product-price.js-generated .yi-regular-price').html("$" + default_price.toFixed(2)); 1244 $('.yi-product-price.js-generated #variation_regular_price_yi').html("$" + default_price.toFixed(2)); 1245 1246 1247 price_html = '<div class="best_price_html">' 1248 + '<label>Your best price: </label>' 1249 + '<div class="m-0 best-price-strikethrough">' 1250 + ' <span class="m-0 product-price-value"><span class="woocommerce-Price-currencySymbol">$</span>' + lowest_best_price.toFixed(2) + '</span>' 1251 + ' <del class="yi-regular-price "><span class="woocommerce-Price-currencySymbol">$</span>' + default_price.toFixed(2) + '</del>' 1252 + '</div>' 1253 + '</div>'; 1254 1255 } else { 1256 price_html = '<div class="general-price"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>' + default_price.toFixed(2) + '</bdi></span></div>'; 1257 } 1258 1259 } 1260 1261 $('.yi-price-range').hide(); 1262 1263 $('.yi-product-price.js-generated').html(price_html); 1264 $('.yi-product-price.js-generated').show(); 1265 1266 1267 /* 1268 * last chance label / show hide on variation change 1269 */ 1270 if (variation['last_chance'] != undefined) { 1271 if (variation['last_chance'] == 'yes') { 1272 var lastChanceHtmlAlready = $('.product-type-variable > .custom-labels .last-chance-label').length; 1273 1274 if (lastChanceHtmlAlready) { 1275 } else { 1276 var lastChanceLabel = '<div class="custom-label blue last-chance-label"> Last Chance </div>'; 1277 $('.product-type-variable > .custom-labels').append(lastChanceLabel); 1278 } 1279 1280 $('.product-type-variable > .custom-labels .last-chance-label').fadeIn(); 1281 } else { 1282 $('.product-type-variable > .custom-labels .last-chance-label').fadeOut(); 1283 } 1284 } else { 1285 $('.product-type-variable > .custom-labels .last-chance-label').fadeOut(); 1286 } 1287 1288 1289 1290 } 1291 }, 200); 1292 1293 console.log( 'Qty changed to : ' + $(this).val() ); 1294 }); 1295 $('body').on('click', '.qty-increase, .qty-decrease' , function(){ 1296 $('.woocommerce-variation-add-to-cart [name="quantity"]').trigger('change'); 1297 }); 1298 1299 // On page load hide price 1300 1301 1302 $(".single_variation_wrap").on("show_variation", function (event, variation) { 1303 1304 // console.log( variation ); 1305 console.log("event.type :: ", event.type); 1306 console.log("variation :: ", variation); 1307 custom_update_title(event.type, variation); 1308 }); 1309 1310 1311 1312 1313 $("input.variation_id").on("change", function () { 1314 console.log($(this).val()); 1315 if (typeof $(this).val() == undefined || $(this).val() == '0' || $(this).val() == '') { 1316 custom_update_title(); 1317 } 1318 }); 1319 1320 $('.reset_variations').on('click', function () { 1321 console.log('variation reset '); 1322 1323 $('.yi-price-range').show(); 1324 $('.yi-product-price.js-generated').hide(); 1325 }) 1326 1327 /* Autofill state & city by pincode */ 1328 $('#zip_code, #ifs_customer_shipping_zipcode, #ifs_customer_zipcode').on('input', function (e) { 1329 var zip = $(this).val(); 1330 var input_field_id = $(this).attr('id'); 1331 if (zip && zip.length >= 5) { 1332 $.ajax({ 1333 type: 'GET', 1334 url: "https://api.worldpostallocations.com/pincode?postalcode=" + zip + "&countrycode=US", 1335 dataType: 'json', 1336 success: function (data) { 1337 1338 if (data.status == 1 && data.result.length > 0) { 1339 var state = data.result[0].state; 1340 var city = data.result[0].postalLocation; 1341 console.log(input_field_id); 1342 if (input_field_id == 'ifs_customer_shipping_zipcode') { 1343 $("#ifs_customer_shipping_city").val(city); 1344 $("#ifs_customer_shipping_state").val(state); 1345 } else if (input_field_id == 'ifs_customer_zipcode') { 1346 $("#ifs_customer_city").val(city); 1347 $("#ifs_customer_state").val(state); 1348 } else { 1349 $('#city').val(city); 1350 $('#state').val(state); 1351 } 1352 } 1353 1354 } 1355 }); 1356 } 1357 1358 }); 1359 1360 /* Change sort options value when applied. */ 1361 if ($("body").hasClass('post-type-product-archive') || $('body').hasClass('tax-product_cat')) { 1362 var url = new URL(window.location.href); 1363 var orderby = url.searchParams.get('orderby'); 1364 if (orderby) { 1365 $('.orderby').val(orderby); 1366 } 1367 } 1368 1369 //Removing Hawaii & Alaska from shipping select. 1370 $("select#state option[value='Hawaii']").remove(); 1371 $("select#state option[value='Alaska']").remove(); 1372 1373 $("select#ifs_customer_shipping_state option[value='HI']").remove(); 1374 $("select#ifs_customer_shipping_state option[value='AK']").remove(); 1375 1376 if ($('body').hasClass('tml-action-lostpassword')) { 1377 jQuery('.tml-user_login-wrap').append(jQuery('.tml-alerts')); 1378 } 1379 /**Reorder item */ 1380 1381 $('.reoder_item_button').on('click', function (e) { 1382 e.preventDefault(); 1383 1384 var formData = { 1385 action: 'yi_reorder_item', 1386 order_id: $(this).data('orderid'), 1387 item_id: $(this).data('itemid') 1388 } 1389 if ($(this).hasClass('add-all')) { 1390 formData.addAll = true; 1391 } 1392 var btn = $(this); 1393 $.ajax({ 1394 type: 'POST', 1395 url: ajaxurl, 1396 data: formData, 1397 dataType: 'json', 1398 beforeSend: function () { 1399 btn.html('<i class="fa fa-spinner fa-spin"></i> Adding ...'); 1400 btn.css('opacity', 0.5); 1401 btn.attr('disabled', true); 1402 }, 1403 success: function (data) { 1404 1405 btn.css('opacity', 1); 1406 1407 if (data.status == 'success') { 1408 1409 console.log('Item added to cart. '); 1410 // alert('Item added to cart. '); 1411 1412 btn.html('<i class="fa fa-check"></i> Added!'); 1413 1414 window.setTimeout(function () { 1415 btn.html('Re-order item'); 1416 btn.attr('disabled', false); 1417 }, 2200); 1418 1419 $(document.body).trigger('wc_fragment_refresh'); 1420 } else { 1421 console.log('Can\'t add item to cart '); 1422 } 1423 } 1424 }); 1425 }); 1426 /* Password validation for reset password page */ 1427 1428 var pattern = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/; 1429 $('.tml-action-resetpass .tml-pass1-wrap').append('<p class="password_message message-info"> Note: Password should contain minimum eight characters, at least one letter, one number and one special character </p>'); 1430 1431 $('.tml-action-resetpass #pass1').on('input', function () { 1432 1433 if (!pattern.test($(this).val())) { 1434 1435 if (!$('.tml-action-resetpass .tml-pass1-wrap .password_message').hasClass('active')) { 1436 1437 $('.tml-action-resetpass .tml-pass1-wrap .password_message').fadeIn(); 1438 $('.tml-action-resetpass .tml-pass1-wrap .password_message').addClass('active'); 1439 1440 if (!$(this).hasClass('password-has-error')) { 1441 $(this).addClass('password-has-error'); 1442 } 1443 } 1444 1445 } else { 1446 $('.tml-action-resetpass .tml-pass1-wrap .password_message').fadeOut(); 1447 $(this).removeClass('password-has-error'); 1448 } 1449 1450 }); 1451 1452 // tml-pass2-wrap 1453 $('.tml-action-resetpass .tml-pass2-wrap').append('<p class="confirm-pass-message message-alert"> Error: Please enter same password in both password fields </p>'); 1454 $('.tml-action-resetpass #pass2').on('input', function () { 1455 1456 var main_password = $('#pass1').val(); 1457 1458 if (main_password != $(this).val()) { 1459 $('.tml-action-resetpass .tml-pass2-wrap .confirm-pass-message').fadeIn(); 1460 1461 if (!$(this).hasClass('password-has-error')) { 1462 $(this).addClass('password-has-error'); 1463 } 1464 1465 } else { 1466 $('.tml-action-resetpass .tml-pass2-wrap .confirm-pass-message').fadeOut(); 1467 $(this).removeClass('password-has-error'); 1468 } 1469 1470 }); 1471 1472 $('.tml-action-resetpass form[name="resetpass"]').on('submit', function (e) { 1473 var form_errors = $(this).find('.password-has-error'); 1474 if (form_errors.length && form_errors.length > 0) { 1475 e.preventDefault(); 1476 $('.password-has-error:first').focus(); 1477 return false;
1478 } 1479 }); 1480 1481 $('body').on('click', '.product-remove', function () { 1482 if ($('.product-remove').length < 2) { 1483 $(this).parents('.yi-box').fadeOut(); 1484 setTimeout(function () { 1485 window.location.reload(); 1486 }, 1500); 1487 } 1488 }); 1489 /**----- HUBSPOT CUSTOM CODE -----**/ 1490 const HomeNewsletterForm = jQuery( '.home-newsletter-form' ); 1491 1492 // On Submission. 1493 HomeNewsletterForm.on( 'submit', function (e) { 1494 jQuery.ajax({ 1495 type: 'post', 1496 dataType: 'json', 1497 url: hubwoo_obj.ajaxUrl, 1498 data: { 1499 nonce : hubwoo_obj.hubwooSecurity, 1500 action: 'submit_optin_form' , 1501 formdata: jQuery(this).serialize() , 1502 }, 1503 success: function( result ){ 1504 console.log( result ); 1505 } 1506 }); 1507 }); 1508 /**----- END HUBSPOT CUSTOM CODE -----**/ 1509 1510 }); // end doc.ready 1511 1512})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.