1/*global $, jQuery, ajaxcalls_vars, document, control_vars, window, control_vars,Modernizr,mapfunctions_vars,wpestate_open_menu,grecaptcha,wpestate_show_no_results,wpestate_load_on_demand_pins,get_custom_value,wpestate_enable_half_map_pin_action,wpestate_lazy_load_carousel_property_unit,Chart,widgetId1,widgetId2,widgetId3,widgetId4,wpestate_get_custom_value_tab_search*/ 2/////////////////////////////////////////////////////////////////////////////////////////// 3 4function wpestate_load_stats_tabs(listing_id) { 5 "use strict"; 6 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 7 var nonce = jQuery('#wpestate_tab_stats').val(); 8 jQuery.ajax({ 9 type: 'POST', 10 url: ajaxurl, 11 dataType: 'json', 12 data: { 13 'action': 'wpestate_load_stats_property', 14 'postid': listing_id, 15 'security': nonce, 16 }, 17 success: function (data) { 18 wpestate_show_prop_stat_graph_tab(data.array_values, data.labels, listing_id); 19 }, 20 error: function (errorThrown) {} 21 });//end ajax 22} 23 24 25 26function wpestate_show_prop_stat_graph_tab(values, labels, listing_id) { 27 if (!document.getElementById('myChart')) { 28 return; 29 } 30 31 var ctx = jQuery("#myChart").get(0).getContext("2d"); 32 var myNewChart = new Chart(ctx); 33 // var labels = ''; 34 var traffic_data = ' '; 35 36 // labels = jQuery.parseJSON ( wpestate_property_vars.singular_label); 37 traffic_data = values; 38 39 var data = { 40 labels: labels, 41 datasets: [ 42 { 43 label: ajaxcalls_vars.property_views, 44 fillColor: "rgba(220,220,220,0.5)", 45 strokeColor: "rgba(220,220,220,0.8)", 46 highlightFill: "rgba(220,220,220,0.75)", 47 highlightStroke: "rgba(220,220,220,1)", 48 data: traffic_data 49 }, 50 ] 51 }; 52 53 var options = { 54 title: 'page views', 55 //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value 56 scaleBeginAtZero: true, 57 58 //Boolean - Whether grid lines are shown across the chart 59 scaleShowGridLines: true, 60 61 //String - Colour of the grid lines 62 scaleGridLineColor: "rgba(0,0,0,.05)", 63 64 //Number - Width of the grid lines 65 scaleGridLineWidth: 1, 66 67 //Boolean - Whether to show horizontal lines (except X axis) 68 scaleShowHorizontalLines: true, 69 70 //Boolean - Whether to show vertical lines (except Y axis) 71 scaleShowVerticalLines: true, 72 73 //Boolean - If there is a stroke on each bar 74 barShowStroke: true, 75 76 //Number - Pixel width of the bar stroke 77 barStrokeWidth: 2, 78 79 //Number - Spacing between each of the X value sets 80 barValueSpacing: 5, 81 82 //Number - Spacing between data sets within X values 83 barDatasetSpacing: 1, 84 85 //String - A legend template 86 legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].fillColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>" 87 88 }; 89 90 // var myBarChart = new Chart(ctx).Bar(data, options); 91 var myBarChart = new Chart(ctx, { 92 type: 'bar', 93 data: data, 94 options: options 95 }); 96} 97 98/** 99 * Remaps half-map listing card column sizes for list-mode rendering. 100 * 101 * @param {string} markup - HTML string containing listing_wrapper elements. 102 * @returns {string} Updated markup with transformed column classes and data-org values. 103 */ 104function wpestate_half_map_remap_list_columns(markup) { 105 106 107 108 if (typeof ajaxcalls_vars !== 'undefined' && ajaxcalls_vars.wp_estate_prop_unit === 'list') { 109 110 return markup; 111 } 112 113 if (typeof markup !== 'string' || markup === '') { 114 return markup; 115 } 116 117 var tempWrapper = jQuery('<div/>').html(markup); 118 119 tempWrapper.find('.listing_wrapper').each(function () { 120 var wrapper = jQuery(this); 121 var originalClasses = wrapper.attr('class') || ''; 122 console.log ("originalClasses"+originalClasses); 123 var mdMatch = originalClasses.match(/col-md-(\d+)/); 124 var originalOrg = wrapper.attr('data-org') || (mdMatch ? mdMatch[1] : '') || '6'; 125 126 // Persist the original column sizing so grid view can be restored later. 127 var lgMatch = originalClasses.match(/col-lg-(\d+)/); 128 var smMatch = originalClasses.match(/col-sm-(\d+)/); 129 130 wrapper.attr('data-half-map-original-md-class', mdMatch ? mdMatch[0] : ''); 131 wrapper.attr('data-half-map-original-lg-class', lgMatch ? lgMatch[0] : ''); 132 wrapper.attr('data-half-map-original-sm-class', smMatch ? smMatch[0] : ''); 133 wrapper.attr('data-half-map-original-org', originalOrg); 134 var targetOrg = originalOrg; 135console.log('remap '+ originalOrg); 136 switch (originalOrg) { 137 case '6': 138 targetOrg = '3'; 139 break; 140 case '4': 141 case '3': 142 targetOrg = '2'; 143 break; 144 case '12': 145 targetOrg = '12'; 146 break; 147 default: 148 targetOrg = originalOrg; 149 } 150 151 ['md', 'lg', 'sm'].forEach(function (breakpoint) { 152 var regex = new RegExp('col-' + breakpoint + '-\\d+', 'g'); 153 var matches = (wrapper.attr('class') || '').match(regex); 154 155 if (matches) { 156 wrapper.removeClass(matches.join(' ')); 157 } 158 159 wrapper.addClass('col-' + breakpoint + '-' + targetOrg); 160 }); 161 162 wrapper.attr('data-org', targetOrg); 163 }); 164 165 return tempWrapper.html(); 166} 167 168 169 170function wpestate_load_stats(listing_id) { 171 "use strict"; 172 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 173 var nonce = jQuery('#wpestate_tab_stats').val(); 174 175 jQuery.ajax({ 176 type: 'POST', 177 url: ajaxurl, 178 dataType: 'json', 179 data: { 180 'action': 'wpestate_load_stats_property', 181 'postid': listing_id, 182 'security': nonce, 183 }, 184 success: function (data) { 185 wpestate_show_prop_stat_graph(data.array_values, data.labels, listing_id); 186 }, 187 error: function (errorThrown) {} 188 });//end ajax 189} 190 191function wpestate_show_prop_stat_graph(values, labels, listing_id) { 192 "use strict"; 193 194 var ctx = jQuery("#myChart_" + listing_id).get(0).getContext('2d'); 195 var myNewChart = new Chart(ctx); 196 var data = { 197 labels: labels, 198 datasets: [ 199 { 200 label: ajaxcalls_vars.property_views, 201 fillColor: "rgba(220,220,220,0.5)", 202 strokeColor: "rgba(220,220,220,0.8)", 203 highlightFill: "rgba(220,220,220,0.75)", 204 highlightStroke: "rgba(220,220,220,1)", 205 data: values 206 }, 207 ] 208 }; 209 210 var options = { 211 scaleBeginAtZero: true, 212 scaleShowGridLines: true, 213 scaleGridLineColor: "rgba(0,0,0,.05)", 214 scaleGridLineWidth: 1, 215 scaleShowHorizontalLines: true, 216 scaleShowVerticalLines: true, 217 barShowStroke: true, 218 barStrokeWidth: 2, 219 barValueSpacing: 5, 220 barDatasetSpacing: 1, 221 legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].fillColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>" 222 }; 223 224 // var myBarChart = new Chart(ctx).Bar(data, options); 225 var myBarChart = new Chart(ctx, { 226 type: 'bar', 227 data: data, 228 options: options 229 }); 230} 231 232 233/** 234 * Run standard AJAX filtering for the classic search wrapper. 235 * 236 * Builds the request payload from the current search UI state and sends it to 237 * `wpestate_ajax_filter_listings_search`. Taxonomy filters are sent by their 238 * taxonomy keys and term-id values plus meta_query clauses prepared by 239 * `wpestate_prepare_custom_search_ajax_data`. 240 * 241 * @param {number} newpage Target results page for pagination. 242 * @returns {void} 243 */ 244function wpestate_start_filtering_ajax(newpage) { 245 "use strict"; 246 247 console.log ('22222222222222 wpestate_start_filtering_ajax '); 248 249 // Step 1: Read scalar filters and request defaults. 250 var action = ''; 251 var category = ''; 252 var city = ''; 253 var area = ''; 254 var county_state = ''; 255 var status = ''; 256 var min_price = parseFloat(jQuery('#price_low').val(), 10); 257 var price_max = parseFloat(jQuery('#price_max').val(), 10); 258 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 259 var postid = 1; 260 var halfmap = 0; 261 var all_checkers = []; 262 var meta_query = []; 263 var order = jQuery('#a_filter_order').attr('data-value'); 264 var nonce = jQuery('#wpestate_ajax_filtering').val(); 265 var search_wrapper = jQuery('.search_wrapper'); 266 267 // Step 2: Resolve search wrapper post id and half-map mode. 268 if (document.getElementById('search_wrapper')) {
269 postid = parseInt(jQuery('#search_wrapper').attr('data-postid'), 10); 270 } 271 if (jQuery('#google_map_prop_list_sidebar').length) { 272 halfmap = 1; 273 } 274 275 // Step 3: Collect shared features, geo and beds/baths values. 276 all_checkers = wpestate_collect_property_features_values(search_wrapper); 277 278 var geoValues = wpestate_collect_geo_values(); 279 var geo_lat = geoValues.geo_lat; 280 var geo_long = geoValues.geo_long; 281 var geo_rad = geoValues.geo_rad; 282 283 var bedsBathsValues = wpestate_collect_beds_baths_component_values(); 284 var componentsbeds = bedsBathsValues.componentsbeds; 285 var componentsbaths = bedsBathsValues.componentsbaths; 286 287 // Step 4: Build taxonomy/meta payload using the shared custom-search resolver. 288 var helperAjaxData = {}; 289 var helperMetaQuery = wpestate_prepare_custom_search_ajax_data( 290 search_wrapper, 291 helperAjaxData, 292 componentsbeds, 293 componentsbaths 294 ); 295 296 action = helperAjaxData.property_action_category || ''; 297 category = helperAjaxData.property_category || ''; 298 city = helperAjaxData.property_city || ''; 299 area = helperAjaxData.property_area || ''; 300 county_state = helperAjaxData.property_county_state || ''; 301 status = helperAjaxData.property_status || ''; 302 meta_query = jQuery.isArray(helperMetaQuery) ? helperMetaQuery : []; 303 304 // Step 5: Reset container and show loader before requesting new results. 305 jQuery('#listing_ajax_container').empty(); 306 jQuery('#listing_loader').show(); 307 308 // Step 6: Send AJAX request with taxonomy and meta query filters. 309 jQuery.ajax({ 310 type: 'POST', 311 url: ajaxurl, 312 dataType: 'json', 313 data: { 314 'action': 'wpestate_ajax_filter_listings_search', 315 'property_action_category': action, 316 'property_category': category, 317 'property_city': city, 318 'property_area': area, 319 'property_county_state': county_state, 320 'property_status': status, 321 'price_min': min_price, 322 'price_max': price_max, 323 'meta_query': meta_query, 324 'newpage': newpage, 325 'postid': postid, 326 'halfmap': halfmap, 327 'property_features': all_checkers, 328 'geo_lat': geo_lat, 329 'geo_long': geo_long, 330 'geo_rad': geo_rad, 331 'order': order, 332 'security': nonce 333 334 335 }, 336 // Step 7: Update UI with returned cards and rebind JS behaviors. 337 success: function (data) { 338 339 jQuery('#listing_loader').hide(); 340 jQuery('.listing_loader_title').show(); 341 jQuery('.pagination_nojax').hide(); 342 //jQuery('#listing_ajax_container').empty().append(data); 343 jQuery('.entry-title.title_prop').addClass('half_results').text(data.no_founs); 344 345 jQuery('#listing_ajax_container').empty().append(data.cards); 346 347 348 wpestate_restart_js_after_ajax(); 349 350 }, 351 // Step 8: Keep default silent error handler behavior. 352 error: function (errorThrown) {} 353 });//end ajax 354} 355 356////////////////////////////////////////////////////////////////////////////////////////////// 357/// ajax filtering on header search ; jslint checked 358//////////////////////////////////////////////////////////////////////////////////////////// 359 360 361/** 362 * Collect taxonomy values from multi-select controls in active scope. 363 * 364 * Reads taxonomy name from select/option data attributes, normalizes known 365 * aliases, then stores selected term ids (or values) as arrays on ajaxData. 366 * 367 * @param {jQuery} activeTabScope Scope used for tab-aware search extraction. 368 * @param {Object} ajaxData AJAX payload object to enrich. 369 * @returns {void} 370 */ 371function wpestate_collect_multiselect_taxonomies(activeTabScope, ajaxData) { 372 "use strict"; 373 374 // Step 1: Alias map for non-canonical taxonomy names from markup. 375 var taxonomyAliasMap = { 376 'cities': 'property_city', 377 'city': 'property_city', 378 'areas': 'property_area', 379 'area': 'property_area', 380 'countystate': 'property_county_state', 381 'county_state': 'property_county_state', 382 'county / state': 'property_county_state', 383 'types': 'property_action_category', 384 'actions': 'property_action_category', 385 'categories': 'property_category', 386 'status': 'property_status', 387 'features': 'property_features' 388 }; 389 390 // Step 2: Process each multi-select field in the active scope. 391 activeTabScope.find('select[multiple]').each(function () { 392 var selectElement = jQuery(this); 393 var taxonomyName = ''; 394 var optionValues = []; 395 396 // Step 2.1: Resolve taxonomy from select/selected-option metadata. 397 taxonomyName = (selectElement.attr('data-search-taxonomy') || '').trim(); 398 if (taxonomyName === '') { 399 var firstSelectedOption = selectElement.find('option:selected').first(); 400 if (firstSelectedOption.length > 0) { 401 taxonomyName = ( 402 firstSelectedOption.attr('data-search-taxonomy') || 403 firstSelectedOption.attr('data-taxonomy') || 404 '' 405 ).trim(); 406 } 407 } 408 409 // Step 2.2: Normalize key format and map aliases to canonical keys. 410 taxonomyName = taxonomyName.toLowerCase(); 411 taxonomyName = taxonomyName.replace(/\[\]$/g, '').trim(); 412 if (taxonomyAliasMap[taxonomyName]) { 413 taxonomyName = taxonomyAliasMap[taxonomyName]; 414 } 415 if (taxonomyName === '') { 416 return; 417 } 418 419 // Step 2.3: Collect selected option values (prefer term ids). 420 selectElement.find('option:selected').each(function () { 421 var selectedOption = jQuery(this); 422 var optionTermId = wpestate_get_term_id_from_element
422(selectedOption); 423 var optionValue = selectedOption.val() || ''; 424 var resolvedValue = (optionTermId !== '') ? optionTermId : optionValue; 425 426 if (resolvedValue !== '' && String(resolvedValue).toLowerCase() !== 'all') { 427 optionValues.push(resolvedValue); 428 } 429 }); 430 431 // Step 2.4: Store unique values under the resolved taxonomy key. 432 if (optionValues.length > 0) { 433 optionValues = optionValues.filter(function (value, index, array) { 434 return array.indexOf(value) === index; 435 }); 436 ajaxData[taxonomyName] = optionValues; 437 } 438 }); 439} 440 441/** 442 * Start advanced custom AJAX filtering for listings. 443 * 444 * This function collects active search values from `.search_wrapper`, 445 * normalizes taxonomy/meta inputs (including term-id aware fields), 446 * and sends the payload to `wpestate_custom_adv_ajax_filter_listings_search`. 447 * 448 * @param {number|string} newpage Requested pagination page. 449 * @returns {void} 450 */ 451function wpestate_custom_search_start_filtering_ajax(newpage) { 452 "use strict"; 453 console.log('wpestate_custom_search_start_filtering_ajax'); 454 // Step 1: search_wrapper is the form container. 455 var search_wrapper = jQuery('.search_wrapper'); 456 var active_tab_scope = search_wrapper.find('.tab-pane.active').first(); 457 458 // Step 1.1: When tabs exist, collect field values only from the active tab. 459 // This prevents hidden fields from inactive tabs from leaking into the request. 460 if (active_tab_scope.length === 0) { 461 active_tab_scope = search_wrapper; 462 } 463 464 // Step 2: active tab term id. 465 var term_id = jQuery('.tab-pane.active .term_id_class').val(); 466 467 // Step 3: Define payload variables that will be populated from the UI. 468 var ajaxurl = ajaxcalls_vars.wpestate_ajax; 469 470 var postid = ''; 471 var slider_min = ''; 472 var slider_max = ''; 473 var halfmap = 0; 474 var property_features_values = []; 475 var filter_search_action10 = ''; 476 var adv_location10 = ''; 477 var filter_search_action11 = ''; 478 var filter_search_categ11 = ''; 479 var geo_lat = ''; 480 var geo_long = ''; 481 var geo_rad = ''; 482 var componentsbeds = ''; 483 var componentsbaths = ''; 484 var location = ''; 485 var term_counter = ''; 486 487 // Step 3.1: If body has data-postid, use it as ajax postid. 488 var bodyPostId = jQuery('body').attr('data-postid'); 489 if (typeof bodyPostId === 'undefined' || bodyPostId === null || bodyPostId === '') { 490 bodyPostId = jQuery('body').data('postid'); 491 } 492 if (typeof bodyPostId !== 'undefined' && bodyPostId !== null && bodyPostId !== '') { 493 postid = bodyPostId; 494 } 495 496 // Step 4: Read slider values via dedicated collector. 497 var sliderValues = wpestate_collect_slider_values(); 498 slider_min = sliderValues.slider_min; 499 slider_max = sliderValues.slider_max; 500 501 // Step 5: Keep tab term id synced for tabbed search layouts. 502 if ((mapfunctions_vars.adv_search_type === '6' || mapfunctions_vars.adv_search_type === '7')) { // && !jQuery('.halfsearch')[0] 503 term_id = jQuery('.tab-pane.active .term_id_class').val(); 504 } 505 506 // Step 6: Read selected feature term ids via dedicated collector. 507 property_features_values = wpestate_collect_property_features_values(search_wrapper); 508 509 // Step 7: Read geolocation values via dedicated collector. 510 var geoValues = wpestate_collect_geo_values(); 511 geo_lat = geoValues.geo_lat; 512 geo_long = geoValues.geo_long; 513 geo_rad = geoValues.geo_rad; 514 515 // Step 8: Read beds/baths component values via dedicated collector. 516 var bedsBathsValues = wpestate_collect_beds_baths_component_values(); 517 componentsbeds = bedsBathsValues.componentsbeds; 518 componentsbaths = bedsBathsValues.componentsbaths; 519 520 // Step 8.1: Read the canonical location field from the active search scope. 521 location = active_tab_scope.find('input[name="location"]').first().val() || ''; 522 523 // Step 9: Keep term counter linked to the active tab term id. 524 term_counter = term_id; 525 526 var nonce = jQuery('#wpestate_ajax_filtering').val(); 527 var order = jQuery('#a_filter_order').attr('data-value'); 528 529 530 const listingContainer = jQuery('#listing_ajax_container'); 531 wpestate_createSkeletons(listingContainer); 532 533 534 //jQuery('#listing_ajax_container').empty(); 535// jQuery('#listing_loader').show(); 536 var ajaxData = { 537 'action': 'wpestate_custom_adv_ajax_filter_listings_search', 538 'newpage': newpage, 539 'postid': postid, 540 'halfmap': halfmap, 541 'property_features': property_features_values, 542 'filter_search_action10': filter_search_action10, 543 'location': location, 544 'adv_location10': adv_location10, 545 'filter_search_action11': filter_search_action11, 546 'filter_search_categ11': filter_search_categ11, 547 'order': order, 548 'term_counter': term_counter, 549 'componentsbeds' : componentsbeds, 550 'componentsbaths' : componentsbaths, 551 'security': nonce,
552 /////////////////////////////////////////////////////////// 553 'post_status': '', 554 'paged': '', 555 'posts_per_page': '', 556 'geo_lat': geo_lat, 557 'geo_long': geo_long, 558 'geo_rad': geo_rad, 559 'price_min': slider_min, 560 'price_max': slider_max, 561 }; 562 563 // Step 10: Prepare taxonomy + post-meta ajax data from search controls. 564 var metaQueryPayload = wpestate_prepare_custom_search_ajax_data( 565 active_tab_scope, 566 ajaxData, 567 componentsbeds, 568 componentsbaths 569 ); 570 571 // Step 11: Attach collected meta_query clauses to the AJAX payload. 572 ajaxData.meta_query = metaQueryPayload; 573 574 // Step 13: Fallback mapping for legacy templates missing `data-search-*`. 575 // Generic active-tab taxonomy fallback (no hardcoded field names). 576 var activeTabButton = search_wrapper.find('.adv_search_tab_item.active').first(); 577 if (activeTabButton.length > 0) { 578 var activeTabTaxonomy = (activeTabButton.attr('data-tax') || '').trim(); 579 var activeTabTermId = wpestate_get_term_id_from_element(activeTabButton); 580 var activeTabTermValue = (activeTabButton.attr('data-term') || '').trim(); 581 582 if (activeTabTaxonomy !== '') { 583 if (activeTabTermId !== '') { 584 ajaxData[activeTabTaxonomy] = activeTabTermId; 585 } else if (activeTabTermValue !== '' && activeTabTermValue.toLowerCase() !== 'all') { 586 ajaxData[activeTabTaxonomy] = activeTabTermValue; 587 } 588 589 if (activeTabTaxonomy === 'property_action_category' && typeof ajaxData[activeTabTaxonomy] !== 'undefined') { 590 ajaxData.query_action = ajaxData[activeTabTaxonomy]; 591 } 592 } 593 } 594 595 jQuery.ajax({ 596 type: 'POST', 597 url: ajaxurl, 598 dataType: 'json', 599 data: ajaxData, 600 success: function (data) { 601 602 603 604 jQuery('#listing_loader').hide(); 605 jQuery('.listing_loader_title').show(); 606 jQuery('.entry-title.title_prop').addClass('half_results').text(data.no_founs); 607 608 var cardsMarkup = data.cards; 609 610 // When half-map list view is active, remap the returned column sizes 611 // before injecting the new cards so they respect the list-mode sizing rules. 612 if (window.wpestateHalfMapState && 613 typeof window.wpestateHalfMapState.getMode === 'function' && 614 window.wpestateHalfMapState.getMode() === 'list') { 615 cardsMarkup = wpestate_half_map_remap_list_columns(cardsMarkup); 616 } 617 618 // jQuery('#listing_ajax_container').empty().append(cardsMarkup); 619 wpestate_replaceSkeletons(listingContainer, cardsMarkup); 620 621 if (window.wpestateHalfMapState && typeof window.wpestateHalfMapState.applyCurrentLayout === 'function') { 622 window.wpestateHalfMapState.applyCurrentLayout(); 623 } 624 625 626 wpestate_restart_js_after_ajax(); 627 jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function () { 628 jQuery(this).parent().addClass('wrap_custom_image'); 629 }); 630 631 if (data.saved_search !== null) { 632 jQuery(".search_param").html(data.saved_search); 633 jQuery("#search_args").val( JSON.stringify(data.args) ); 634 jQuery("#meta_args").val( JSON.stringify(data.search_meta) ); 635 636 } 637 }, 638 error: function (errorThrown) { 639 640 } 641 });//end ajax 642} 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683function wpestate_js_pagination_ajax(){ 684 "use strict"; 685 686 jQuery('.pagination_ajax a').on('click', function (event) { 687 event.preventDefault(); 688 var newpage = parseInt(jQuery(this).attr('data-future'), 10); 689 wpestate_start_filtering(newpage); 690 }); 691 692} 693 694 695//////////////////////////////////////////////////////////////////////////////////////////// 696/// redo js after ajax calls - jslint checked 697//////////////////////////////////////////////////////////////////////////////////////////// 698function wpestate_restart_js_after_ajax() { 699 "use strict"; 700 wpestate_lazy_load_carousel_property_unit(); 701 wpestate_card_unit_contact_actions(); 702 703 704 // wpestate_enable_half_map_pin_action(); 705 if (typeof wpestate_enable_half_map_pin_action == 'function') { 706 wpestate_enable_half_map_pin_action(); 707 } 708 var newpage, post_id, post_image, to_add, icon; 709 710 jQuery('.pagination_ajax_search a').on('click', function (event) { 711 event.preventDefault(); 712
713 newpage = parseInt(jQuery(this).attr('data-future'), 10); 714 document.getElementById('scrollhere').scrollIntoView(); 715 if (mapfunctions_vars.custom_search === 'yes') { 716 wpestate_custom_search_start_filtering_ajax(newpage); // should be custom 717 } else { 718 wpestate_start_filtering_ajax(newpage);// 719 } 720 }); 721 722 jQuery('.pagination_ajax a').on('click', function (event) { 723 event.preventDefault(); 724 newpage = parseInt(jQuery(this).attr('data-future'), 10); 725 document.getElementById('scrollhere').scrollIntoView(); 726 wpestate_start_filtering(newpage); 727 }); 728 729 730 731 jQuery('.property_listing').on('click', function (event) { 732 if ( 733 event.target.classList.contains('demo-icon') || 734 event.target.classList.contains('carousel-control-next-icon') || 735 event.target.classList.contains('carousel-control-prev-icon') 736 ){ 737 return; 738 } 739 740 741 if (control_vars.property_modal === '1' && !Modernizr.mq('only all and (max-width: 1024px)')) { 742 event.preventDefault(); 743 event.stopPropagation(); 744 scroll_modal_save = scroll_modal; 745 746 var listing_id = jQuery(this).parent().attr('data-listid'); 747 var main_img_url = jQuery(this).parent().attr('data-main-modal'); 748 var main_title = jQuery(this).parent().attr('data-modal-title'); 749 var link = jQuery(this).parent().attr('data-modal-link'); 750 wpestate_enable_property_modal(listing_id, main_img_url, main_title, link); 751 } else { 752 if (control_vars.new_page_link === '_blank') { 753 return; 754 } 755 var link; 756 link = jQuery(this).attr('data-link'); 757 758 window.open(link, '_self'); 759 } 760 }); 761 762 763 764 765 766 jQuery('.share_unit').on('click', function (event) { 767 event.stopPropagation(); 768 }); 769 770 var already_in = []; 771 772 jQuery('.compare-action').unbind('click'); 773 jQuery('.compare-action').on('click', function (event) { 774 event.stopPropagation(); 775 jQuery('.prop-compare').animate({ 776 right: "0px" 777 }); 778 post_id = jQuery(this).attr('data-pid'); 779 for (var i = 0; i < already_in.length; i++) { 780 if (already_in[i] === post_id) { 781 return; 782 } 783 } 784 785 already_in.push(post_id); 786 post_image = jQuery(this).attr('data-pimage'); 787 788 to_add = '<div class="items_compare ajax_compare" style="display:none;"><img src="' + post_image + '" class="img-responsive"><input type="hidden" value="' + post_id + '" name="selected_id[]" /></div>'; 789 jQuery('div.items_compare:first-child').css('background', 'red'); 790 if (parseInt(jQuery('.items_compare').length, 10) > 3) { 791 jQuery('.items_compare:first').remove(); 792 } 793 jQuery('#submit_compare').before(to_add); 794 jQuery('.items_compare').fadeIn(800); 795 }); 796 797 jQuery('#submit_compare').unbind('click'); 798 jQuery('#submit_compare').on('click', function (event) { 799 jQuery('#form_compare').trigger('submit'); 800 }); 801 802 jQuery('.icon-fav').on('click', function (event) { 803 event.stopPropagation(); 804 icon = jQuery(this); 805 wpestate_add_remove_favorite(icon); 806 }); 807 808 jQuery(".share_list, .icon-fav, .compare-action,.property_listing_details_v7_item").on('mouseenter', function () { 809 jQuery(this).tooltip('show'); 810 }) 811 .on('mouseleave', function () { 812 jQuery(this).tooltip('hide'); 813 }); 814 815 816 jQuery('.share_list').on('click', function (event) { 817 event.stopPropagation(); 818 var sharediv = jQuery(this).parent().find('.share_unit'); 819 sharediv.toggle(); 820 jQuery(this).toggleClass('share_on'); 821 }); 822 823 wpestate_grid_list_controls(); 824 wpestate_enable_share_unit(); 825 wpestate_enable_not_logged_favorites(); 826} 827 828 829 830 831 832/* 833* 834* Remove/Add to favorites(property page) when login is not required 835* 836*/ 837 838function wpestate_add_remove_favorite_local_storage_single(icon,post_id){ 839 var current_favorites = window.localStorage.getItem('wpestate_favorites'); 840 post_id=parseInt(post_id); 841 842 843 if(icon.hasClass('isnotfavorite')){ 844 845 if ( current_favorites ) { 846 current_favorites=current_favorites + ',' + post_id; 847 window.localStorage.setItem('wpestate_favorites',current_favorites ); 848 } else { 849 current_favorites=post_id; 850 window.localStorage.setItem('wpestate_favorites', current_favorites); 851 } 852
853 setCookie('wpestate_favorites',current_favorites,10); 854 855 jQuery('#add_favorites').removeClass('isnotfavorite').addClass('isfavorite').attr('title', ajaxcalls_vars.remove_favorite); 856 jQuery('#add_favorites').html('<i class="fas fa-heart"></i>' + ajaxcalls_vars.favorite); 857 858 }else{ 859 860 var prop_ids = jQuery.map(current_favorites.split(','), function(value){ 861 return parseInt(value); 862 }); 863 864 865 const index = prop_ids.indexOf( post_id ); 866 867 if (index > -1) { 868 prop_ids.splice(index, 1); 869 window.localStorage.setItem('wpestate_favorites', prop_ids); 870 setCookie('wpestate_favorites',prop_ids,10); 871 } 872 873 874 jQuery('#add_favorites').removeClass('isfavorite').addClass('isnotfavorite').attr('title', ajaxcalls_vars.add_favorite); 875 jQuery('#add_favorites').html('<i class="far fa-heart"></i>' + ajaxcalls_vars.favorite); 876 877 } 878 879 current_favorites = window.localStorage.getItem('wpestate_favorites'); 880} 881 882 883 884/* 885* 886* Remove/Add to favorites when login is not required 887* 888*/ 889 890 891function wpestate_add_remove_favorite_local_storage(icon,post_id){ 892 var current_favorites = window.localStorage.getItem('wpestate_favorites'); 893 post_id=parseInt(post_id); 894 895 if(icon.hasClass('icon-fav-off')){ 896 897 if ( current_favorites ) { 898 current_favorites=current_favorites+','+post_id; 899 window.localStorage.setItem('wpestate_favorites', current_favorites); 900 } else { 901 current_favorites=post_id; 902 window.localStorage.setItem('wpestate_favorites', current_favorites); 903 } 904 905 setCookie('wpestate_favorites',current_favorites,10); 906 907 icon.removeClass('icon-fav-off').addClass('icon-fav-on'); 908 icon.attr('title', ajaxcalls_vars.remove_fav); 909 910 }else{ 911 912 var prop_ids = jQuery.map(current_favorites.split(','), function(value){ 913 return parseInt(value); 914 }); 915 916 const index = prop_ids.indexOf( post_id ); 917 918 if (index > -1) { 919 prop_ids.splice(index, 1); 920 window.localStorage.setItem('wpestate_favorites', prop_ids); 921 setCookie('wpestate_favorites',prop_ids,10); 922 } 923 924 if (icon.hasClass('remove_fav_dash')) { 925 icon.parents('.property_wrapper_dash').remove(); 926 icon.parents('.listing_wrapper').remove(); 927 } 928 929 icon.removeClass('icon-fav-on').addClass('icon-fav-off'); 930 icon.attr('title', ajaxcalls_vars.add_favorite); 931 } 932 933 current_favorites = window.localStorage.getItem('wpestate_favorites'); 934} 935 936 937 938/* 939* 940* Remove/Add to favorites 941* 942*/ 943 944function wpestate_add_remove_favorite(icon) { 945 "use strict"; 946 var post_id, securitypass, ajaxurl; 947 post_id = icon.attr('data-postid'); 948 securitypass = jQuery('#security-pass').val(); 949 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 950 var nonce = jQuery('#wpestate_ajax_filtering').val(); 951 var use_favorite_login = ajaxcalls_vars.favorites_login; 952 953 if(use_favorite_login == "no"){ 954 wpestate_add_remove_favorite_local_storage(icon, post_id); 955 return; 956 } 957 958 if (parseInt(ajaxcalls_vars.userid, 10) === 0) { 959 wpestate_trigger_login_modal_open(1); 960 } else { 961 icon.toggleClass('icon-fav-off'); 962 icon.toggleClass('icon-fav-on'); 963 964 965 jQuery.ajax({ 966 type: 'POST', 967 url: ajaxurl, 968 dataType: 'json', 969 data: { 970 'action': 'wpestate_ajax_add_fav', 971 'post_id': post_id, 972 'security': nonce 973 }, 974 success: function (data) { 975 976 if (data.added) { 977 icon.removeClass('icon-fav-off').addClass('icon-fav-on'); 978 // Update Bootstrap tooltip attributes 979 icon.attr('aria-label', ajaxcalls_vars.remove_fav); 980 icon.attr('data-bs-original-title', ajaxcalls_vars.remove_fav); 981 // Also update title for fallback 982 icon.attr('title', ajaxcalls_vars.remove_fav); 983 984 // Refresh the Bootstrap tooltip if it exists 985 if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) { 986 var tooltipInstance = bootstrap.Tooltip.getInstance(icon[0]); 987 if (tooltipInstance) { 988 tooltipInstance.setContent({ 989 '.tooltip-inner': ajaxcalls_vars.remove_fav 990 }); 991 } 992 } 993 } else { 994 if (icon.hasClass('remove_fav_dash')) { 995 icon.parents('.property_wrapper_dash').remove(); 996 } 997 icon.removeClass('icon-fav-on').addClass('icon-fav-off'); 998 // Update Bootstrap tooltip attributes 999 icon.attr('aria-label', ajaxcalls_vars.add_favorite); 1000 icon.attr('data-bs-original-title', ajaxcalls_vars.add_favorite); 1001 // Also update title for fallback 1002 icon.attr('title', ajaxcalls_vars.add_favorite); 1003 1004 // Refresh the Bootstrap tooltip if it exists 1005 if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) { 1006 var tooltipInstance = bootstrap.Tooltip.getInstance(icon[0]); 1007 if (tooltipInstance) { 1008 tooltipInstance.setContent({ 1009 '.tooltip-inner': ajaxcalls_vars.add_favorite 1010 }); 1011 } 1012 } 1013 } 1014 }, 1015 error: function (errorThrown) { 1016 // Handle error case 1017 } 1018 }); // end ajax 1019 } // end login use 1020} 1021
1022//////////////////////////////////////////////////////////////////////////////////////////// 1023/// resend listing for approval-jslint checked 1024//////////////////////////////////////////////////////////////////////////////////////////// 1025function wpestate_resend_for_approval(prop_id, selected_div) { 1026 "use strict"; 1027 var ajaxurl, normal_list_no; 1028 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 1029 var nonce = jQuery('#wpestate_property_actions').val(); 1030 1031 jQuery.ajax({ 1032 type: 'POST', 1033 url: ajaxurl, 1034 data: { 1035 'action': 'wpestate_ajax_resend_for_approval', 1036 'propid': prop_id, 1037 'security': nonce 1038 }, 1039 success: function (data) { 1040 1041 if (data === 'pending') { 1042 selected_div.parent().empty().append('<span class="featured_prop">Sent for approval</span>'); 1043 normal_list_no = parseInt(jQuery('#normal_list_no').text(), 10); 1044 jQuery('#normal_list_no').text(normal_list_no - 1); 1045 } else { 1046 selected_div.removeClass('resend_pending').html(data); 1047 } 1048 }, 1049 error: function (errorThrown) { 1050 1051 } 1052 });//end ajax 1053} 1054 1055//////////////////////////////////////////////////////////////////////////////////////////// 1056/// make property featured-jslint checked 1057//////////////////////////////////////////////////////////////////////////////////////////// 1058function wpestate_make_prop_featured(prop_id, selectedspan) { 1059 "use strict"; 1060 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1061 var nonce = jQuery('#wpestate_property_actions').val(); 1062 1063 jQuery.ajax({ 1064 type: 'POST', 1065 url: ajaxurl, 1066 data: { 1067 'action': 'wpestate_ajax_make_prop_featured', 1068 'propid': prop_id, 1069 'security': nonce 1070 }, 1071 success: function (data) { 1072 if (data.trim() === 'done') { 1073 selectedspan.empty().html('<span class="label label-success">' + ajaxcalls_vars.prop_featured + '</span>'); 1074 var featured_list_no = parseInt(jQuery('#featured_list_no').text(), 10); 1075 jQuery('#featured_list_no').text(featured_list_no - 1); 1076 } else { 1077 selectedspan.empty().removeClass('make_featured').addClass('featured_exp').text(ajaxcalls_vars.no_prop_featured); 1078 } 1079 1080 }, 1081 error: function (errorThrown) { 1082 } 1083 1084 });//end ajax 1085} 1086 1087//////////////////////////////////////////////////////////////////////////////////////////// 1088/// pay package via paypal recuring-jslint checked 1089//////////////////////////////////////////////////////////////////////////////////////////// 1090function wpestate_recuring_pay_pack_via_paypal() { 1091 "use strict"; 1092 var ajaxurl, packName, packId; 1093 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 1094 1095 packName = jQuery('.package_selected .pack-listing-title').text(); 1096 packId = jQuery('.package_selected .pack-listing-title').attr('data-packid'); 1097 1098 var nonce = jQuery('#wpestate_payments_nonce').val(); 1099 jQuery.ajax({ 1100 type: 'POST', 1101 url: ajaxurl, 1102 data: { 1103 'action': 'wpestate_ajax_paypal_pack_recuring_generation_rest_api', 1104 'packName': packName, 1105 'packId': packId, 1106 'security': nonce 1107 }, 1108 success: function (data) { 1109 window.location.href = data; 1110 }, 1111 error: function (errorThrown) { 1112 1113 } 1114 });//end ajax 1115} 1116 1117jQuery(".buypackage").click(function () { 1118 "use strict"; 1119 var stripe_pack_id, stripetitle2, stripetitle, stripepay; 1120 1121 1122 jQuery(".pack-listing").removeClass("package_selected"); 1123 jQuery(".pack-listing input").prop('checked', false); 1124 1125 jQuery(this).find('.input_pak_check').prop('checked', true); 1126 jQuery(this).parent().addClass("package_selected"); 1127 1128 stripetitle = jQuery(this).parent().find('.pack-listing-title').attr('data-stripetitle'); 1129 stripetitle2 = jQuery(this).parent().find('.pack-listing-title').attr('data-stripetitle2'); 1130 stripepay = jQuery(this).parent().find('.pack-listing-title').attr('data-stripepay'); 1131 stripe_pack_id = jQuery(this).parent().find('.pack-listing-title').attr('data-packid'); 1132 1133 jQuery('.stripe_buttons').attr("id", stripetitle2); 1134 jQuery('#stripe_script').attr("data-amount", stripepay); 1135 jQuery('#stripe_script').attr("data-description", stripetitle); 1136 1137 jQuery('#pack_id').val(stripe_pack_id); 1138 jQuery('#pack_title').val(stripetitle2); 1139 jQuery('#pay_ammout').val(stripepay); 1140 jQuery('#stripe_form').attr('data-amount', stripepay); 1141 1142 1143 jQuery('.wpestate_stripe_pay_desc').html(control_vars.stripe_pay_for + " " + stripetitle2); 1144 jQuery('#wpestate_stripe_form_button_sumit').html(control_vars.stripe_pay + " " + stripepay / 100 + " " + control_vars.submission_curency); 1145 1146 // enable stripe code 1147 1148 1149}); 1150 1151 1152 1153//////////////////////////////////////////////////////////////////////////////////////////// 1154/// pay package via paypal-jslint checked
1155//////////////////////////////////////////////////////////////////////////////////////////// 1156function wpestate_pay_pack_via_paypal() { 1157 "use strict"; 1158 var ajaxurl, packName, packId; 1159 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 1160 packName = jQuery('.package_selected .pack-listing-title').text(); 1161 packId = jQuery('.package_selected .pack-listing-title').attr('data-packid'); 1162 var nonce = jQuery('#wpestate_payments_nonce').val(); 1163 jQuery.ajax({ 1164 type: 'POST', 1165 url: ajaxurl, 1166 data: { 1167 'action': 'wpestate_ajax_paypal_pack_generation', 1168 'packName': packName, 1169 'packId': packId, 1170 'security': nonce 1171 }, 1172 success: function (data) { 1173 1174 window.location.href = data; 1175 }, 1176 error: function (errorThrown) { 1177 1178 } 1179 });//end ajax 1180 1181} 1182//////////////////////////////////////////////////////////////////////////////////////////// 1183/// listing pay -jslint checked 1184//////////////////////////////////////////////////////////////////////////////////////////// 1185function wpestate_listing_pay(prop_id, selected_div, is_featured, is_upgrade) { 1186 "use strict"; 1187 var ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 1188 var nonce = jQuery('#wpestate_payments_nonce').val(); 1189 jQuery.ajax({ 1190 type: 'POST', 1191 url: ajaxurl, 1192 data: { 1193 'action': 'wpestate_ajax_listing_pay', 1194 'propid': prop_id, 1195 'is_featured': is_featured, 1196 'is_upgrade': is_upgrade, 1197 'security': nonce 1198 }, 1199 success: function (data) { 1200 window.location.href = data; 1201 }, 1202 error: function (errorThrown) { 1203 } 1204 });//end ajax 1205} 1206 1207//////////////////////////////////////////////////////////////////////////////////////////// 1208/// start filtering -jslint checked 1209//////////////////////////////////////////////////////////////////////////////////////////// 1210 1211/** 1212 * Resolve a single-select dropdown filter to a taxonomy payload array. 1213 * 1214 * Reads the active dropdown button `data-value`, ignores placeholder values, 1215 * then resolves the selected `<li data-value="...">` to `data-term-id` when present. 1216 * Returns a one-item array for AJAX payload compatibility. 1217 * 1218 * @param {string} filterButtonSelector jQuery selector for the dropdown trigger. 1219 * @param {Array<string>} placeholderValues Values that mean "no filter". 1220 * @returns {Array<string>} Selected taxonomy value array (term id preferred). 1221 */ 1222function wpestate_resolve_single_filter_taxonomy_values(filterButtonSelector, placeholderValues) { 1223 "use strict"; 1224 1225 // Step 1: Resolve button and current selected value. 1226 var filterButton = jQuery(filterButtonSelector).first(); 1227 if (filterButton.length === 0) { 1228 return []; 1229 } 1230 1231 var selectedValue = (filterButton.attr('data-value') || '').trim(); 1232 if (selectedValue === '') { 1233 return []; 1234 } 1235 1236 // Step 2: Skip placeholder values that represent "all". 1237 var normalizedSelectedValue = selectedValue.toLowerCase(); 1238 var normalizedPlaceholders = (placeholderValues || []).map(function (value) { 1239 return String(value).toLowerCase(); 1240 }); 1241 if (normalizedPlaceholders.indexOf(normalizedSelectedValue) !== -1) { 1242 return []; 1243 } 1244 1245 // Step 3: Resolve selected option term id from the related dropdown list. 1246 var resolvedValue = selectedValue; 1247 var dropdownId = filterButton.attr('id') || ''; 1248 if (dropdownId !== '') { 1249 var dropdownMenu = jQuery('ul[aria-labelledby="' + dropdownId + '"]').first(); 1250 if (dropdownMenu.length > 0) { 1251 var selectedListItem = dropdownMenu.find('li').filter(function () { 1252 return (jQuery(this).attr('data-value') || '') === selectedValue; 1253 }).first(); 1254 1255 if (selectedListItem.length > 0) { 1256 var termId = wpestate_get_term_id_from_element(selectedListItem); 1257 if (termId !== '') { 1258 resolvedValue = termId; 1259 } 1260 } 1261 } 1262 } 1263 1264 // Step 4: Return the normalized value as one-item array. 1265 return [resolvedValue]; 1266} 1267 1268/** 1269 * Collect taxonomy filters for wpestate_start_filtering payload. 1270 * 1271 * Uses canonical taxonomy names as payload keys and term ids as values 1272 * whenever term metadata exists on dropdown options. 1273 * 1274 * @returns {Object} Taxonomy payload object keyed by taxonomy names. 1275 */ 1276function wpestate_collect_start_filtering_taxonomies() { 1277 "use strict"; 1278 1279 // Step 1: Collect each single-select filter using canonical taxonomy keys. 1280 return { 1281 property_action_category: wpestate_resolve_single_filter_taxonomy_values('#a_filter_action', ['all', 'types', 'all-actions']), 1282 property_category: wpestate_resolve_single_filter_taxonomy_values('#a_filter_categ', ['all', 'categories', 'all-types']), 1283 property_status: wpestate_resolve_single_filter_taxonomy_values('#a_filter_status', ['all', 'property status']), 1284 property_features: wpestate_resolve_single_filter_taxonomy_values('#a_filter_features', ['all', 'property features']), 1285 property_county_state: wpestate_resolve_single_filter_taxonomy_values('#a_filter_county', ['all', 'states']), 1286 property_city: wpestate_resolve_single_filter_taxonomy_values('#a_filter_cities', ['all', 'cities', 'all-cities']), 1287 property_area: wpestate_resolve_single_filter_taxonomy_values('#a_filter_areas', ['all', 'areas', 'all-areas']) 1288 }; 1289} 1290 1291function wpestate_start_filtering(newpage) { 1292 "use strict"; 1293 jQuery('#gmap-loading').show(); 1294 jQuery('#grid_view').addClass('icon_selected'); 1295 jQuery('#list_view').removeClass('icon_selected'); 1296 1297 // Step 1: Collect canonical taxonomy payload (taxonomy keys + array values). 1298 var taxonomyPayload = wpestate_collect_start_filtering_taxonomies(); 1299 1300 // Step 2: Read ordering and page context values. 1301 var order = jQuery('#a_filter_order').attr('data-value'); 1302 var ajaxurl; 1303 var page_id; 1304 ajaxurl = ajaxcalls_vars.wpestate_ajax; 1305 page_id = jQuery('#page_idx').val(); 1306 1307 // Step 3: Read listing card rendering context from wrapper.
1308 var card_version = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-card_version'); 1309 var rownumber = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-rownumber'); 1310 var ishortcode = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-ishortcode'); 1311 var number = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-number'); 1312 var context = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-context'); 1313 1314 1315 1316 // Step 4: Show loading skeletons before the AJAX request. 1317 var align = ''; 1318 if (jQuery('.wpestate_filter_list_properties_wrapper').length > 0) { 1319 1320 wpestate_createSkeletons(jQuery('.wpestate_filter_list_properties_wrapper')); 1321 align = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-align'); 1322 } else { 1323 wpestate_createSkeletons(jQuery('#listing_ajax_container')); 1324 } 1325 var nonce = jQuery('#wpestate_ajax_filtering').val(); 1326 1327 // Step 5: Build the request payload with canonical taxonomy keys. 1328 var ajaxData = { 1329 'action': 'wpestate_ajax_filter_listings', 1330 'property_action_category': taxonomyPayload.property_action_category, 1331 'property_category': taxonomyPayload.property_category, 1332 'property_status': taxonomyPayload.property_status, 1333 'property_features': taxonomyPayload.property_features, 1334 'property_county_state': taxonomyPayload.property_county_state, 1335 'property_city': taxonomyPayload.property_city, 1336 'property_area': taxonomyPayload.property_area, 1337 'order': order, 1338 'newpage': newpage, 1339 'page_id': page_id, 1340 'align': align, 1341 'card_version': card_version, 1342 'rownumber': rownumber, 1343 'ishortcode': ishortcode, 1344 'number': number, 1345 'context': context, 1346 'security': nonce 1347 }; 1348 1349 jQuery.ajax({ 1350 type: 'POST', 1351 url: ajaxurl, 1352 dataType: 'json', 1353 data: ajaxData, 1354 success: function (data) { 1355 1356 jQuery('#listing_loader').hide(); 1357 if (jQuery('.wpestate_filter_list_properties_wrapper').length > 0) { 1358 1359 wpestate_replaceSkeletons(jQuery('.wpestate_filter_list_properties_wrapper'), data.to_show); 1360 } else { 1361 wpestate_replaceSkeletons(jQuery('#listing_ajax_container'), data.to_show); 1362 } 1363 1364 jQuery('.pagination_nojax').hide(); 1365 1366 // map update 1367 var no_results = parseInt(data.no_results); 1368 if (no_results !== 0) { 1369 wpestate_load_on_demand_pins(data.markers, no_results, 0); 1370 } else { 1371 wpestate_show_no_results(); 1372 } 1373 1374 jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function () { 1375 jQuery(this).parent().addClass('wrap_custom_image'); 1376 }); 1377 1378 jQuery('#gmap-loading').hide(); 1379 1380 }, 1381 error: function (errorThrown) { 1382 1383 } 1384 });//end ajax 1385} 1386 1387 1388 1389 1390 1391 1392 1393//////////////////////////////////////////////////////////////////////////////////////////// 1394// on ready -jslint checked 1395// developer listing on tab click !! 1396//////////////////////////////////////////////////////////////////////////////////////////// 1397jQuery(document).ready(function ($) { 1398 "use strict"; 1399 1400 wpestate_add_to_favorites(); 1401 wpestate_js_pagination_ajax(); 1402 wpestate_enable_not_logged_favorites(); 1403 wpestate_load_agency_developer_listings(); 1404 1405 1406 wpestate_agent_submit_email(); 1407 1408 wpestate_theme_slider_show_contact(); 1409 wpestate_enable_schedule_contact(); 1410 1411 1412 1413 1414 1415 1416 /////////////////////////////////////////////////////////////////////////////////////////// 1417 //// stripe cancel 1418 /////////////////////////////////////////////////////////////////////////////////////////// 1419 $('#stripe_cancel').on('click', function (event) { 1420 1421 var stripe_user_id, ajaxurl; 1422 stripe_user_id = $(this).attr('data-stripeid'); 1423 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1424 $('#stripe_cancel').text(ajaxcalls_vars.saving); 1425 var nonce = jQuery('#wpestate_stripe_cancel_nonce').val(); 1426 1427 $.ajax({ 1428 type: 'POST', 1429 url: ajaxurl, 1430 data: { 1431 'action': 'wpestate_cancel_stripe', 1432 'stripe_customer_id': stripe_user_id, 1433 'security': nonce, 1434 1435 }, 1436 success: function (data) { 1437 $('#stripe_cancel').text(ajaxcalls_vars.stripecancel); 1438 }, 1439 error: function (errorThrown) { 1440 } 1441 }); 1442 }); 1443 1444
1445 //////////////////////////////////////////////////////////////////////////////////////////// 1446 /// resend for approval 1447 /////////////////////////////////////////////////////////////////////////////////////////// 1448 $('.resend_pending').on('click', function (event) { 1449 1450 var prop_id = $(this).attr('data-listingid'); 1451 wpestate_resend_for_approval(prop_id, $(this)); 1452 }); 1453 1454 1455 1456 jQuery('#wpestate_stripe_booking_recurring').on('click', function () { 1457 1458 var modalid = jQuery(this).attr('data-modalid'); 1459 var modal = jQuery('#' + modalid); 1460 1461 modal.appendTo('body'); 1462 1463 modal.show(); 1464 jQuery('#' + modalid + ' .wpestate_stripe_form_1').show(); 1465 1466 wpestate_start_stripe(1, modalid); 1467 }); 1468 1469 /////////////////////////////////////////////////////////////////////////////////////////// 1470 //////// pack upgrade via paypal 1471 /////////////////////////////////////////////////////////////////////////////////////////// 1472 $('#pick_pack').on('click', function (event) { 1473 1474 var pay_paypal; 1475 pay_paypal = '<div class="modal fade" id="paypal_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body listing-submit">' + ajaxcalls_vars.paypal + '</div></div></div></div></div>'; 1476 jQuery('body').append(pay_paypal); 1477 jQuery('#paypal_modal').modal(); 1478 1479 1480 if ($('#pack_recuring').is(':checked')) { 1481 wpestate_recuring_pay_pack_via_paypal(); 1482 } else { 1483 wpestate_pay_pack_via_paypal(); 1484 } 1485 }); 1486 1487 /////////////////////////////////////////////////////////////////////////////////////////// 1488 //////// listing pay via paypal 1489 /////////////////////////////////////////////////////////////////////////////////////////// 1490 $('.listing_submit_normal').on('click', function (event) { 1491 var prop_id, featured_checker, is_featured, is_upgrade, pay_paypal; 1492 pay_paypal = '<div class="modal fade" id="paypal_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body listing-submit">' + ajaxcalls_vars.paypal + '</div></div></div></div></div>'; 1493 jQuery('body').append(pay_paypal); 1494 jQuery('#paypal_modal').modal(); 1495 1496 1497 prop_id = $(this).attr('data-listingid'); 1498 featured_checker = $(this).parent().find('input'); 1499 is_featured = 0; 1500 is_upgrade = 0; 1501 1502 if (featured_checker.prop('checked')) { 1503 is_featured = 1; 1504 } else { 1505 is_featured = 0; 1506 } 1507 1508 wpestate_listing_pay(prop_id, $(this), is_featured, is_upgrade); 1509 }); 1510 1511 jQuery('.woo_pay_submit').on('click', function () { 1512 var pay_paypal, prop_id, book_id, invoice_id, is_featured, is_upgrade, ajaxurl, depozit, is_submit, pack_id; 1513 prop_id = jQuery(this).attr('data-propid'); 1514 depozit = jQuery(this).attr('data-deposit'); 1515 is_featured = jQuery(this).attr('data-is_featured'); 1516 pack_id = jQuery('.package_selected').attr('data-id'); 1517 is_upgrade = 0; 1518 is_submit = 1; 1519 if (jQuery('#open_packages').length > 0) { 1520 is_submit = 0; 1521 } 1522 book_id = ''; 1523 invoice_id = ''; 1524 1525 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1526 jQuery.ajax({ 1527 type: 'POST', 1528 url: ajaxurl, 1529 data: { 1530 'action': 'wpestate_woo_pay', 1531 'propid': prop_id, 1532 'depozit': depozit, 1533 'is_submit': is_submit, 1534 'is_featured': is_featured, 1535 'pack_id': pack_id, 1536 'book_id': book_id, 1537 'invoiceid': invoice_id, 1538// 'price_pack' : price_pack, 1539// 'security' : nonce, 1540 }, 1541 success: function (data) { 1542 if (data !== false) { 1543 window.location.href = ajaxcalls_vars.checkout_url; 1544 } 1545 }, 1546 error: function (errorThrown) {} 1547 });//end ajax 1548 }); 1549 1550 $('.listing_upgrade').on('click', function (event) { 1551 var is_upgrade, is_featured, prop_id; 1552 is_upgrade = 1; 1553 is_featured = 0; 1554 prop_id = $(this).attr('data-listingid'); 1555 wpestate_listing_pay(prop_id, $(this), is_featured, is_upgrade); 1556 }); 1557 1558 1559
1560 /////////////////////////////////////////////////////////////////////////////////////////// 1561 /////// Property page + ajax call on contact 1562 /////////////////////////////////////////////////////////////////////////////////////////// 1563 1564 1565 1566 1567 /////////////////////////////////////////////////////////////////////////////////////////// 1568 //////// property listing listing 1569 //////////////////////////////////////////////////////////////////////////////////////////// 1570 1571 $('.listing_filters_head li').on('click', function (event) { 1572 1573 var pick, value, parent; 1574 pick = $(this).text(); 1575 value = $(this).attr('data-value'); 1576 parent = $(this).parent().parent(); 1577 parent.find('.filter_menu_trigger').text(pick).append('<span class="caret caret_filter"></span>').attr('data-value', value); 1578 parent.find('input:hidden').val(value); 1579 1580 wpestate_start_filtering(1); 1581 1582 1583 }); 1584 1585 1586 1587 1588 /////////////////////////////////////////////////////////////////////////////////////////// 1589 //////// advanced search filtering 1590 //////////////////////////////////////////////////////////////////////////////////////////// 1591 1592 jQuery(document).on('click', '.wpresidence_property_list_half_map_core .wpresidence_wrap_a_filter_order li', function (event) { 1593 console.log('wpresidence_half_map_filter_wrapper '); 1594 var pick, value, parent; 1595 pick = $(this).text(); 1596 value = $(this).attr('data-value'); 1597 parent = $(this).parent().parent(); 1598 parent.find('.filter_menu_trigger').text(pick).append('<span class="caret caret_filter"></span>').attr('data-value', value); 1599 parent.find('input:hidden').val(value); 1600 1601 if(mapfunctions_vars.custom_search==='yes'){ 1602 jQuery('.half-pagination').remove(); 1603 1604 console.log('dddddddddddddddddd '); 1605 wpestate_custom_search_start_filtering_ajax(1); 1606 }else{ 1607 1608 1609 console.log('lllllllllllll '); 1610 wpestate_start_filtering_ajax(1); 1611 } 1612 1613 }); 1614 1615 1616 $('.adv_listing_filters_head li').on('click', function (event) { 1617 1618 var pick, value, parent, args, page_id, ajaxurl; 1619 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1620 pick = $(this).text(); 1621 value = $(this).attr('data-value'); 1622 parent = $(this).parent().parent(); 1623 parent.find('.filter_menu_trigger').text(pick).append('<span class="caret caret_filter"></span>').attr('data-value', value); 1624 args = $('#searcharg').val(); 1625 page_id = $('#page_idx').val(); 1626 //$('#listing_ajax_container').empty(); 1627 //$('#listing_loader').show(); 1628 1629 1630 const listingContainer = jQuery('#listing_ajax_container'); 1631 wpestate_createSkeletons(listingContainer); 1632 1633 1634 var nonce = jQuery('#wpestate_search_nonce').val(); 1635 $.ajax({ 1636 type: 'POST', 1637 url: ajaxurl, 1638 1639 data: { 1640 'action': 'wpestate_advanced_search_filters', 1641 'args': args, 1642 'value': value, 1643 'page_id': page_id, 1644 'security': nonce 1645 }, 1646 success: function (data) { 1647 //$('#listing_loader').hide(); 1648 //$('#listing_ajax_container').append(data); 1649 wpestate_replaceSkeletons(listingContainer, data); 1650 1651 1652 wpestate_restart_js_after_ajax(); 1653 wpestate_add_pagination_orderby(); 1654 }, 1655 error: function (errorThrown) { 1656 } 1657 }); //end ajax 1658 }); 1659 1660 1661 function wpestate_add_pagination_orderby() { 1662 1663 var order = $('#a_filter_order').attr('data-value'); 1664 jQuery('.pagination a').each(function () { 1665 var href = $(this).attr('href'); 1666 href = href + "&order_search=" + order; 1667 $(this).attr('href', href); 1668 }); 1669 } 1670 1671 /////////////////////////////////////////////////////////////////////////////////////////// 1672 //////// Ajax add to favorites on listing 1673 //////////////////////////////////////////////////////////////////////////////////////////// 1674 $('.icon-fav,.remove_fav_dash').on('click', function (event) { 1675 event.stopPropagation(); 1676 var icon = $(this); 1677 wpestate_add_remove_favorite(icon); 1678 }); 1679 1680 1681 1682 1683 // remove from fav listing on user profile 1684 $('.icon-fav-on-remove').on('click', function (event) { 1685 event.stopPropagation(); 1686 $(this).parent().parent().remove(); 1687 1688 }); 1689 1690 1691 1692 1693
1694 /////////////////////////////////////////////////////////////////////////////////////////// 1695 //////// update profile 1696 //////////////////////////////////////////////////////////////////////////////////////////// 1697 $('#register_agent').on('click', function (event) { 1698 var firstname = $('#firstname').val(); 1699 var secondname = $('#secondname').val(); 1700 var useremail = $('#useremail').val(); 1701 var userphone = $('#userphone').val(); 1702 var usermobile = $('#usermobile').val(); 1703 var userskype = $('#userskype').val(); 1704 var usertitle = $('#usertitle').val(); 1705 var description = $('#about_me').val(); 1706 var userfacebook = $('#userfacebook').val(); 1707 var usertwitter = $('#usertwitter').val(); 1708 var userlinkedin = $('#userlinkedin').val(); 1709 var userpinterest = $('#userpinterest').val(); 1710 var userinstagram = $('#userinstagram').val(); 1711 var userurl = $('#website').val(); 1712 var agent_username = $('#agent_username').val(); 1713 var agent_password = $('#agent_password').val(); 1714 var agent_repassword = $('#agent_repassword').val(); 1715 var agent_category_submit = $('#agent_category_submit').val(); 1716 var agent_action_submit = $('#agent_action_submit').val(); 1717 var agent_city = $('#agent_city').val(); 1718 var agent_county = $('#agent_county').val(); 1719 var agent_member = $('#agent_member').val(); 1720 var agent_address = $('#agent_address').val(); 1721 1722 var agent_youtube = $('#useryoutube').val(); 1723 var agent_tiktok = $('#usertiktok').val(); 1724 var agent_telegram = $('#usertelegram').val(); 1725 var agent_vimeo = $('#uservimeo').val(); 1726 var agent_private_notes = $('#agent_private_notes').val(); 1727 1728 var agent_area = $('#agent_area').val(); 1729 var is_agent_edit = $('#is_agent_edit').val(); 1730 var user_id = $('#user_id').val(); 1731 var agent_id = $('#agent_id').val(); 1732 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1733 var securityprofile = $('#security-profile').val(); 1734 var upload_picture = $('#upload_picture').val(); 1735 var profile_image_url = $('#profile-image').attr('data-profileurl'); 1736 var profile_image_url_small = $('#profile-image').attr('data-smallprofileurl'); 1737 var acf_fields = wpestate_return_form_acf_fields('.field-group'); 1738 1739 // customparameters 1740 var agent_custom_label = []; 1741 $('.single_parameter_row .agent_custom_label').each(function () { 1742 agent_custom_label.push($(this).val()); 1743 }); 1744 1745 var agent_custom_value = []; 1746 $('.single_parameter_row .agent_custom_value').each(function () { 1747 agent_custom_value.push($(this).val()); 1748 }); 1749 var nonce = jQuery('#wpestate_register_agent_nonce').val(); 1750 1751 window.scrollTo(0, 0); 1752 1753 $('#profile_message').empty().append('<div class="login-alert">' + ajaxcalls_vars.saving + '<div>'); 1754 1755 1756 $.ajax({ 1757 type: 'POST', 1758 url: ajaxurl, 1759 dataType: 'json', 1760 data: { 1761 'action': 'wpestate_ajax_register_agent', 1762 'agent_username': agent_username, 1763 'agent_password': agent_password, 1764 'agent_repassword': agent_repassword, 1765 'firstname': firstname, 1766 'secondname': secondname, 1767 'useremail': useremail, 1768 'userphone': userphone, 1769 'usermobile': usermobile, 1770 'userskype': userskype, 1771 'usertitle': usertitle, 1772 'description': description, 1773 'upload_picture': upload_picture, 1774 'security-profile': securityprofile, 1775 'profile_image_url': profile_image_url, 1776 'profile_image_url_small': profile_image_url_small, 1777 'userfacebook': userfacebook, 1778 'usertwitter': usertwitter, 1779 'userlinkedin': userlinkedin, 1780 'userpinterest': userpinterest, 1781 'userinstagram': userinstagram, 1782 'userurl': userurl, 1783 'agent_category_submit': agent_category_submit, 1784 'agent_action_submit': agent_action_submit, 1785 'agent_city': agent_city, 1786 'agent_county': agent_county, 1787 'agent_area': agent_area, 1788 'agentedit': is_agent_edit, 1789 'userid': user_id, 1790 'agentid': agent_id, 1791 'agent_member': agent_member, 1792 'agent_address': agent_address, 1793 'agent_youtube':agent_youtube, 1794 'agent_tiktok':agent_tiktok, 1795 'agent_telegram':agent_telegram, 1796 'agent_vimeo': agent_vimeo, 1797 'agent_private_notes': agent_private_notes, 1798 'acf_fields': JSON.stringify(acf_fields), 1799 'agent_custom_label': agent_custom_label, 1800 'agent_custom_value': agent_custom_value, 1801 'security': nonce 1802 1803 }, 1804 success: function (data) { 1805 $('#profile_message').empty().append('<div class="login-alert">
1805' + data.mesaj + '<div>'); 1806 if (data.added) { 1807 setTimeout(function () { 1808 window.open(ajaxcalls_vars.agent_list, '_self', false); 1809 }, 1500); 1810 } 1811 }, 1812 error: function (errorThrown) { 1813 1814 } 1815 }); 1816 }); 1817 1818 1819 $('#update_profile').on('click', function (event) { 1820 1821 $('#profile_message').find('.login-alert').remove(); 1822 1823 var firstname, secondname, userurl, usermobile, userinstagram, userpinterest, userlinkedin, usertwitter, userfacebook, profile_image_url, profile_image_url_small, firstname, secondname, useremail, userphone, userskype, usertitle, description, ajaxurl, securityprofile, upload_picture; 1824 firstname = $('#firstname').val(); 1825 secondname = $('#secondname').val(); 1826 useremail = $('#useremail').val(); 1827 userphone = $('#userphone').val(); 1828 usermobile = $('#usermobile').val(); 1829 userskype = $('#userskype').val(); 1830 usertitle = $('#usertitle').val(); 1831 description = $('#about_me').val(); 1832 userfacebook = $('#userfacebook').val(); 1833 usertwitter = $('#usertwitter').val(); 1834 userlinkedin = $('#userlinkedin').val(); 1835 userpinterest = $('#userpinterest').val(); 1836 userinstagram = $('#userinstagram').val(); 1837 userurl = $('#website').val(); 1838 var hubspot_api = $('#hubspot_api').val(); 1839 var agent_member = $('#agent_member').val(); 1840 var agent_address= $('#agent_address').val(); 1841 1842 var agent_youtube = $('#useryoutube').val(); 1843 var agent_tiktok = $('#usertiktok').val(); 1844 var agent_telegram = $('#usertelegram').val(); 1845 var agent_vimeo = $('#uservimeo').val(); 1846 var agent_private_notes = $('#agent_private_notes').val(); 1847 1848 var agent_category_submit = $('#agent_category_submit').val(); 1849 var agent_action_submit = $('#agent_action_submit').val(); 1850 var agent_city = $('#agent_city').val(); 1851 var agent_county = $('#agent_county').val(); 1852 var agent_area = $('#agent_area').val(); 1853 var nonce = jQuery('#wpestate_update_profile_nonce').val(); 1854 1855 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1856 securityprofile = $('#security-profile').val(); 1857 upload_picture = $('#upload_picture').val(); 1858 profile_image_url = $('#profile-image').attr('data-profileurl'); 1859 profile_image_url_small = $('#profile-image').attr('data-smallprofileurl'); 1860 1861 var acf_fields = wpestate_return_form_acf_fields('.field-group'); 1862 1863 // customparameters 1864 var agent_custom_label = []; 1865 $('.cliche_row .agent_custom_label').each(function () { 1866 agent_custom_label.push($(this).val()); 1867 }); 1868 1869 var agent_custom_value = []; 1870 $('.cliche_row .agent_custom_value').each(function () { 1871 agent_custom_value.push($(this).val()); 1872 }); 1873 1874 1875 1876 window.scrollTo(0, 0); 1877 $('#profile_message').empty().append('<div class="login-alert">' + ajaxcalls_vars.saving + '<div>'); 1878 $.ajax({ 1879 type: 'POST', 1880 url: ajaxurl, 1881 data: { 1882 'action': 'wpestate_ajax_update_profile', 1883 'firstname': firstname, 1884 'secondname': secondname, 1885 'useremail': useremail, 1886 'userphone': userphone, 1887 'usermobile': usermobile, 1888 'userskype': userskype, 1889 'usertitle': usertitle, 1890 'description': description, 1891 'upload_picture': upload_picture, 1892 'security-profile': securityprofile, 1893 'profile_image_url': profile_image_url, 1894 'profile_image_url_small': profile_image_url_small, 1895 'userfacebook': userfacebook, 1896 'usertwitter': usertwitter, 1897 'userlinkedin': userlinkedin, 1898 'userpinterest': userpinterest, 1899 'userinstagram': userinstagram, 1900 'userurl': userurl, 1901 'agent_category_submit': agent_category_submit, 1902 'agent_action_submit': agent_action_submit, 1903 'agent_city': agent_city, 1904 'agent_county': agent_county, 1905 'agent_area': agent_area, 1906 'agent_member': agent_member, 1907 'agent_address':agent_address, 1908 'agent_youtube':agent_youtube, 1909 'agent_tiktok':agent_tiktok, 1910 'agent_telegram':agent_telegram, 1911 'agent_vimeo': agent_vimeo, 1912 'agent_private_notes': agent_private_notes, 1913 'agent_custom_label': agent_custom_label, 1914 'agent_custom_value': agent_custom_value, 1915 'acf_fields': JSON.stringify(acf_fields), 1916 'hubspot_api': hubspot_api, 1917 'security': nonce, 1918 1919 }, 1920 success: function (data) { 1921 1922 $('#profile_message').empty().append('<div class="login-alert">
1922' + data + '<div>'); 1923 window.scrollTo(0, 0); 1924 }, 1925 error: function (errorThrown) { 1926 } 1927 }); 1928 }); 1929 1930 1931 1932 $('#update_profile_agency').on('click', function () { 1933 1934 var hubspot_api, agency_opening_hours, agency_license, agency_long, agency_lat, agency_address, agency_area, agency_county, agency_city, agency_action_submit, agency_action_submit, agency_category_submit, agency_taxes, agency_website, agency_languages, agency_name, userurl, usermobile, userinstagram, userpinterest, userlinkedin, usertwitter, userfacebook, profile_image_url, profile_image_url_small, firstname, secondname, useremail, userphone, userskype, usertitle, description, ajaxurl, securityprofile, upload_picture; 1935 agency_name = $('#agency_title').val(); 1936 useremail = $('#useremail').val(); 1937 userphone = $('#userphone').val(); 1938 usermobile = $('#usermobile').val(); 1939 userskype = $('#userskype').val(); 1940 1941 description = $('#about_me').val(); 1942 userfacebook = $('#userfacebook').val(); 1943 usertwitter = $('#usertwitter').val(); 1944 userlinkedin = $('#userlinkedin').val(); 1945 userpinterest = $('#userpinterest').val(); 1946 userinstagram = $('#userinstagram').val(); 1947 1948 var useryoutube = $('#useryoutube').val(); 1949 var usertiktok = $('#usertiktok').val(); 1950 var usertelegram = $('#usertelegram').val(); 1951 var uservimeo = $('#uservimeo').val(); 1952 var agency_private_notes = $('#agency_private_notes').val(); 1953 1954 1955 1956 agency_languages = $('#agency_languages').val(); 1957 agency_website = $('#agency_website').val(); 1958 agency_taxes = $('#agency_taxes').val(); 1959 agency_license = $('#agency_license').val(); 1960 1961 1962 agency_category_submit = $('#agency_category_submit').val(); 1963 agency_action_submit = $('#agency_action_submit').val(); 1964 agency_city = $('#agency_city').val(); 1965 agency_county = $('#agency_county').val(); 1966 agency_area = $('#agency_area').val(); 1967 agency_address = $('#agency_address').val(); 1968 agency_lat = $('#agency_lat').val(); 1969 agency_long = $('#agency_long').val(); 1970 agency_opening_hours = $('#agency_opening_hours ').val(); 1971 hubspot_api = $('#hubspot_api ').val(); 1972 securityprofile = $('#security-profile').val(); 1973 upload_picture = $('#upload_picture').val(); 1974 profile_image_url = $('#profile-image').attr('data-profileurl'); 1975 profile_image_url_small = $('#profile-image').attr('data-smallprofileurl'); 1976 1977 var acf_fields = wpestate_return_form_acf_fields('.field-group'); 1978 1979 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1980 1981 var nonce = jQuery('#wpestate_update_profile_nonce').val(); 1982 $('#profile_message').empty().append('<div class="login-alert">' + ajaxcalls_vars.saving + '<div>'); 1983 window.scrollTo(0, 0); 1984 $.ajax({ 1985 type: 'POST', 1986 url: ajaxurl, 1987 data: { 1988 'action': 'wpestate_ajax_update_profile_agency', 1989 'agency_name': agency_name, 1990 'useremail': useremail, 1991 'userphone': userphone, 1992 'usermobile': usermobile, 1993 'userskype': userskype, 1994 'usertitle': usertitle, 1995 'description': description, 1996 'upload_picture': upload_picture, 1997 'security-profile': securityprofile, 1998 'profile_image_url': profile_image_url, 1999 'profile_image_url_small': profile_image_url_small, 2000 'userfacebook': userfacebook, 2001 'usertwitter': usertwitter, 2002 'userlinkedin': userlinkedin, 2003 'userpinterest': userpinterest, 2004 'userinstagram': userinstagram, 2005 'useryoutube':useryoutube, 2006 'usertiktok':usertiktok, 2007 'usertelegram':usertelegram, 2008 'uservimeo':uservimeo, 2009 'agency_private_notes':agency_private_notes, 2010 'userurl': userurl, 2011 'agency_languages': agency_languages, 2012 'agency_website': agency_website, 2013 'agency_taxes': agency_taxes, 2014 'agency_license': agency_license, 2015 'agency_category_submit': agency_category_submit, 2016 'agency_action_submit': agency_action_submit, 2017 'agency_city': agency_city, 2018 'agency_county': agency_county, 2019 'agency_area': agency_area, 2020 'agency_address': agency_address, 2021 'agency_lat': agency_lat, 2022 'agency_opening_hours': agency_opening_hours, 2023 'agency_long': agency_long, 2024 'hubspot_api': hubspot_api, 2025 'acf_fields': JSON.stringify(acf_fields), 2026 'security': nonce 2027 }, 2028 success: function (data) { 2029 $('#profile_message').empty().append('<div class="login-alert">
2029' + data + '<div>'); 2030 window.scrollTo(0, 0); 2031 }, 2032 error: function (errorThrown) { 2033 console.log(errorThrown); 2034 } 2035 }); 2036 }); 2037 2038 2039 2040// update developer profile 2041 $('#update_profile_developer').on('click', function () { 2042 2043 var hubspot_api, developer_license, developer_long, developer_lat, developer_address, developer_area, developer_county, developer_city, developer_action_submit, developer_action_submit, developer_category_submit, developer_taxes, developer_website, developer_languages, developer_name, userurl, usermobile, userinstagram, userpinterest, userlinkedin, usertwitter, userfacebook, profile_image_url, profile_image_url_small, firstname, secondname, useremail, userphone, userskype, usertitle, description, ajaxurl, securityprofile, upload_picture; 2044 developer_name = $('#developer_title').val(); 2045 useremail = $('#useremail').val(); 2046 userphone = $('#userphone').val(); 2047 usermobile = $('#usermobile').val(); 2048 userskype = $('#userskype').val(); 2049 2050 description = $('#about_me').val(); 2051 userfacebook = $('#userfacebook').val(); 2052 usertwitter = $('#usertwitter').val(); 2053 userlinkedin = $('#userlinkedin').val(); 2054 userpinterest = $('#userpinterest').val(); 2055 userinstagram = $('#userinstagram').val(); 2056 2057 2058 var useryoutube = $('#useryoutube').val(); 2059 var usertiktok = $('#usertiktok').val(); 2060 var usertelegram = $('#usertelegram').val(); 2061 var uservimeo = $('#uservimeo').val(); 2062 var developer_private_notes = $('#developer_private_notes').val(); 2063 2064 2065 2066 developer_languages = $('#developer_languages').val(); 2067 developer_website = $('#developer_website').val(); 2068 developer_taxes = $('#developer_taxes').val(); 2069 developer_license = $('#developer_license').val(); 2070 2071 2072 developer_category_submit = $('#developer_category_submit').val(); 2073 developer_action_submit = $('#developer_action_submit').val(); 2074 developer_city = $('#developer_city').val(); 2075 developer_county = $('#developer_county').val(); 2076 developer_area = $('#developer_area').val(); 2077 developer_address = $('#developer_address').val(); 2078 developer_lat = $('#developer_lat').val(); 2079 developer_long = $('#developer_long').val(); 2080 securityprofile = $('#security-profile').val(); 2081 upload_picture = $('#upload_picture').val(); 2082 profile_image_url = $('#profile-image').attr('data-profileurl'); 2083 profile_image_url_small = $('#profile-image').attr('data-smallprofileurl'); 2084 hubspot_api = $('#hubspot_api').val(); 2085 2086 var acf_fields = wpestate_return_form_acf_fields('.field-group'); 2087 2088 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2089 var nonce = jQuery('#wpestate_update_profile_nonce').val(); 2090 $('#profile_message').empty().append('<div class="login-alert">' + ajaxcalls_vars.saving + '<div>'); 2091 window.scrollTo(0, 0); 2092 $.ajax({ 2093 type: 'POST', 2094 url: ajaxurl, 2095 data: { 2096 'action': 'wpestate_ajax_update_profile_developer', 2097 'developer_name': developer_name, 2098 'useremail': useremail, 2099 'userphone': userphone, 2100 'usermobile': usermobile, 2101 'userskype': userskype, 2102 'usertitle': usertitle, 2103 'description': description, 2104 'upload_picture': upload_picture, 2105 'security-profile': securityprofile, 2106 'profile_image_url': profile_image_url, 2107 'profile_image_url_small': profile_image_url_small, 2108 'userfacebook': userfacebook, 2109 'usertwitter': usertwitter, 2110 'userlinkedin': userlinkedin, 2111 'userpinterest': userpinterest, 2112 'userinstagram': userinstagram, 2113 'userurl': userurl, 2114 'developer_languages': developer_languages, 2115 'developer_website': developer_website, 2116 'developer_taxes': developer_taxes, 2117 'developer_license': developer_license, 2118 'developer_category_submit': developer_category_submit, 2119 'developer_action_submit': developer_action_submit, 2120 'developer_city': developer_city, 2121 'developer_county': developer_county, 2122 'developer_area': developer_area, 2123 'developer_address': developer_address, 2124 'developer_lat': developer_lat, 2125 'developer_long': developer_long, 2126 'hubspot_api': hubspot_api, 2127 'useryoutube':useryoutube, 2128 'usertiktok':usertiktok,
2129 'usertelegram':usertelegram, 2130 'uservimeo':uservimeo, 2131 'developer_private_notes':developer_private_notes, 2132 'acf_fields': JSON.stringify(acf_fields), 2133 'security': nonce 2134 }, 2135 success: function (data) { 2136 $('#profile_message').empty().append('<div class="login-alert">' + data + '<div>'); 2137 window.scrollTo(0, 0); 2138 }, 2139 error: function (errorThrown) { 2140 } 2141 }); 2142 }); 2143 2144 //delete profile 2145 2146 $('#delete_profile').on('click', function (event) { 2147 var ajaxurl; 2148 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2149 var nonce = jQuery('#wpestate_update_profile_nonce').val(); 2150 var result = confirm(ajaxcalls_vars.delete_account); 2151 if (result) { 2152 //Logic to delete the item 2153 2154 $.ajax({ 2155 type: 'POST', 2156 url: ajaxurl, 2157 data: { 2158 'action': 'wpestate_delete_profile', 2159 'security': nonce, 2160 }, 2161 success: function (data) { 2162 window.location = '/'; 2163 }, 2164 error: function (errorThrown) { 2165 2166 } 2167 }); 2168 } 2169 }); 2170 2171 //end delete profile 2172 2173}); // end ready jquery 2174//End ready ******************************************************************** 2175 2176 2177/** 2178 * Handles the loading of agency/developer listings via AJAX. 2179 * This function is triggered when a user clicks on a term bar item. 2180 */ 2181function wpestate_load_agency_developer_listings() { 2182 jQuery('.term_bar_item, .listing_load_more').on('click', function (event) { 2183 2184 2185 // Select relevant DOM elements 2186 var $this = jQuery(this); 2187 var $listingParent = $this.parents('.single_listing_block'); 2188 var listings_per_page= $listingParent.attr('data-listings_per_page'); 2189 var rownumber= $listingParent.attr('data-rownumber'); 2190 2191 var $loadMoreButton = jQuery('.load_more_ajax_cont .listing_load_more', $listingParent); 2192 var $agencyListingsWrapper = jQuery('.agency_listings_wrapper'); 2193 var $listingLoader = jQuery('#listing_loader'); 2194 var $termBarWrapper = jQuery('.term_bar_wrapper'); 2195 var $areadyLoadedItems = jQuery('.listing_wrapper', $listingParent).length; 2196 2197 var $page_with_sidebar = 0; 2198 if(jQuery('#primary_sidebar_wrapper').length > 0){ 2199 $page_with_sidebar = 1; 2200 } 2201 2202 // Display load more button 2203 $loadMoreButton.fadeIn(); 2204 2205 2206 // Perform AJAX request 2207 if(!$this.hasClass('listing_load_more')){ 2208 //$agencyListingsWrapper.empty(); 2209 $areadyLoadedItems=0; 2210 2211 // Update active term styling 2212 jQuery('.term_bar_item').removeClass('active_term'); 2213 $this.addClass('active_term'); 2214 2215 } 2216 2217 2218 2219 2220 var $active_tab = jQuery('.active_term', $listingParent); 2221 var term_name = jQuery($active_tab).attr('data-term_name'); 2222 2223 2224 2225 // Prepare AJAX data 2226 var ajaxData = { 2227 action: 'wpestate_agency_listings', 2228 listings_per_page:listings_per_page, 2229 rownumber:rownumber, 2230 term_name: $this.attr('data-term_name'), 2231 agency_id: $termBarWrapper.attr('data-agency_id'), 2232 agent_id: $termBarWrapper.attr('data-agent_id'), 2233 post_id: $termBarWrapper.attr('data-post_id'), 2234 term_name: term_name, 2235 loaded: $areadyLoadedItems, 2236 is_agency: jQuery('.single-estate_agency').length > 0 ? 1 : 0, 2237 page_with_sidebar: $page_with_sidebar, 2238 security: jQuery('#wpestate_developer_listing_nonce').val() 2239 }; 2240 2241 2242 2243 2244 2245 const listingContainer = jQuery('.agency_listings_wrapper'); 2246 2247 if(!$this.hasClass('listing_load_more')){ 2248 wpestate_createSkeletons(listingContainer); 2249 }else{ 2250 wpestate_createSkeletons(listingContainer,true); 2251 } 2252 2253 // $listingLoader.show(); 2254 2255 jQuery.ajax({ 2256 type: 'POST', 2257 url: ajaxcalls_vars.admin_url + 'admin-ajax.php', 2258 data: ajaxData, 2259 dataType: 'json', 2260 success: function (response) { 2261 $listingLoader.hide(); 2262 if (response.success) { 2263 2264 if(response.data.found_posts > 0){ 2265 if(!$this.hasClass('listing_load_more')){ 2266 //$agencyListingsWrapper.html(response.data.html); 2267 wpestate_replaceSkeletons(listingContainer, response.data.html); 2268 2269 }else{ 2270 2271 //$agencyListingsWrapper.append(response.data.html); 2272 wpestate_replaceSkeletons(listingContainer,response.data.html); 2273 2274 } 2275 2276 wpestate_restart_js_after_ajax(); 2277 }else{ 2278 //$agencyListingsWrapper.append(response.data.html); 2279 wpestate_replaceSkeletons(listingContainer,response.data.html); 2280 if($this.hasClass('listing_load_more')){ 2281 $this.hide(); 2282 } 2283 } 2284 2285 2286 2287 } else { 2288 $agencyListingsWrapper.html('<p>' + response.data.message + '</p>'); 2289 } 2290 }, 2291 error: function (jqXHR, textStatus, errorThrown) { 2292 console.error('AJAX request failed:', textStatus, errorThrown); 2293 $listingLoader.hide(); 2294 $agencyListingsWrapper.html('<p>Error loading listings. Please try again.</p>'); 2295 } 2296 }); 2297 }); 2298} 2299 2300 2301function wpestate_add_to_favorites() { 2302 2303 2304 jQuery('#add_favorites').on('click', function (event) { 2305 2306 var post_id, ajaxurl; 2307 post_id = jQuery('#add_favorites').attr('data-postid'); 2308 var icon = jQuery('#add_favorites'); 2309 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2310 var nonce = jQuery('#wpestate_ajax_filtering').val(); 2311 var use_favorite_login = ajaxcalls_vars.favorites_login; 2312 if(use_favorite_login=="no"){ 2313 wpestate_add_remove_favorite_local_storage_single(icon,post_id); 2314 return; 2315 } 2316 2317 2318 2319 if (parseInt(ajaxcalls_vars.userid, 10) === 0) { 2320 if (!Modernizr.mq('only all and (max-width: 768px)')) { 2321 jQuery('#modal_login_wrapper').show(); 2322 jQuery('#modal_login_wrapper').find('[autofocus]').focus(); 2323 jQuery('.loginpop').val('1'); 2324 } else { 2325 jQuery('.mobile-trigger-user').trigger('click'); 2326 } 2327 2328 } else { 2329 jQuery('#add_favorites').text(ajaxcalls_vars.saving); 2330 jQuery.ajax({ 2331 type: 'POST', 2332 url: ajaxurl, 2333 dataType: 'json', 2334 data: { 2335 'action': 'wpestate_ajax_add_fav', 2336 'post_id': post_id, 2337 'security': nonce 2338 }, 2339 success: function (data) { 2340 if (data.added) { 2341 jQuery('#add_favorites').removeClass('isnotfavorite').addClass('isfavorite').attr('title', ajaxcalls_vars.remove_favorite); 2342 jQuery('#add_favorites').html('<i class="fas fa-heart"></i>' + ajaxcalls_vars.favorite); 2343 2344 // Refresh the Bootstrap tooltip if it exists 2345 if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) { 2346 var tooltipInstance = bootstrap.Tooltip.getInstance(icon[0]); 2347 if (tooltipInstance) { 2348 tooltipInstance.setContent({ 2349 '.tooltip-inner': ajaxcalls_vars.remove_fav 2350 }); 2351 } 2352 } 2353 2354 2355 } else { 2356 jQuery('#add_favorites').removeClass('isfavorite').addClass('isnotfavorite').attr('title', ajaxcalls_vars.add_favorite); 2357 jQuery('#add_favorites').html('<i class="far fa-heart"></i>' + ajaxcalls_vars.favorite); 2358 2359 // Refresh the Bootstrap tooltip if it exists 2360 if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) { 2361 var tooltipInstance = bootstrap.Tooltip.getInstance(icon[0]); 2362 if (tooltipInstance) { 2363 tooltipInstance.setContent({ 2364 '.tooltip-inner': ajaxcalls_vars.remove_fav 2365 }); 2366 } 2367 } 2368 2369 } 2370 }, 2371 error: function (errorThrown) { 2372 } 2373 }); //end ajax 2374 }// end check login 2375 }); 2376} 2377
2378/////////////////////////////////////////////////////////////////////////////////////////// 2379/////// Property page + ajax call on contact 2380/////////////////////////////////////////////////////////////////////////////////////////// 2381function wpestate_theme_slider_show_contact() { 2382 jQuery('.wpestate_theme_slider_contact_agent').on('click', function () { 2383 var acesta = jQuery(this).parent().parent(); 2384 acesta.find('#show_contact').text(ajaxcalls_vars.contact_agent); 2385 acesta.find('.theme_slider_contact_form_wrapper').show('0').toggleClass('theme_slider_contact_form_wrapper_visible'); 2386 jQuery('#estate-carousel').carousel('pause'); 2387 2388 }); 2389 2390 2391 2392 jQuery('.theme_slider_details_modal_close').on('click', function () { 2393 jQuery(this).parent().removeClass('theme_slider_contact_form_wrapper_visible'); 2394 jQuery('#estate-carousel').carousel('cycle'); 2395 }); 2396 2397 jQuery('.theme_slider_contact_form_wrapper').on('click', function (event) { 2398 event.stopPropagation(); 2399 }); 2400 2401 2402} 2403 2404 2405/** 2406 * Enable Schedule Contact Functionality 2407 * 2408 * This function sets up event handlers for the schedule meeting functionality 2409 * and initializes the datepicker for schedule day selection. 2410 * 2411 * @package WpResidence 2412 * @subpackage PropertyDetails 2413 * @since 3.0.3 2414 * 2415 * Dependencies: 2416 * - jQuery 2417 * - jQuery UI Datepicker 2418 * 2419 * Usage: Call this function after DOM is ready and dependencies are loaded. 2420 */ 2421 2422function wpestate_enable_schedule_contact() { 2423 // Toggle schedule wrapper visibility when clicking on schedule meeting button 2424 jQuery('.schedule_meeting').on('click', function (event) { 2425 var parent = jQuery(this).parent().parent(); 2426 var scheduleWrapper = parent.find('.schedule_wrapper'); 2427 2428 scheduleWrapper.slideToggle(400, function() { 2429 scheduleWrapper.css('display', scheduleWrapper.is(':visible') ? 'flex' : 'none'); 2430 }); 2431 }); 2432 2433 2434 2435 // Initialize datepicker for schedule day input with position correction 2436 jQuery(".schedule_day, #schedule_day").datepicker({ 2437 dateFormat: "yy-mm-dd", 2438 beforeShow: function(input, inst) { 2439 // Position correction 2440 setTimeout(function() { 2441 inst.dpDiv.css({ 2442 position: 'absolute', 2443 top: jQuery(input).offset().top + jQuery(input).outerHeight(), 2444 left: jQuery(input).offset().left 2445 }); 2446 }, 0); 2447 } 2448 }).datepicker('widget').wrap('<div class="ll-skin-melon"/>'); 2449} 2450 2451 2452function wpestate_agent_submit_email() { 2453 jQuery('.wpresidence_elementor_form').on('submit', function (event) { 2454 event.preventDefault(); 2455 var form_submit = jQuery('.wpresidence_elementor_form').find('.agent_submit_class_elementor'); 2456 process_form_submit(form_submit); 2457 }); 2458 2459 jQuery('.agent_submit_class').on('click', function (event) { 2460 process_form_submit(jQuery(this)); 2461 }); 2462 2463 jQuery('.message_submit').on('click', function (event) { 2464 process_form_submit(jQuery(this)); 2465 }); 2466} 2467 2468 2469function process_form_submit(form_submit) { 2470 2471 var parent, contact_name, contact_email, contact_phone, contact_coment, agent_id, property_id, nonce, ajaxurl; 2472 parent = form_submit.closest('.wpestate_contact_form_parent'); 2473 2474 var is_private_message='no'; 2475 if(form_submit.hasClass('message_submit')){ 2476 is_private_message='yes'; 2477 } 2478 2479 2480 contact_name = parent.find('#agent_contact_name').val(); 2481 contact_email = parent.find('#agent_user_email').val(); 2482 contact_phone = parent.find('#agent_phone').val(); 2483 contact_coment = parent.find('#agent_comment').val(); 2484 agent_id = parent.find('#agent_id').val(); 2485 property_id = parent.find('#agent_property_id').val(); 2486 2487 nonce = parent.find('#agent_property_ajax_nonce').val(); 2488 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2489 2490 var schedule_day = parent.find('.schedule_day').val(); 2491 var schedule_hour = parent.find('.schedule_hour').val(); 2492 var schedule_mode ='in_person'; 2493 2494 2495 2496 if( parent.hasClass('wpestate_schedule_tour_wrapper_content') || 2497 parent.hasClass('wpestate_shedule_tour_wrapper_type2') || 2498 parent.hasClass('wpestate_schedule_tour_wrapper') ){ 2499 2500 schedule_day = parent.find('.shedule_day_option_selected').attr('data-scheudle-day'); 2501 schedule_hour = parent.find('#wpestate_schedule_tour_time').val(); 2502 2503 var schedule_mode_button = parent.find('.shedule_option_selected'); 2504 if( schedule_mode_button.hasClass('schedule_video_chat') ){ 2505 schedule_mode ='video_chat'; 2506 } 2507 } 2508 2509 2510 var is_elementor = 0; 2511 if (form_submit.parents('.wpresidence_elementor_form').length) { 2512 parent = form_submit.parents('.wpresidence_elementor_form'); 2513 contact_name = parent.find('#form-field-name').val(); 2514 contact_email = parent.find('#form-field-email').val(); 2515 contact_coment = parent.find('#form-field-message').val(); 2516 contact_phone = parent.find('input[name="phone"]').val(); 2517 nonce = parent.find('#agent_property_ajax_nonce').val(); 2518 is_elementor = parent.find('#contact_form_elementor').val(); 2519 var wpresidence_form_id = parent.find('#wpresidence_form_id').val(); 2520 var elementor_email_subject = parent.find('#elementor_email_subject').val(); 2521 2522 var temp_details; 2523 temp_details = ''; 2524 var elementor_form = form_submit.parents('.wpresidence_elementor_form'); 2525 var form_items = elementor_form.find('.elementor-field'); 2526 var label_name =''; 2527 var labelElement; 2528 form_items.each(function () { 2529 2530 labelElement=jQuery(this).parent().find('.elementor-field-label'); 2531 2532 if (labelElement.length > 0) { 2533 label_name = labelElement.text(); 2534 label_name = label_name.replace('*', ''); 2535 } else { 2536 label_name = jQuery(this).attr('name') 2537 } 2538 2539 temp_details = temp_details + label_name + ": " + jQuery(this).val() + "/n"; 2540 }); 2541 2542 contact_coment = temp_details ; 2543 2544 } 2545 2546 if (parent.find('.wpestate_agree_gdpr').length > 0) { 2547 if (!parent.find('.wpestate_agree_gdpr').is(':checked')) { 2548 parent.find('#alert-agent-contact').empty().append(ajaxcalls_vars.gdpr_terms); 2549 return; 2550 } 2551 } 2552 2553 2554 2555 parent.find('#alert-agent-contact').empty().append(ajaxcalls_vars.sending); 2556 2557 jQuery.ajax({ 2558 type: 'POST', 2559 dataType: 'json', 2560 url: ajaxurl, 2561 data: { 2562 'action': 'wpestate_ajax_agent_contact_form', 2563 'name': contact_name, 2564 'email': contact_email, 2565 'phone': contact_phone, 2566 'comment': contact_coment, 2567 'agent_id': agent_id, 2568 'propid': property_id, 2569 'schedule_day': schedule_day, 2570 'schedule_hour': schedule_hour, 2571 'schedule_mode':schedule_mode, 2572 'elementor_wpresidence_form_id': wpresidence_form_id, 2573 'elementor_email_subject': elementor_email_subject, 2574 'is_elementor': is_elementor, 2575 'is_private_message':is_private_message, 2576 'nonce': nonce 2577 }, 2578 success: function (data) { 2579 2580 if (data.sent) { 2581 parent.find('#agent_contact_name').val(''); 2582 parent.find('#agent_user_email').val(''); 2583 parent.find('#agent_phone').val(''); 2584 parent.find('#agent_comment').val(''); 2585 parent.find('.schedule_day').val(''); 2586 parent.find('#schedule_hour').val(''); 2587 parent.find('#alert-agent-contact').addClass(' wpestate-agent-contact-sent ').empty().append(data.response); 2588 2589 2590 if (typeof (form_items) !== 'undefined') { 2591 form_items.each(function () { 2592 jQuery(this).val(''); 2593 }); 2594 } 2595 2596 } else { 2597 parent.find('#alert-agent-contact').empty().append(data.response); 2598 } 2599 2600 }, 2601 error: function (errorThrown) { 2602 2603 } 2604 }); 2605 2606 2607 2608 jQuery.ajax({ 2609 type: 'POST', 2610 // dataType: 'json', 2611 url: ajaxurl, 2612 data: { 2613 'action': 'wpestate_ajax_agent_contact_form_forcrm', 2614 'name': contact_name, 2615 'email': contact_email, 2616 'phone': contact_phone, 2617 'comment': contact_coment, 2618 'agent_id': agent_id, 2619 'propid': property_id, 2620 'schedule_day': schedule_day, 2621 'schedule_hour': schedule_hour, 2622 'schedule_mode':schedule_mode, 2623 'nonce': nonce 2624 }, 2625 success: function (data) { 2626 }, 2627 error: function (errorThrown) { 2628 2629 } 2630 }); 2631 2632 2633} 2634 2635 2636/////////////////////////////////////////////////////////////////////////////////////////// 2637/////// Property page + ajax call on contact 2638/////////////////////////////////////////////////////////////////////////////////////////// 2639 2640 2641function wpestate_enable_share_unit(){ 2642 2643 jQuery('.share_list').unbind('click'); 2644 jQuery('.share_list').on( 'click', function(event) { 2645 event.stopPropagation(); 2646 var sharediv=jQuery(this).parent().find('.share_unit');
2647 sharediv.toggle(); 2648 jQuery(this).toggleClass('share_on'); 2649 }); 2650 2651} 2652 2653function setCookie(cname, cvalue, exdays) { 2654 const d = new Date(); 2655 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 2656 let expires = "expires="+d.toUTCString(); 2657 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 2658 } 2659 2660 2661function wpestate_enable_not_logged_favorites(){ 2662 2663 var use_favorite_login = ajaxcalls_vars.favorites_login; 2664 2665 if(use_favorite_login=="yes"){ 2666 return; 2667 } 2668 2669 var current_favorites = window.localStorage.getItem('wpestate_favorites'); 2670 setCookie('wpestate_favorites',current_favorites,10); 2671 var prop_ids=''; 2672 2673 if( current_favorites!==null ){ 2674 prop_ids = jQuery.map(current_favorites.split(','), function(value){ 2675 return parseInt(value); 2676 }); 2677 } 2678 2679 jQuery('.icon-fav').each(function(){ 2680 var icon=jQuery(this); 2681 var property_id=icon.attr('data-postid'); 2682 property_id=parseInt(property_id); 2683 var index = prop_ids.indexOf( property_id ); 2684 2685 if (index > -1) { 2686 icon.removeClass('icon-fav-off').addClass('icon-fav-on'); 2687 icon.attr('title', ajaxcalls_vars.remove_fav); 2688 2689 }else{ 2690 icon.removeClass('icon-fav-on').addClass('icon-fav-off'); 2691 icon.attr('title', ajaxcalls_vars.add_favorite); 2692 2693 } 2694 }) 2695 2696 2697 if(jQuery('#add_favorites').length>0){ 2698 var property_id=jQuery('#add_favorites').attr('data-postid'); 2699 property_id=parseInt(property_id); 2700 var index = prop_ids.indexOf( property_id ); 2701 2702 if (index > -1) { 2703 jQuery('#add_favorites').removeClass('isnotfavorite').addClass('isfavorite').attr('title', ajaxcalls_vars.remove_favorite); 2704 jQuery('#add_favorites').html('<i class="fas fa-heart"></i>' + ajaxcalls_vars.favorite); 2705 2706 } 2707 } 2708 2709} 2710 2711 2712 2713/** 2714 * Returns ACF fields from a given container. 2715 * 2716 * This function collects input, textarea, and select elements within the specified container 2717 * and returns an Array containing their values, formatted according to ACF field naming conventions. 2718 * 2719 * @param {string} container - The CSS selector for the container to search within. 2720 * @returns {Array} acf_fields - An Array containing ACF field names and their corresponding values. 2721 */ 2722function wpestate_return_form_acf_fields( container = '') { 2723 2724 var acf_fields = {}; 2725 2726 if ( !jQuery(container).length ) { 2727 return acf_fields; 2728 } 2729 2730 jQuery(container).find('input, textarea, select').each(function() { 2731 var $field = jQuery(this); 2732 var fieldName = $field.attr('name'); 2733 2734 if (!fieldName || !fieldName.startsWith('acf_fields[')) { 2735 return; 2736 } 2737 2738 // Extract field name from acf_fields[field_name] format 2739 var matches = fieldName.match(/acf_fields\[([^\]]+)\]/); 2740 if (!matches) { 2741 return; 2742 } 2743 2744 var cleanFieldName = matches[1]; 2745 2746 if ($field.is(':checkbox')) { 2747 // Handle checkboxes 2748 if ($field.attr('name').includes('[]')) { 2749 // Multiple checkboxes (checkbox field type) 2750 if (!acf_fields[cleanFieldName]) { 2751 acf_fields[cleanFieldName] = []; 2752 } 2753 if ($field.is(':checked')) { 2754 acf_fields[cleanFieldName].push($field.val()); 2755 } 2756 } else { 2757 // Single checkbox (true/false field type) 2758 acf_fields[cleanFieldName] = $field.is(':checked') ? $field.val() : ''; 2759 } 2760 } else if ($field.is(':radio')) { 2761 // Handle radio buttons 2762 if ($field.is(':checked')) { 2763 acf_fields[cleanFieldName] = $field.val(); 2764 } 2765 } else { 2766 // Handle other input types 2767 acf_fields[cleanFieldName] = $field.val(); 2768 } 2769 }); 2770 return acf_fields; 2771}
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.