1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 $(window).load(function () { 32 //Show loader 33 setTimeout(function () { 34 $('.profile_loader').hide(); 35 }, 500); 36 }); 37 $(document).ready( 38 function ($) { 39 40 /** 41 * Bind get_posts to tag cloud and navigation 42 */ 43 var page = 1; 44 var search_terms = ""; 45 var order = ""; 46 var scope = "all"; 47 var params = { 48 action: "bp_business_profile_filter", 49 nonce: bp_business_profile.ajax_nonce, 50 page: page, 51 scope: scope, 52 order: order, 53 args: $('#business-dir-list').data( 'bp-args' ), 54 search_terms: search_terms 55 }; 56 57 // Run query 58 get_businesses(params); 59 60 $(document).on( 61 "change", 62 "#business-order-by", 63 function (e) { 64 e.preventDefault(); 65 /* Order By */ 66 order = $('#business-order-by').val(); 67 68 params = { 69 action: "bp_business_profile_filter", 70 nonce: bp_business_profile.ajax_nonce, 71 page: page, 72 scope: scope, 73 order: order, 74 args: $('#business-dir-list').data( 'bp-args' ), 75 search_terms: search_terms 76 }; 77 78 // Run query 79 get_businesses(params); 80 } 81 ); 82 83 $(document).on( 84 "click", 85 ".bp-business-profile-index-scope-link, .bp-business-pagination a.page-numbers, #dir-business-search, #dir-business-search-submit", 86 function (e) { 87 88 e.preventDefault(); 89 90 if ($(this).hasClass("bp-business-profile-index-scope-link")) { 91 $(".bp-business-profile-index-scope-link").removeClass("selected"); 92 $(this).addClass("selected"); 93 94 if ($(this).data("bp-scope") == "all") { 95 scope = "all"; 96 } else if ($(this).data("bp-scope") == "personal") { 97 scope = "personal"; 98 } 99 } 100 /* Pagintion */ 101 if ($(this).hasClass("page-numbers")) { 102 if ($(this).attr("href").replace(/\D/g, "") != '') { 103 page = parseInt($(this).attr("href").replace(/\D/g, "")); 104 } else { 105 page = 1; 106 } 107 } 108 /* Search Terms*/ 109 if ($(this).attr("name") == 'business_search' || $(this).attr("name") == 'dir_business_search_submit') { 110 search_terms = $('#dir-business-search').val(); 111 } 112 113 order = $('#business-order-by').val(); 114 115 params = { 116 action: "bp_business_profile_filter", 117 nonce: bp_business_profile.ajax_nonce, 118 page: page, 119 scope: scope, 120 order: order, 121 args: $('#business-dir-list').data( 'bp-args' ), 122 search_terms: search_terms 123 }; 124 125 // Run query 126 get_businesses(params); 127 128 } 129 ); 130 131 /** 132 * Retrieve Business 133 */ 134 function get_businesses($params) { 135 136 var $container = $("#bp-businesses-content"); 137 var $content = $container.find("#business-dir-list"); 138 139 var $status = $container.find(".status"); 140 var $pager = $container.find(".infscr-pager a"); 141 142 $status.text(bp_business_profile.loading_business); 143 144 /** 145 * Do AJAX 146 */ 147 $.ajax( 148 { 149 url: bp_business_profile.ajaxurl, 150 data: $params, 151 type: "post", 152 dataType: "json", 153 success: function (data, textStatus, XMLHttpRequest) { 154 155 $content.empty(); 156 $content.append(data.data.contents); 157 }, 158 error: function (MLHttpRequest, textStatus, errorThrown) { 159 $status.html(textStatus); 160 }, 161 complete: function (data, textStatus) { 162 163 if (data.responseJSON.status === 201) { 164 $content.empty(); 165 } 166 167 }, 168 } 169 ); 170 } 171 172 var hash = window.location.hash.substr(1); 173 if (hash != '') { 174 $('#bp-profile-settings-tabs-nav li#bp-profile-setting-' + hash + '-li').addClass('active'); 175 $('.bp-business-settings-content .settings-tab-content').hide(); 176 $('.bp-business-settings-content .settings-tab-content:first').hide(); 177 $('#bp-profile-setting-' + hash.replace('/', '\\/') + '-content').css('display', 'block'); 178 } else { 179 // Show the first tab and hide the rest 180 if ($('#bp-profile-settings-tabs-nav li.active').length > 0) { 181 182 let active_setting_tab = $('#bp-profile-settings-tabs-nav li.active').data('id'); 183 $('.bp-business-settings-content .settings-tab-content').hide(); 184 $('.bp-business-settings-content .settings-tab-content#bp-profile-setting-' + active_setting_tab + '-content').show(); 185 } else { 186 $('#bp-profile-settings-tabs-nav li:first-child').addClass('active'); 187 $('.bp-business-settings-content .settings-tab-content').hide(); 188 $('.bp-business-settings-content .settings-tab-content:first').show(); 189 } 190 } 191 192 // Click function 193 $(document).on( 194 'click', 195 '#bp-profile-settings-tabs-nav li', 196 function () { 197 $('#bp-business-settings-submit').show(); 198 if ($(this).attr('id') === 'bp-profile-setting-delete-li') { 199 $('#bp-business-settings-submit').hide(); 200 } 201 $('#bp-profile-settings-tabs-nav li').removeClass('active'); 202 $(this).addClass('active'); 203 $('.bp-business-settings-content .settings-tab-content').hide(); 204 205 var activeTab = $(this).find('a').attr('href'); 206 $(activeTab).fadeIn(); 207 return false;
208 } 209 ); 210 211 /* Working Hours*/ 212 // Show the first tab and hide the rest 213 $('#bp-business-work-hours-tabs-nav li:first-child').addClass('active'); 214 $('.bp-business-work-hours-content .work-tab-content').hide(); 215 $('.bp-business-work-hours-content .work-tab-content:first').show(); 216 217 // Click function 218 $(document).on( 219 'click', 220 '#bp-business-work-hours-tabs-nav li', 221 function () { 222 $('#bp-business-work-hours-tabs-nav li').removeClass('active'); 223 $(this).addClass('active'); 224 $('.bp-business-work-hours-content .work-tab-content').hide(); 225 226 var activeTab = $(this).find('a').attr('href'); 227 $(activeTab).fadeIn(); 228 return false; 229 } 230 ); 231 232 $(document).on( 233 'change', 234 'input[name="business_info[hours][type]"]', 235 function (event) { 236 if ($(this).val() === 'selected_hours') { 237 $('.bp_business_selected_hours').show(); 238 } else { 239 $('.bp_business_selected_hours').hide(); 240 } 241 } 242 ); 243 244 /* Repeat Hours */ 245 $(document).on( 246 'click', 247 '.bp-social-network-repeater-create', 248 function (event) { 249 event.preventDefault(); 250 251 let $trLast = $('.bp-business-social-network').find(".repeater-item:last"), 252 $trNew = $trLast.clone(); 253 $trNew.find('input').val(''); 254 $trLast.after($trNew); 255 256 $('.bp-business-social-network .repeater-delete').show(); 257 $('.bp-business-social-network .repeater-item:first .repeater-delete').hide(); 258 259 } 260 ); 261 262 /* Delete Hour */ 263 $(document).on( 264 'click', 265 '.bp-social-network-repeater-delete', 266 function (event) { 267 event.preventDefault(); 268 $(this).parent().remove(); 269 270 } 271 ); 272 273 /* Repeat Hours */ 274 $('.bp-business-open-hours .repeater-item:first .repeater-delete').hide(); 275 $(document).on( 276 'click', 277 '.bp-work-hours-repeater-create', 278 function (event) { 279 event.preventDefault(); 280 let day = $(this).data("day"); 281 let $trLast = $('#bp-business' + day + '-open-hours').find(".repeater-item:last"), 282 $trNew = $trLast.clone(); 283 $trNew.find('select option:selected').removeAttr('selected'); 284 $trNew.find('.bp-work-hours-repeater-create').hide(); 285 $trLast.after($trNew); 286 287 $('#bp-business' + day + '-open-hours .repeater-delete').show(); 288 $('#bp-business' + day + '-open-hours .repeater-item:first .repeater-delete').hide(); 289 290 } 291 ); 292 293 /* Delete Hour */ 294 $(document).on( 295 'click', 296 '.bp-work-hours-repeater-delete', 297 function (event) { 298 event.preventDefault(); 299 $(this).parent().remove(); 300 301 } 302 ); 303 304 $(document).on( 305 'submit', 306 '#bp-profile-settings', 307 function (event) { 308 309 if ($(event.originalEvent.submitter).attr('id') === 'delete-business-button') { 310 /* delete bussiness button trigger then submit the form*/ 311 return true; 312 } else { 313 314 event.preventDefault(); 315 var formData = new FormData(this); 316 $('.bp-business-ajax-spinner').show(); 317 $('.bp-business-settings-submit').addClass('loading'); 318 319 var business_setting_page_url = $('#business_setting_page_url').val(); 320 var active_setting_tab = $('#bp-profile-settings-tabs-nav li.active').data('id'); 321 console.log(business_setting_page_url + " == " + active_setting_tab); 322 jQuery.ajax( 323 { 324 url: bp_business_profile.ajaxurl, 325 type: 'post', 326 processData: false, 327 contentType: false, 328 data: formData, 329 beforeSend: function () { 330 331 }, 332 success: function (response) { 333 $('.bp-business-ajax-spinner').hide(); 334 $('.bp-business-settings-submit').removeClass('loading'); 335 $('.bp-business-settings-result-box').html(''); 336 $('.bp-business-settings-result-box').removeClass('bp-business-settings-success'); 337 $('.bp-business-settings-result-box').removeClass('bp-business-settings-error'); 338 if (response.data.error == true) { 339 $('.bp-business-settings-result-box').addClass('bp-business-settings-error'); 340 } else { 341 $('.bp-business-settings-result-box').addClass('bp-business-settings-success'); 342 } 343 $('.bp-business-settings-result-box').html(response.data.message); 344 $('.bp-business-settings-result-box').show(); 345 if (response.data.action_button != '') { 346 $('#bp-business-action-button').remove(); 347 $('#bp-business-follow-button-container').prepend(response.data.action_button); 348 } 349 setTimeout( 350 function () {
351 $('.bp-business-settings-result-box').slideUp("slow"); 352 }, 353 3000 354 ); 355 window.location.href = business_setting_page_url + '?active=' + active_setting_tab; 356 //location.reload(); 357 } 358 } 359 ); 360 } 361 } 362 ); 363 364 $(document).on( 365 'click', 366 '.bp_business_expand_more', 367 function (e) { 368 e.preventDefault(); 369 if ($(this).hasClass('fa-solid fa-chevron-down')) { 370 $(this).removeClass('fa-solid fa-chevron-down'); 371 $(this).addClass('fa-solid fa-chevron-up'); 372 } else { 373 $(this).removeClass('fa-solid fa-chevron-up'); 374 $(this).addClass('fa-solid fa-chevron-down'); 375 } 376 $('.bp-business-open-hours-wrapper').toggle(); 377 } 378 ); 379 380 $(document).on( 381 'click', 382 '.bp_business_hours_expand_more', 383 function (e) { 384 e.preventDefault(); 385 if ($(this).hasClass('fa-solid fa-chevron-down')) { 386 $(this).removeClass('fa-solid fa-chevron-down'); 387 $(this).addClass('fa-solid fa-chevron-up'); 388 } else { 389 $(this).removeClass('fa-solid fa-chevron-up'); 390 $(this).addClass('fa-solid fa-chevron-down'); 391 } 392 $(this).parents('.bp-business-hours-container-section').find('.bp-business-open-hours-wrapper').toggle(); 393 } 394 ); 395 396 /* Business Follow */ 397 $(document).on( 398 "click", 399 ".bp-business-follow-button", 400 function (e) { 401 402 if ($(this).hasClass("followed")) { 403 var type = "unfollow"; 404 } else { 405 var type = "follow"; 406 } 407 var business_listing = $(this).parents().find('.bp-business-listing-follow-button').length; 408 var business_id = $(this).data('id'); 409 $.ajax( 410 { 411 type: "POST", 412 dataType: "JSON", 413 url: bp_business_profile.ajaxurl, 414 data: { 415 action: "bp_business_follow", 416 nonce: bp_business_profile.ajax_nonce, 417 post_id: $(this).data('id'), 418 type: type, 419 }, 420 success: function (response) { 421 if (!response.success) { 422 console.log("WP Spaces Error code: " + response.data[0].code); 423 } else { 424 425 if (business_listing == 0) { 426 427 $("#bp-business-follow-button-" + business_id + ' .bp-business-follow-button').remove(); 428 $("#bp-business-follow-button-" + business_id).append(response.data.content); 429 location.reload(true); 430 } else { 431 $("#bp-business-follow-button-" + business_id).html(response.data.content); 432 } 433 } 434 }, 435 } 436 ); 437 } 438 ); 439 440 // Change the stars on hover 441 $('.bp-business-stars').mouseenter( 442 function () { 443 $(this).parent().children().eq(0).val('not_clicked'); 444 var id = $(this).attr('data-attr'); 445 var parent_id = $(this).parent().attr('id'); 446 for (let i = 1; i <= id; i++) { 447 $('#' + parent_id).children('.' + i).addClass('fas').removeClass('far'); 448 } 449 } 450 ); 451 452 $('.bp-business-stars').mouseleave( 453 function () { 454 var clicked_id = $(this).parent().children().eq(1).val(); 455 var id = $(this).attr('data-attr'); 456 var parent_id = $(this).parent().attr('id'); 457 if ($(this).parent().children().eq(0).val() !== 'clicked') { 458 var j = parseInt(clicked_id) + 1; 459 for (let i = j; i <= 5; i++) { 460 $('#' + parent_id).children('.' + i).addClass('far').removeClass('fas'); 461 } 462 } 463 } 464 ); 465 466 // Color the stars on click 467 $(document).on( 468 "click", 469 ".bp-business-stars", 470 function (e) { 471 let attr = $(this).attr('data-attr');
472 let clicked_id = attr; 473 var parent_id = $(this).parent().attr('id'); 474 $(this).parent().children().eq(1).val(attr); 475 $(this).parent().children().eq(0).val('clicked'); 476 for (let i = 1; i <= attr; i++) { 477 $('#' + parent_id).children('.' + i).addClass('fas').removeClass('far'); 478 } 479 480 var k = parseInt(attr) + 1; 481 for (let j = k; j <= 5; j++) { 482 $('#' + parent_id).children('.' + j).addClass('far').removeClass('fas'); 483 } 484 } 485 ); 486 487 // Submit Group Review 488 489 $(document).on( 490 'submit', 491 "#bp-business-add-review-form", 492 function (e) { 493 494 let submit = false; 495 496 var rating_exist = []; 497 var review_desc = $('textarea[name*= "review-desc"]', this).val(); 498 var rating_field_counter = $("#rating_field_counter").val(); 499 var empty_rate = 0; 500 501 $(".bgr_mrating", this).each( 502 function () { 503 var rate_val = $(this).val(); 504 if (rate_val > 0) { 505 empty_rate = empty_rate + 1; 506 $(this).parent().next(".bp-business-error-fields").hide(); 507 } else { 508 $(this).parent().next(".bp-business-error-fields").show(); 509 } 510 rating_exist.push(rate_val); 511 } 512 ); 513 514 if (review_desc == "") { 515 $('textarea[name*= "review-desc"]', this).siblings(".bp-business-error-fields").show(); 516 submit = false; 517 } else { 518 $('textarea[name*= "review-desc"]', this).siblings(".bp-business-error-fields").hide(); 519 submit = true; 520 } 521 522 if (rating_field_counter > 0) { 523 if (jQuery.inArray("0", rating_exist) == -1) { 524 submit = true; 525 if (review_desc == "") { 526 submit = false; 527 } 528 529 } else { 530 submit = false; 531 532 } 533 } 534 535 return submit 536 537 } 538 ); 539 540 $(document).on( 541 'click', 542 '.bp-business-single-events-nav-button', 543 function (e) { 544 $('.bp-business-single-events-nav li').removeClass('selected'); 545 546 if ($(this).attr('id') == 'bp-business-single-create-event') { 547 $(this).closest('li').addClass('selected'); 548 $('#bp-business-single-events-create-screen').show(); 549 $('#bp-business-single-events-list').hide(); 550 } else { 551 $(this).closest('li').addClass('selected'); 552 $('#bp-business-single-events-create-screen').hide(); 553 $('#bp-business-single-events-list').show(); 554 } 555 556 } 557 ); 558 559 /* Repeat Hours */ 560 $('.bp-business-action-button .bp-business-action-info').hide(); 561 562 $('#bp-business-action-' + $('input[name="business_info[action-button]"]:checked').val()).show(); 563 $(document).on( 564 'change', 565 '.bp-business-action-button .bp-business-action-radio', 566 function (event) { 567 $('.bp-business-action-info').hide(); 568 let val = $(this).val() 569 $('#bp-business-action-' + val).show(); 570 } 571 ); 572 573 $(document).on( 574 'click', 575 '.bp-business-single-media-nav-button', 576 function (e) { 577 $('.bp-business-single-media-nav li').removeClass('selected'); 578 579 if ($(this).attr('id') == 'bp-business-single-create-media') { 580 $(this).closest('li').addClass('selected'); 581 $('#bp-business-single-media-create-screen').show(); 582 $('#bp-business-single-media-list').hide(); 583 } else { 584 $(this).closest('li').addClass('selected'); 585 $('#bp-business-single-media-create-screen').hide(); 586 $('#bp-business-single-media-list').show(); 587 } 588 589 } 590 ); 591 592 $(document).on( 593 'click', 594 '.bp_business_work_education_repeater', 595 function (e) { 596 var type = $(this).data('type'); 597 var clonedObj = $(this).siblings('.bp-business-work-education-container:first').clone().insertAfter($(this).siblings('.bp-business-work-education-container:last')); 598 clonedObj.find('.bp_business_remove_repeater_div').show(); 599 clonedObj.find('select option:selected').removeAttr('selected'); 600 clonedObj.find('input').val(''); 601 clonedObj.find('textarea').val(''); 602 clonedObj.find('input[type="checkbox"]').removeAttr('checked'); 603 $('.bp-business-' + type + '-container').each( 604 function (index) { 605 $(this).find("input").each( 606 function () { 607 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 608 } 609 ); 610 $(this).find("textarea").each( 611 function () { 612 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 613 } 614 ); 615 $(this).find("select").each( 616 function () { 617 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 618 } 619 ); 620 } 621 ); 622 } 623 ); 624 625 $(document).on( 626 'click', 627 '.bp_business_remove_repeater', 628 function () { 629 $(this).closest('div.bp-business-work-education-container').remove(); 630 var type = $(this).data('type'); 631 $('.bp-business-' + type + '-container').each( 632 function (index) { 633 $(this).find("input").each( 634 function () { 635 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 636 } 637 ); 638 $(this).find("textarea").each( 639 function () { 640 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 641 } 642 ); 643 $(this).find("select").each( 644 function () { 645 this.name = this.name.replace('[' + type + '][0]', '[' + type + ']' + '[' + index + ']'); 646 } 647 ); 648 } 649 ); 650 } 651 ); 652 653 $(document).on( 654 'click', 655 'input.bp-business-current-year', 656 function () { 657 if ($(this).is(":checked")) { 658 $(this).closest('.bp-business-currently-here').siblings('.bp-business-to-year').find("option:selected").removeAttr("selected"); 659 $(this).closest('.bp-business-currently-here').siblings('.bp-business-to-year').hide(); 660 } else { 661 $(this).closest('.bp-business-currently-here').siblings('.bp-business-to-year').show(); 662 } 663 } 664 ); 665 666 // More Menu. 667 $('nav#bp-business-main-object-nav > ul').BpBusinessMenu(35); 668 $(document).on('click', 'nav#bp-business-main-object-nav .hideshow .bs-more-button', function (e) { 669 e.preventDefault(); 670 $(this).toggleClass('active').next().toggleClass('active'); 671 }); 672 673 $(document).on('click', 'nav#bp-business-main-object-nav .hideshow .sub-menu a', function (e) { 674 //e.preventDefault(); 675 $('body').trigger('click'); 676 677 // add 'current' and 'selected' class 678 var currentLI = $(this).parent(); 679 currentLI.parent('nav#bp-business-main-object-nav .hideshow .sub-menu').find('li').removeClass('current selected'); 680 currentLI.addClass('current selected'); 681 }); 682 683 $(document).click(function (e) { 684 var container = $('nav#bp-business-main-object-nav .hideshow .bs-more-button, nav#bp-business-main-object-nav .hideshow .sub-menu'); 685 if (!container.is(e.target) && container.has(e.target).length === 0) { 686 $('nav#bp-business-main-object-nav .hideshow .bs-more-button').removeClass('active').next().removeClass('active'); 687 } 688 }); 689 690 // More Menu - resize. 691 $(window).resize(function () { 692 $('nav#bp-business-main-object-nav > ul').BpBusinessMenu(35); 693 $(document).on('click', 'nav#bp-business-main-object-nav .hideshow .bs-more-button', function (e) { 694 e.preventDefault(); 695 $(this).toggleClass('active').next().toggleClass('active'); 696 }); 697 698 $(document).on('click', 'nav#bp-business-main-object-nav .hideshow .sub-menu a', function (e) { 699 //e.preventDefault(); 700 $('body').trigger('click'); 701 702 // add 'current' and 'selected' class 703 var currentLI = $(this).parent(); 704 currentLI.parent('nav#bp-business-main-object-nav .hideshow .sub-menu').find('li').removeClass('current selected'); 705 currentLI.addClass('current selected'); 706 }); 707 708 $(document).click(function (e) { 709 var container = $('nav#bp-business-main-object-nav .hideshow .bs-more-button, nav#bp-business-main-object-nav .hideshow .sub-menu'); 710 if (!container.is(e.target) && container.has(e.target).length === 0) { 711 $('nav#bp-business-main-object-nav .hideshow .bs-more-button').removeClass('active').next().removeClass('active'); 712 } 713 }); 714 }); 715 716 if ($('.business-google-address').length > 0) { 717 const autolocator = document.getElementById("business-address"); 718 let autocomplete = new google.maps.places.Autocomplete(
719 /** @type {!HTMLInputElement} */ 720 (autolocator), { 721 fields: ["address_components", "geometry", "formatted_address"], 722 types: ['address'], 723 }); 724 autocomplete.setFields(['geometry', 'formatted_address', 'formatted_address']); 725 google.maps.event.addListener(autocomplete, 'place_changed', function () { 726 var place = autocomplete.getPlace(); 727 let address = ""; 728 729 for (const component of place.address_components) { 730 731 const componentType = component.types[0]; 732 733 switch (componentType) { 734 735 case "locality": 736 document.getElementById('business-address-city').value = component.long_name; 737 break; 738 739 case "administrative_area_level_1": { 740 document.getElementById('business-address-state').value = component.long_name; 741 break; 742 } 743 case "postal_code": // Added case for postal code 744 document.getElementById('business-address-zipcode').value = component.long_name; 745 break; 746 case "country": 747 document.getElementById('business-address-country').value = component.long_name; 748 break; 749 } 750 } 751 752 autolocator.value = place.formatted_address; 753 }); 754 } 755 756 /* Selecting/Deselecting all messages */ 757 $('.bp-business-profile-bulk-messages #select-all-messages').on('click', function () { 758 if (this.checked) { 759 $('.message-check').each(function () { 760 this.checked = true; 761 }); 762 } else { 763 $('.message-check').each(function () { 764 this.checked = false; 765 }); 766 } 767 }); 768 769 770 /** 771 * Business Directory Filter 772 */ 773 $('#business-category-filter').change(function () { 774 var $this = $(this); 775 var filterterm = $this.val(); 776 var type = $this.data('type'); 777 var custom_filter = {}; 778 $('.business-custom-category-filter').each( function(){ 779 custom_filter[$(this).attr('data-type')] = $(this).val(); 780 }); 781 var params = { 782 action: "bp_business_profile_filter", 783 nonce: bp_business_profile.ajax_nonce, 784 filter: filterterm, 785 custom_filter: JSON.stringify(custom_filter), 786 type: type 787 }; 788 // Run query 789 get_businesses(params); 790 }); 791 792 /** 793 * Business Directory Filter from custom taxonomy 794 */ 795 $( document ).on( 'change', '.business-custom-category-filter', function() { 796 var $this = $(this); 797 var filterterm = $('#business-category-filter').val(); 798 var type = $this.data('type'); 799 var custom_filter = {}; 800 $('.business-custom-category-filter').each( function(){ 801 custom_filter[$(this).attr('data-type')] = $(this).val(); 802 }); 803 804 var params = { 805 action: "bp_business_profile_filter", 806 nonce: bp_business_profile.ajax_nonce, 807 filter: filterterm, 808 custom_filter: JSON.stringify(custom_filter), 809 type: type 810 }; 811 // Run query 812 get_businesses(params); 813 }); 814 815 816 $( document ).on( 'change', '.business-search-country', function() { 817 var $params = { 818 action: "bp_business_profile_search_state", 819 nonce: bp_business_profile.ajax_nonce, 820 country: $(this).val(), 821 }; 822 823 /** 824 * Do AJAX 825 */ 826 $.ajax({ 827 url: bp_business_profile.ajaxurl, 828 data: $params, 829 type: "post", 830 dataType: "json", 831 success: function (data, textStatus, XMLHttpRequest) { 832 $(".business-search-state").empty(); 833 $(".business-search-state").append(data.data.state); 834 }, 835 836 }); 837 }); 838 839 $( document ).on( 'change', '.business-search-state', function() { 840 var $params = { 841 action: "bp_business_profile_search_city", 842 nonce: bp_business_profile.ajax_nonce, 843 country: $(this).parents('.business-search-filter').find('.business-search-country').val(), 844 state: $(this).val(), 845 }; 846 847 /** 848 * Do AJAX 849 */ 850 $.ajax({ 851 url: bp_business_profile.ajaxurl, 852 data: $params, 853 type: "post", 854 dataType: "json", 855 success: function (data, textStatus, XMLHttpRequest) { 856 $(".business-search-city").empty(); 857 $(".business-search-city").append(data.data.city); 858 }, 859 860 }); 861 }); 862 863 864 $( document ).on( 'click', '.bp-business-search-submit', function( e ) { 865 if ( $('#bp-businesses-content').length > 0 || $('#business-dir-list').length > 0) { 866 e.preventDefault(); 867 let form_data = $(this).parents('.bp-business-search-form').serialize(); 868 get_businesses(form_data); 869 } 870 871 872 }); 873 874 875 } 876 877 878 ); 879 880 $(document).ready(function () { 881 // for category drop down 882 new SlimSelect({ 883 select: '#bp-business-shop-select-cat', 884 settings: { 885 placeholderText: 'Select Categories', 886 } 887 }); 888 // for tag drop down 889 new SlimSelect({ 890 select: '#bp-business-shop-select-tag', 891 settings: { 892 placeholderText: 'Select Tags', 893 } 894 }); 895 896 var check_class = $("body").hasClass("single-business"); 897 if( true == check_class ){ 898 $(".primary-menu-container ul li").each(function (i) { 899 var findclass = $(this).hasClass("current_page_item"); 900 if (true == findclass) { 901 $(this).removeClass("current_page_item"); 902 } 903 }); 904 } 905 }); 906 907 908 909 910})(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.