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