1/*global $, jQuery, ajaxcalls_vars, document,placeCircle,google,wpestate_lazy_load_carousel_property_unit, control_vars, window, control_vars, wpestate_start_filtering, wpestate_login_via_facebook, wpestate_login_via_google, wpestate_login_via_google, wpestate_enable_actions_modal, wpestate_show_login_form, wpestate_add_remove_favorite, wpestate_hover_action_pin, wpestate_return_hover_action_pin, wpestate_restart_js_after_ajax, wpestate_set_filter_pins, map, mapfunctions_vars, wpestate_get_custom_value, wpestate_safe_redirect*/ 2 3////////////////////////////////////////////////////////////////////////////////////////////// 4/// wpestate_safe_redirect 5/// 6/// Navigate window.location.href to a URL returned from an AJAX handler, 7/// but only if the value is a plain string and uses a safe scheme. Blocks 8/// javascript:, data:, vbscript: and other script-bearing schemes so a 9/// compromised or buggy server endpoint cannot turn an open-redirect into 10/// a DOM-XSS or phishing pivot. 11//////////////////////////////////////////////////////////////////////////////////////////// 12function wpestate_safe_redirect(target) { 13 "use strict"; 14 15 // Only strings are acceptable â HTML, objects, arrays are rejected outright. 16 if (typeof target !== 'string') { 17 return false; 18 } 19 20 // Trim whitespace; some schemes become exploitable with leading spaces. 21 var url = jQuery.trim(target); 22 if (url === '') { 23 return false; 24 } 25 26 // Allow: same-origin absolute paths (/foo), protocol-relative (//host/...), 27 // and absolute http(s):// URLs. Everything else (javascript:, data:, etc.) 28 // is rejected. 29 var isAbsolutePath = url.charAt(0) === '/'; 30 var isHttp = /^https?:\/\//i.test(url); 31 if (!isAbsolutePath && !isHttp) { 32 return false; 33 } 34 35 // Navigate. 36 window.location.href = url; 37 return true; 38} 39 40////////////////////////////////////////////////////////////////////////////////////////////// 41/// ajax filtering on header search ; jslint checked 42//////////////////////////////////////////////////////////////////////////////////////////// 43 44// Sequence counter for the half-map filter AJAX. Each call increments it and 45// captures the value; a response only updates the UI when its captured value 46// still matches the latest one, so out-of-order responses from rapid filter 47// clicks can no longer leave the result count out of sync with the cards. 48var wpestate_filtering_ajax_seq = 0; 49 50function wpestate_start_filtering_ajax_map(newpage,pan_ne_lat, pan_ne_long, pan_sw_lat,pan_sv_long,move_map) { 51 "use strict"; 52 if (document.body.classList.contains('single-estate_property')) { 53 //not on single 54 return; 55 } 56 is_fit_bounds_zoom=1; 57 map_geo_first_load=1; 58 external_action_ondemand=1; 59 60 var ajaxurl,all_fields,all_checkers,city,area,country,property_admin_area,stype,search_location_filter_autointernal,all_checkers,postid,keyword_search; 61 62 // Claim a sequence number for this request; a later request raises the 63 // counter, so this request's success handler will bail as superseded. 64 wpestate_filtering_ajax_seq = wpestate_filtering_ajax_seq + 1; 65 var request_seq = wpestate_filtering_ajax_seq; 66 67 all_fields=new Array(); 68 ajaxcalls_vars.adv_search_what_half.forEach( function(element) { 69 70 if(element==='property_price' || element==='property_price_v2' ){ 71 all_fields.push({element:'price_low',value: parseInt(jQuery('#price_low').val(), 10)}); 72 all_fields.push({element:'price_max',value:parseInt(jQuery('#price_max').val(), 10) }); 73 }else if(element==='property_beds_baths' ){ 74 75 var componentsbeds = jQuery('.wpresidence-componentsbeds').val(); 76 var componentsbaths = jQuery('.wpresidence-componentsbaths').val(); 77 78 all_fields.push({element:'componentsbeds',value: parseInt(componentsbeds, 10)}); 79 all_fields.push({element:'componentsbaths',value:parseInt(componentsbaths, 10) }); 80 81 }else if(element==='guest_no'){ 82 if(jQuery('.advanced_search_form_wrapper .guest_no_hidden').length>0){ 83 84 all_fields.push({ element:element.toLowerCase(),value:jQuery('.advanced_search_form_wrapper .guest_no_hidden').val() }); 85 }else{ 86 all_fields.push({element:element.toLowerCase(),value:jQuery('#'+element.toLowerCase()).val() }); 87 } 88 }else{ 89 all_fields.push({element:element.toLowerCase(),value:jQuery('#'+element.toLowerCase()).val() }); 90 } 91 });
92 93 94 if(ajaxcalls_vars.adv_search_type==='type4'){ 95 96 all_fields.push({element:'property_category',value:jQuery('#property_category').val() }); 97 all_fields.push({element:'property_action_category',value:jQuery('#property_action_category').val() }); 98 } 99 100 if(jQuery('#search_location_city').length >0){ 101 city = jQuery('#search_location_city').val(); 102 } 103 if(jQuery('#advanced_city').length >0){ 104 city = jQuery('#advanced_city').val(); 105 } 106 107 if(jQuery('#advanced_cityhalf').length >0){ 108 109 city = jQuery('#advanced_cityhalf').val(); 110 111 } 112 113 114 if(jQuery('#search_location_area').length>0){ 115 area = jQuery('#search_location_area').val(); 116 } 117 if(jQuery('#advanced_area').length>0){ 118 area = jQuery('#advanced_area').val(); 119 } 120 if(jQuery('#advanced_areahalf').length>0){ 121 area = jQuery('#advanced_areahalf').val(); 122 } 123 124 125 126 127 if(jQuery('#search_location_country').length>0){ 128 country = jQuery('#search_location_country').val(); 129 } 130 131 if(jQuery('#advanced_country').length>0){ 132 country = jQuery('#advanced_country').val(); 133 } 134 if(jQuery('#advanced_countryhalf').length>0){ 135 country = jQuery('#advanced_countryhalf').val(); 136 } 137 138 139 140 141 property_admin_area = jQuery('#property_admin_area').val(); 142 if(jQuery('#property_admin_areahalf').length>0){ 143 property_admin_area = jQuery('#property_admin_areahalf').val(); 144 } 145 146 stype = jQuery('#stype').val(); 147 search_location_filter_autointernal = jQuery('#search_location_autointernal').val(); 148 if(jQuery('#search_locationhalf_autointernal').length>0){ 149 search_location_filter_autointernal = jQuery('#search_locationhalf_autointernal').val(); 150 } 151 152 153 154 all_checkers = ''; 155 jQuery('.extended_search_check_wrapper input[type="checkbox"]').each(function () { 156 if (jQuery(this).is(":checked")) { 157 all_checkers = all_checkers + "," + jQuery(this).attr("data-label-search"); 158 } 159 }); 160 161 162
163 postid = parseInt(jQuery('#adv-search-1').attr('data-postid'), 10); 164 if ( isNaN(postid) ){ 165 postid = parseInt(jQuery('#adv_extended_options_text_adv').attr('data-pageid'), 10); 166 } 167 168 169 170 if( jQuery('#keyword_search').length > 0 ){ 171 keyword_search = jQuery('#keyword_search').val(); 172 } 173 174 var order = jQuery('#a_filter_order').attr('data-value'); 175 176 var geo_lat = ''; 177 var geo_long = ''; 178 var geo_rad = ''; 179 if( jQuery("#geolocation_search").length > 0){ 180 geo_lat = jQuery('#geolocation_lat').val(); 181 geo_long = jQuery('#geolocation_long').val(); 182 geo_rad = jQuery('#geolocation_radius').val(); 183 184 } 185 186 187 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 188 // jQuery('#google_map_prop_list_sidebar #listing_ajax_container').empty(); 189 // jQuery('#google_map_prop_list_sidebar #listing_loader').show(); 190 191 192 const listingContainer = jQuery('#listing_ajax_container'); 193 wpestate_createSkeletons(listingContainer); 194 195 196 var nonce = jQuery('#wprentals_ajax_filtering').val(); 197 jQuery.ajax({ 198 type: 'POST', 199 url: ajaxurl, 200 dataType: 'json', 201 data: { 202 'action' : 'wpestate_custom_ondemand_pin_load_new', 203 'search_location' : search_location_filter_autointernal, 204 'all_fields' : all_fields, 205 'stype' : stype, 206 'advanced_city' : city, 207 'advanced_area' : area, 208 'advanced_country' : country, 209 'property_admin_area' : property_admin_area, 210 'all_checkers' : all_checkers, 211 'newpage' : newpage, 212 'postid' : postid, 213 'keyword_search' : keyword_search, 214 'order' : order, 215 'geo_lat' : geo_lat, 216 'geo_long' : geo_long, 217 'geo_rad' : geo_rad, 218 'pan_ne_lat' : pan_ne_lat, 219 'pan_ne_long' : pan_ne_long, 220 'pan_sw_lat' : pan_sw_lat, 221 'pan_sv_long' : pan_sv_long, 222 'move_map' : move_map, 223 'security' : nonce, 224 225 }, 226 success: function (data) { 227 // Ignore responses from superseded requests so the visible cards 228 // and the result count always come from the most recent filter. 229 if (request_seq !== wpestate_filtering_ajax_seq) { 230 return; 231 } 232 233 jQuery('#advanced_search_map_list').removeClass('movetofixed'); 234 //jQuery('#listing_loader').hide(); 235 jQuery('.listing_loader_title').show(); 236 // jQuery('#google_map_prop_list_sidebar #listing_ajax_container').empty().append(data.response); 237 238 wpestate_replaceSkeletons(listingContainer, data.response); 239 240 jQuery('.wprentals_adv_listing_filters_head .half_map_results').text(data.results); 241 jQuery('.pagination_nojax').remove(); 242 243 244 245 wpestate_restart_js_after_ajax(); 246 wpestate_lazy_load_carousel_property_unit(); 247 if (typeof wpestate_add_pagination_orderby === 'function') { 248 wpestate_add_pagination_orderby(); 249 } 250 var new_markers = jQuery.parseJSON(data.markers); 251 if (infoBox !== null) { 252 infoBox.close(); 253 } 254 255 256 if(typeof(move_map)!=='undefined'){ 257 258 wpestate_set_filter_pins_ondemand(map, new_markers); 259 }else{ 260 261 wpestate_set_filter_pins(map, new_markers); 262 } 263 264 is_fit_bounds_zoom=0; 265 266 if( jQuery("#geolocation_search").length > 0 && initial_geolocation_circle_flag === 0){ 267 var place_lat = jQuery('#geolocation_lat').val(); 268 var place_lng = jQuery('#geolocation_long').val(); 269 270 271 if(place_lat!=='' && place_lng!==''){ 272 initial_geolocation_circle_flag=1; 273 wpestate_geolocation_marker(place_lat,place_lng); 274 if (googlecode_regular_vars.on_demand_pins==='no'){ 275 initial_geolocation_circle_flag=0; 276 } 277 278 } 279 } 280 281 282 }, 283 error: function (errorThrown) {} 284 });//end ajax 285} 286 287 288 289 290 291 292 293 294function wpestate_geolocation_marker (place_lat, place_lng){ 295 var place_radius; 296 297 298 if(control_vars.geo_radius_measure==='miles'){ 299 place_radius =parseInt( jQuery('#geolocation_radius').val(),10)*1609.34 ; 300 }else{ 301 place_radius =parseInt( jQuery('#geolocation_radius').val(),10)*1000 ; 302 } 303 304 if(wprentals_map_type===1){ 305 var place_position=new google.maps.LatLng(place_lat, place_lng); 306 map.setCenter(place_position); 307 308 if(placeCircle!=''){ 309 placeCircle.setMap(null); 310 placeCircle=''; 311 } 312 313 marker = new google.maps.Marker({ 314 map: map, 315 position: place_position, 316 icon: mapfunctions_vars.path+'/poi/location.png' 317 }); 318 319 320 var populationOptions = { 321 strokeColor: '#67cfd8', 322 strokeOpacity: 0.6, 323 strokeWeight: 1, 324 fillColor: '#1CA8DD', 325 fillOpacity: 0.2, 326 map: map, 327 center: place_position, 328 radius: parseInt(place_radius,10) 329 }; 330 331 placeCircle = new google.maps.Circle(populationOptions); 332 map.fitBounds(placeCircle.getBounds()); 333 334 335 }else if(wprentals_map_type===2){ 336 var markerCenter = L.latLng(place_lat, place_lng ); 337 map.panTo(markerCenter); 338 if(map.hasLayer(circleLayer)){ 339 map.removeLayer(circleLayer); 340 } 341 342 343 var markerImage = { 344 iconUrl: mapfunctions_vars.path+'/poi/location.png', 345 iconSize: [28, 38], 346 iconAnchor: [10, 19], 347 popupAnchor: [1, -18] 348 }; 349 var markerOptions = { 350 riseOnHover: true 351 }; 352 if(map.hasLayer(circleLayer)){ 353 map.removeLayer(circleLayer); 354 } 355 circleLayer=L.featureGroup(); 356 markerOptions.icon = L.icon( markerImage ); 357 L.marker( markerCenter, markerOptions ).addTo( map ); 358 placeCircle= L.circle( markerCenter, parseInt(place_radius,10) ).addTo(circleLayer); 359 360 361 map.addLayer(circleLayer); 362 map.fitBounds(placeCircle.getBounds()); 363 } 364} 365 366 367 368 369 370 371 372 373 374 375 376 377function wpestate_get_custom_value(slug){ 378 /*ok*/ 379 var value; 380 var is_drop=0; 381 if(slug === 'adv_categ' || slug === 'adv_actions' || slug === 'advanced_city' || slug === 'advanced_area' || slug === 'county-state'){ 382 value = jQuery('#'+slug).attr('data-value'); 383 } else if(slug === 'property_price' && mapfunctions_vars.slider_price==='yes'){ 384 value = jQuery('#price_low').val(); 385 }else if(slug === 'property-country'){ 386 value = jQuery('#advanced_country').attr('data-value'); 387 }else{ 388 389 if( jQuery('#'+slug).hasClass('filter_menu_trigger') ){ 390 value = jQuery('#'+slug).attr('data-value'); 391 is_drop=1; 392 }else{ 393 value = jQuery('#half-'+slug).val() ; 394 395 } 396 } 397 398 399 if (typeof(value)!=='undefined'&& is_drop===0){ 400 // value= value .replace(" ","-"); 401 } 402 403 return value; 404 405} 406 407 408 409 410 411 412////////////////////////////////////////////////////////////////////////////////////////////// 413/// ajax filtering on header search ; jslint checked 414//////////////////////////////////////////////////////////////////////////////////////////// 415function wpestate_start_filtering_ajax(newpage) { 416 "use strict"; 417 var action, guest_no, country, check_out, check_in, category, city, area, rooms, baths, min_price, price_max, ajaxurl, postid, order; 418 action = jQuery('#adv_actions').attr('data-value'); 419 category = jQuery('#adv_categ').attr('data-value'); 420 city = jQuery('#advanced_city').attr('data-value'); 421 area = jQuery('#advanced_area').attr('data-value'); 422 country = jQuery('#advanced_country').attr('data-value');
423 rooms = parseInt(jQuery('#adv_rooms').val(), 10); 424 baths = parseInt(jQuery('#adv_bath').val(), 10); 425 min_price = parseInt(jQuery('#price_low').val(), 10); 426 price_max = parseInt(jQuery('#price_max').val(), 10); 427 postid = parseInt(jQuery('#adv-search-1').attr('data-postid'), 10); 428 429 430 check_in = jQuery('#check_in').val(); 431 check_out = jQuery('#check_out').val(); 432 guest_no = jQuery('#guest_no_main').val(); 433 order = jQuery('#a_filter_order').attr('data-value'); 434 435 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 436 jQuery('#listing_ajax_container').empty(); 437 jQuery('.listing_loader_title').show(); 438 jQuery('#internal-loader').show(); 439 var nonce = jQuery('#wprentals_ajax_filtering').val(); 440 jQuery.ajax({ 441 type: 'POST', 442 url: ajaxurl, 443 data: { 444 'action' : 'wpestate_ajax_filter_listings_search', 445 'action_values' : action, 446 'category_values' : category, 447 'city' : city, 448 'area' : area, 449 'advanced_rooms' : rooms, 450 'advanced_bath' : baths, 451 'price_low' : min_price, 452 'price_max' : price_max, 453 'newpage' : newpage, 454 'postid' : postid, 455 'check_in' : check_in, 456 'check_out' : check_out, 457 'guest_no' : guest_no, 458 'order' : order, 459 'country' : country, 460 'security' : nonce, 461 }, 462 success: function (data) { 463 464 jQuery('#internal-loader,#listing_loader').hide(); 465 jQuery('#listing_ajax_container').addClass('load_from_ajax').empty().append(data); 466 wpestate_restart_js_after_ajax(); 467 if (typeof wpestate_add_pagination_orderby === 'function') { 468 wpestate_add_pagination_orderby(); 469 } 470 }, 471 error: function (errorThrown) { 472 473 } 474 });//end ajax 475} 476 477 478 479 480//////////////////////////////////////////////////////////////////////////////////////////// 481/// redo js after ajax calls - jslint checked 482//////////////////////////////////////////////////////////////////////////////////////////// 483function wpestate_restart_js_after_ajax() { 484 "use strict"; 485 var newpage, post_id, post_image, to_add, icon, already_in, i, bLazy; 486 487 //bLazy = new Blazy(); 488 //bLazy.revalidate(); 489 490 491 wpestate_open_property_card_setup(); 492 493 494 jQuery('#google_map_prop_list_sidebar .listing_wrapper').unbind('mouseenter'); 495 jQuery('#google_map_prop_list_sidebar .listing_wrapper').unbind('mouseleave'); 496 497 jQuery("#google_map_prop_list_sidebar .listing_wrapper").on("mouseenter", function(event) { 498 var listing_id = jQuery(this).attr('data-listid'); 499 wpestate_hover_action_pin(listing_id); 500 }) 501 502 jQuery("#google_map_prop_list_sidebar .listing_wrapper").on("mouseleave", function(event) { 503 var listing_id = jQuery(this).attr('data-listid'); 504 wpestate_return_hover_action_pin(listing_id); 505 }) 506 507 508 509 510 jQuery('.prop-compare:first-of-type').remove(); 511 jQuery('.pagination_ajax_search a').on('click',function (event) { 512 event.preventDefault(); 513 newpage = parseInt(jQuery(this).attr('data-future'), 10); 514 document.getElementById('scrollhere').scrollIntoView(); 515 wpestate_start_filtering_ajax(newpage); 516 }); 517 518 jQuery('.pagination_ajax a').on('click',function (event) { 519 event.preventDefault(); 520 newpage = parseInt(jQuery(this).attr('data-future'), 10); 521 document.getElementById('scrollhere').scrollIntoView(); 522 wpestate_start_filtering(newpage); 523 }); 524 525 526 527 jQuery('.pagination_ajax_search_home a').on('click',function (event) { 528 529 event.preventDefault(); 530 531 newpage = parseInt(jQuery(this).attr('data-future'), 10); 532 document.getElementById('scrollhere').scrollIntoView(); 533 534 if (googlecode_regular_vars.on_demand_pins==='yes' && map_is_moved===1){ 535 external_action_ondemand=1; 536 wpestate_reload_pins_onmap(newpage); 537 }else{ 538 wpestate_start_filtering_ajax_map(newpage); 539 } 540 });
541 542 543 544 already_in = []; 545 jQuery('.compare-action').on('click',function (e) { 546 e.preventDefault(); 547 e.stopPropagation(); 548 jQuery('.prop-compare').show(); 549 post_id = jQuery(this).attr('data-pid'); 550 551 for (i = 0; i < already_in.length; i++) { 552 if (already_in[i] === post_id) { 553 return; 554 } 555 } 556 557 already_in.push(post_id); 558 post_image = jQuery(this).attr('data-pimage'); 559 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>'; 560 jQuery('div.items_compare:first-child').css('background', 'red'); 561 if (parseInt(jQuery('.items_compare').length, 10) > 3) { 562 jQuery('.items_compare:first').remove(); 563 } 564 jQuery('#submit_compare').before(to_add); 565 jQuery('.items_compare').fadeIn(800); 566 }); 567 568 jQuery('#submit_compare').on('click',function () { 569 jQuery('#form_compare').trigger('submit'); 570 }); 571 572 jQuery('.icon-fav').on('click',function (event) { 573 event.stopPropagation(); 574 icon = jQuery(this); 575 wpestate_add_remove_favorite(icon); 576 }); 577 578 579 580 581 jQuery(".share_list, .icon-fav, .compare-action").on("mouseenter", function(event) { 582 jQuery(this).tooltip('show'); 583 }); 584 jQuery(".share_list, .icon-fav, .compare-action").on("mouseleave", function(event) { 585 jQuery(this).tooltip('hide'); 586 }); 587 588 589 jQuery('.share_list').on('click',function () { 590 var sharediv = jQuery(this).parent().find('.share_unit'); 591 sharediv.toggle(); 592 jQuery(this).toggleClass('share_on'); 593 }); 594 595 wpestate_lazy_load_carousel_property_unit(); 596} 597 598//////////////////////////////////////////////////////////////////////////////////////////// 599/// add remove from favorite-jslint checked 600//////////////////////////////////////////////////////////////////////////////////////////// 601function wpestate_add_remove_favorite(icon) { 602 "use strict"; 603 var post_id, securitypass, ajaxurl; 604 post_id = icon.attr('data-postid'); 605 securitypass = jQuery('#security-pass').val(); 606 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 607 608 if (parseInt(ajaxcalls_vars.userid, 10) === 0) { 609 wpestate_show_login_form(1, 1, 0); 610 } else { 611 icon.toggleClass('icon-fav-off'); 612 icon.toggleClass('icon-fav-on'); 613 var nonce = jQuery('#wprentals_ajax_filtering').val(); 614 jQuery.ajax({ 615 type: 'POST', 616 url: ajaxurl, 617 dataType: 'json', 618 data: { 619 'action' : 'wpestate_ajax_add_fav', 620 'post_id' : post_id, 621 'security' : nonce 622 }, 623 success: function (data) { 624 if (data.added) { 625 icon.removeClass('icon-fav-off').addClass('icon-fav-on'); 626 icon.attr('data-original-title',ajaxcalls_vars.remove_favorite); 627 } else { 628 629 icon.removeClass('icon-fav-on').addClass('icon-fav-off'); 630 icon.attr('data-original-title',ajaxcalls_vars.add_favorite_unit); 631 if(jQuery('.favorite_dashboard_property_list').length>0){ 632 icon.parents('.dasboard-prop-listing').remove(); 633 } 634 635 } 636 }, 637 error: function (errorThrown) { 638 } 639 });//end ajax 640 }// end login use 641} 642 643//////////////////////////////////////////////////////////////////////////////////////////// 644/// resend listing for approval-jslint checked 645//////////////////////////////////////////////////////////////////////////////////////////// 646function wpestate_resend_for_approval(prop_id, selected_div) { 647 "use strict"; 648 var ajaxurl, normal_list_no; 649 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 650 var nonce = jQuery('#wprentals_property_actions').val(); 651 jQuery.ajax({ 652 type: 'POST', 653 url: ajaxurl, 654 data: { 655 'action' : 'wpestate_ajax_resend_for_approval', 656 'propid' : prop_id, 657 'security' : nonce 658 }, 659 success: function (data) { 660 if (data === 'pending') { 661 selected_div.parent().empty().append('<span class="featured_prop">Sent for approval</span>');
662 normal_list_no = parseInt(jQuery('#normal_list_no').text(), 10); 663 jQuery('#normal_list_no').text(normal_list_no - 1); 664 } else { 665 selected_div.parent().empty().append(data); 666 } 667 }, 668 error: function (errorThrown) { 669 670 } 671 });//end ajax 672} 673 674//////////////////////////////////////////////////////////////////////////////////////////// 675/// make property featured-jslint checked 676//////////////////////////////////////////////////////////////////////////////////////////// 677function wpestate_make_prop_featured(prop_id, selectedspan) { 678 "use strict"; 679 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 680 var nonce = jQuery('#wprentals_property_actions').val(); 681 jQuery.ajax({ 682 type: 'POST', 683 url: ajaxurl, 684 data: { 685 'action' : 'wpestate_ajax_make_prop_featured', 686 'propid' : prop_id, 687 'security' : nonce, 688 }, 689 success: function (data) { 690 if (data.trim() === 'done') { 691 selectedspan.empty().html('<span class="label label-success is_featured">' + ajaxcalls_vars.prop_featured + '</span>'); 692 selectedspan.removeClass('dashboad-tooltip'); 693 var featured_list_no = parseInt(jQuery('#featured_list_no').text(), 10); 694 jQuery('#featured_list_no').text(featured_list_no - 1); 695 } else { 696 selectedspan.empty().removeClass('make_featured').addClass('featured_exp').removeClass('dashboad-tooltip').text(ajaxcalls_vars.no_prop_featured); 697 } 698 }, 699 error: function (errorThrown) { 700 } 701 702 });//end ajax 703} 704 705//////////////////////////////////////////////////////////////////////////////////////////// 706/// duplicate listing-jslint checked 707//////////////////////////////////////////////////////////////////////////////////////////// 708function wpestate_duplicate_listing(prop_id, selected_div) { 709 "use strict"; 710 var ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 711 var nonce = jQuery('#wprentals_property_actions').val(); 712 jQuery.ajax({ 713 type: 'POST', 714 url: ajaxurl, 715 data: { 716 'action': 'wpestate_ajax_duplicate_listing', 717 'propid': prop_id, 718 'security': nonce 719 }, 720 success: function (data) { 721 if (data === 'done') { 722 selected_div.parent().empty().append('<span class="featured_prop">Duplicate created</span>'); 723 location.reload(); 724 } else { 725 selected_div.parent().empty().append(data); 726 } 727 }, 728 error: function (errorThrown) { 729 730 } 731 });//end ajax 732} 733 734/// pay package via paypal recuring-jslint checked 735//////////////////////////////////////////////////////////////////////////////////////////// 736function wpestate_recuring_pay_pack_via_paypal() { 737 "use strict"; 738 var ajaxurl, packName, packId; 739 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 740 packName = jQuery('#pack_select :selected').text(); 741 packId = jQuery('#pack_select :selected').val(); 742 var nonce = jQuery('#wprentals_payments_actions').val(); 743 744 745 jQuery.ajax({ 746 type: 'POST', 747 url: ajaxurl, 748 data: { 749 'action' : 'wpestate_ajax_paypal_pack_recuring_generation_rest_api', 750 'packName' : packName, 751 'packId' : packId, 752 'security' : nonce, 753 }, 754 success: function (data) { 755 756 wpestate_safe_redirect(data); 757 }, 758 error: function (errorThrown) { 759 } 760 });//end ajax 761} 762 763//////////////////////////////////////////////////////////////////////////////////////////// 764/// pay package via paypal-jslint checked 765//////////////////////////////////////////////////////////////////////////////////////////// 766function wpestate_pay_pack_via_paypal() { 767 "use strict"; 768 var ajaxurl, packName, packId; 769 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 770 packName = jQuery('#pack_select :selected').text(); 771 packId = jQuery('#pack_select :selected').val(); 772 var nonce = jQuery('#wprentals_payments_actions').val(); 773 jQuery.ajax({ 774 type: 'POST', 775 url: ajaxurl, 776 data: { 777 'action' : 'wpestate_ajax_paypal_pack_generation', 778 'packName' : packName, 779 'packId' : packId, 780 'security' : nonce 781 }, 782 success: function (data) { 783 784 wpestate_safe_redirect(data); 785 }, 786 error: function (errorThrown) { 787 } 788 });//end ajax 789 790} 791//////////////////////////////////////////////////////////////////////////////////////////// 792/// listing pay -jslint checked 793//////////////////////////////////////////////////////////////////////////////////////////// 794function wpestate_listing_pay(prop_id, selected_div, is_featured, is_upgrade) { 795 "use strict"; 796 var ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 797 var nonce = jQuery('#wprentals_payments_actions').val(); 798 jQuery.ajax({ 799 type: 'POST', 800 url: ajaxurl, 801 data: { 802 'action' : 'wpestate_ajax_listing_pay', 803 'propid' : prop_id, 804 'is_featured' : is_featured, 805 'is_upgrade' : is_upgrade, 806 'security' : nonce 807 }, 808 success: function (data) { 809 wpestate_safe_redirect(data); 810 }, 811 error: function (errorThrown) { 812 } 813 });//end ajax 814} 815 816//////////////////////////////////////////////////////////////////////////////////////////// 817/// start filtering -jslint checked 818//////////////////////////////////////////////////////////////////////////////////////////// 819function wpestate_start_filtering(newpage) { 820 "use strict"; 821 822 jQuery('#grid_view').addClass('icon_selected'); 823 jQuery('#list_view').removeClass('icon_selected'); 824 var action, category, city, area, order, ajaxurl, page_id; 825 // get action vars 826 action = jQuery('#a_filter_action').attr('data-value'); 827 // get category 828 category = jQuery('#a_filter_categ').attr('data-value'); 829 // get city 830 city = jQuery('#a_filter_cities').attr('data-value'); 831 // get area 832 area = jQuery('#a_filter_areas').attr('data-value'); 833 // get order 834 order = jQuery('#a_filter_order').attr('data-value'); 835 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 836 page_id = jQuery('#page_idx').val(); 837 var is_archive=''; 838 839 if(jQuery('body').hasClass('archive') && jQuery('#primary').hasClass('none') ){ 840 is_archive='yes'; 841 } 842 843 //jQuery('#listing_ajax_container').empty(); 844 //jQuery('#listing_loader').show(); 845 846 const listingContainer = jQuery('#listing_ajax_container'); 847 wpestate_createSkeletons(listingContainer); 848 849 850 var nonce = jQuery('#wprentals_ajax_filtering').val(); 851 852 jQuery.ajax({ 853 type: 'POST', 854 url: ajaxurl, 855 data: { 856 'action' : 'wpestate_ajax_filter_listings', 857 'action_values' : action, 858 'category_values' : category, 859 'city' : city, 860 'area' : area, 861 'order' : order, 862 'newpage' : newpage, 863 'page_id' : page_id, 864 'is_archive' : is_archive, 865 'security' : nonce 866 }, 867 success: function (data) { 868 //jQuery('#listing_loader').hide(); 869 //jQuery('#listing_ajax_container').empty().append(data); 870 jQuery('.pagination_nojax').hide(); 871 872 wpestate_replaceSkeletons(listingContainer, data); 873 874 875 wpestate_restart_js_after_ajax(); 876 wpestate_lazy_load_carousel_property_unit(); 877 if (typeof wpestate_add_pagination_orderby === 'function') { 878 wpestate_add_pagination_orderby(); 879 } 880 //var bLazy = new Blazy(); 881 //bLazy.revalidate(); 882 }, 883 error: function (errorThrown) { 884 885 } 886 });//end ajax 887} 888 889//////////////////////////////////////////////////////////////////////////////////////////// 890/// show login form on fav login-jslint checked 891//////////////////////////////////////////////////////////////////////////////////////////// 892function wpestate_show_login_form(type, ispop, propid) { 893 "use strict"; 894 895 if(parseInt(type,10)===1){ 896 jQuery('#ajax_login_div').show(); 897 jQuery('#ajax_register_div').hide(); 898 jQuery('#forgot-pass-div_mod').hide(); 899 900 }else{ 901 jQuery('#ajax_login_div').hide(); 902 jQuery('#ajax_register_div').show(); 903 jQuery('#forgot-pass-div_mod').hide(); 904 } 905 906 //ispop=9 modal is open from booking - hide socila login 907 908 if(parseInt(ispop,10)===9){ 909 jQuery('#loginmodal .login-links').hide(); 910 } 911 912 jQuery('#loginmodal').modal(); 913 wpestate_enable_actions_modal(); 914} 915 916//////////////////////////////////////////////////////////////////////////////////////////// 917/// change pass on profile-jslint checked 918////////////////////////////////////////////////////////////////////////////////////////////
919//////////////////////////////////////////////////////////////////////////////////////////// 920/// Profile action inline message (GitHub issue #140) 921/// Renders the server feedback for a profile action into a container placed 922/// directly below the clicked button, so the result is visible right where 923/// the user is looking. target = jQuery selector of the message container, 924/// message = text to show, type = '' | 'success' | 'error'. 925//////////////////////////////////////////////////////////////////////////////////////////// 926function wpestate_show_profile_message(target, message, type) { 927 "use strict"; 928 929 // The type suffix drives the accent colour in CSS. 930 var typeClass = (type === 'success' || type === 'error') ? ' is-' + type : ''; 931 932 // Build the alert; use .text() so any server output is treated as plain text. 933 var alert = jQuery('<div class="login-alert' + typeClass + '"></div>').text(message); 934 935 // Replace any previous message in the target container. 936 jQuery(target).empty().append(alert); 937} 938 939 940function wpestate_change_pass_profile() { 941 "use strict"; 942 var oldpass, newpass, renewpass, securitypass, ajaxurl; 943 oldpass = jQuery('#oldpass').val(); 944 newpass = jQuery('#newpass').val(); 945 renewpass = jQuery('#renewpass').val(); 946 securitypass = jQuery('#security-pass').val(); 947 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 948 949 jQuery.ajax({ 950 type: 'POST', 951 url: ajaxurl, 952 data: { 953 'action' : 'wpestate_ajax_update_pass', 954 'oldpass' : oldpass, 955 'newpass' : newpass, 956 'renewpass' : renewpass, 957 'security-pass' : securitypass 958 }, 959 success: function (data) { 960 // Server returns {success:bool, data:msg}; map it to green (success) or coral (warning). Issue #140. 961 var isok = !!(data && data.success); 962 var msg = (data && typeof data.data !== 'undefined') ? data.data : data; 963 wpestate_show_profile_message('#change_pass_message', msg, isok ? 'success' : 'error'); 964 // Only clear the fields on a successful change. 965 if (isok) { 966 jQuery('#oldpass, #newpass, #renewpass').val(''); 967 } 968 }, 969 error: function (errorThrown) { 970 } 971 }); 972} 973 974 975//////////////////////////////////////////////////////////////////////////////////////////// 976/// user register via widget-jslint checked 977//////////////////////////////////////////////////////////////////////////////////////////// 978function wpestate_register_wd() { 979 "use strict"; 980 var user_pass,user_pass_retype,capthca, user_login_register, user_email_register, nonce, ajaxurl,user_type,user_phone; 981 user_login_register = jQuery('#user_login_register_wd').val(); 982 user_email_register = jQuery('#user_email_register_wd').val(); 983 nonce = jQuery('#wpestate_ajax_log_reg').val(); 984 user_pass = jQuery('#user_password_wd').val(); 985 user_pass_retype = jQuery('#user_password_retype_wd').val(); 986 user_phone = jQuery('#user_phone_register_wd').val(); 987 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 988 user_type = jQuery("input[name=acc_type]:checked").val(); 989 990 if (!jQuery('#user_terms_register_wd').is(":checked")) { 991 jQuery('#register_message_area_wd').empty().append('<div class="login-alert alert_err">' + control_vars.terms_cond + '</div>'); 992 return; 993 } 994 995 capthca=''; 996 if(control_vars.usecaptcha==='yes'){ 997 capthca= grecaptcha.getResponse( 998 widgetId3 999 ); 1000 } 1001 1002 jQuery.ajax({ 1003 type: 'POST', 1004 url: ajaxurl, 1005 dataType: 'json', 1006 data: { 1007 'action' : 'wpestate_ajax_register_form', 1008 'user_login_register' : user_login_register, 1009 'user_email_register' : user_email_register,
1010 'user_type' : user_type, 1011 'tipul' : 2, 1012 'capthca' : capthca, 1013 'user_pass' : user_pass, 1014 'user_pass_retype' : user_pass_retype, 1015 'user_phone' : user_phone, 1016 'security' : nonce, 1017 }, 1018 1019 success: function (data) { 1020 if (data.register === true) { 1021 jQuery('#register_message_area_wd').empty().append('<div class="login-alert">' + data.message + '</div>'); 1022 }else{ 1023 jQuery('#register_message_area_wd').empty().append('<div class="alert_err login-alert">' + data.message + '</div>'); 1024 } 1025 jQuery('#user_login_register_wd').val(''); 1026 jQuery('#user_email_register_wd').val(''); 1027 }, 1028 error: function (errorThrown) { 1029 } 1030 }); 1031} 1032 1033 1034 1035 1036//////////////////////////////////////////////////////////////////////////////////////////// 1037/// user register via widget-jslint checked 1038//////////////////////////////////////////////////////////////////////////////////////////// 1039function wpestate_register_wd_mobile() { 1040 "use strict"; 1041 var user_pass,user_pass_retype,capthca,user_login_register, user_email_register, nonce, ajaxurl,user_type,user_phone; 1042 user_login_register = jQuery('#user_login_register_wd_mobile').val(); 1043 user_email_register = jQuery('#user_email_register_wd_mobile').val(); 1044 nonce = jQuery('#wpestate_ajax_log_reg').val(); 1045 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1046 user_type = jQuery("input[name=acc_type]:checked").val(); 1047 user_pass = jQuery('#user_password_wd_mobile').val(); 1048 user_pass_retype = jQuery('#user_password_retype_wd_mobile').val(); 1049 user_phone = jQuery('#user_phone_register_wd_mobile').val(); 1050 1051 if (!jQuery('#user_terms_register_wd_mobile').is(":checked")) { 1052 jQuery('#register_message_area_wd_mobile').empty().append('<div class="login-alert alert_err">' + control_vars.terms_cond + '</div>'); 1053 return; 1054 } 1055 1056 capthca=''; 1057 if(control_vars.usecaptcha==='yes'){ 1058 capthca= grecaptcha.getResponse( 1059 widgetId2 1060 ); 1061 } 1062 1063 jQuery.ajax({ 1064 type: 'POST', 1065 url: ajaxurl, 1066 dataType: 'json', 1067 data: { 1068 'action' : 'wpestate_ajax_register_form', 1069 'user_login_register' : user_login_register, 1070 'user_email_register' : user_email_register, 1071 'security-register' : nonce, 1072 'user_type' : user_type, 1073 'tipul' : 1, 1074 'capthca' : capthca, 1075 'user_pass' : user_pass, 1076 'user_pass_retype' : user_pass_retype, 1077 'user_phone' : user_phone, 1078 'security' : nonce, 1079 }, 1080 1081 success: function (data) { 1082 if (data.register === true) { 1083 jQuery('#register_message_area_wd_mobile').empty().append('<div class="login-alert">' + data.message + '</div>'); 1084 }else{ 1085 jQuery('#register_message_area_wd_mobile').empty().append('<div class="alert_err login-alert">' + data.message + '</div>'); 1086 } 1087 jQuery('#user_login_register_wd_mobile').val(''); 1088 jQuery('#user_email_register_wd_mobile').val(''); 1089 }, 1090 error: function (errorThrown) { 1091 } 1092 }); 1093} 1094 1095 1096//////////////////////////////////////////////////////////////////////////////////////////// 1097/// on ready -jslint checked 1098//////////////////////////////////////////////////////////////////////////////////////////// 1099function wpestate_forgot(type) { 1100 "use strict"; 1101 var forgot_email, securityforgot, postid, ajaxurl; 1102 postid = jQuery('#postid').val(); 1103 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1104 1105 if (type === 1) { 1106 forgot_email = jQuery('#forgot_email_mod').val(); 1107 securityforgot = jQuery('#security-login-forgot_wd').val(); 1108 } 1109 if (type === 2) { 1110 forgot_email = jQuery('#forgot_email_mod').val(); 1111 securityforgot = jQuery('#security-forgot').val(); 1112 } 1113 if (type === 3) { 1114 forgot_email = jQuery('#forgot_email_shortcode').val(); 1115 securityforgot = jQuery('#security-login-forgot_wd').val(); 1116 } 1117 1118 if (type === 4) { 1119 forgot_email = jQuery('#forgot_email_mobile').val(); 1120 securityforgot = jQuery('#security-login-forgot_wd_mobile').val(); 1121 } 1122 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1123 1124 jQuery('#forgot_pass_area').empty(); 1125 jQuery('#forgot_pass_area_shortcode_wd').empty(); 1126 jQuery.ajax({ 1127 type: 'POST', 1128 url: ajaxurl, 1129 data: { 1130 'action' : 'wpestate_ajax_forgot_pass', 1131 'forgot_email' : forgot_email, 1132 'security-forgot' : securityforgot, 1133 'postid' : postid, 1134 'type' : type, 1135 'security' : nonce 1136 }, 1137 1138 success: function (data) { 1139 if (type === 1) { 1140 jQuery('#forgot_email_mod').val(''); 1141 jQuery('#forgot_pass_area_shortcode').empty().append('<div class="login-alert">
1141' + data + '<div>'); 1142 } 1143 if (type === 2) { 1144 jQuery('#forgot_email').val(''); 1145 jQuery('#forgot_pass_area').empty().append('<div class="login-alert">' + data + '<div>'); 1146 jQuery('#forgot_pass_area_shortcode').empty().append('<div class="login-alert">' + data + '<div>'); 1147 } 1148 if (type === 3) { 1149 jQuery('#forgot_email_shortcode').val(''); 1150 jQuery('#forgot_pass_area').empty().append('<div class="login-alert">' + data + '<div>'); 1151 jQuery('#forgot_pass_area_shortcode_wd').empty().append('<div class="login-alert">' + data + '<div>'); 1152 } 1153 if (type === 4) { 1154 jQuery('#forgot_email_mobile').val(''); 1155 jQuery('#forgot_pass_area_shortcode_wd_mobile').empty().append('<div class="login-alert">' + data + '<div>'); 1156 } 1157 }, 1158 error: function (errorThrown) { 1159 } 1160 }); 1161} 1162 1163//////////////////////////////////////////////////////////////////////////////////////////// 1164/// on ready-jslint checked 1165//////////////////////////////////////////////////////////////////////////////////////////// 1166function wpestate_login_wd() { 1167 "use strict"; 1168 var login_user, login_pwd, ispop, ajaxurl, security; 1169 1170 login_user = jQuery('#login_user_wd').val(); 1171 login_pwd = jQuery('#login_pwd_wd').val(); 1172 security = jQuery('#security-login-wd').val(); 1173 ispop = jQuery('#loginpop_wd').val(); 1174 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1175 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1176 jQuery('#login_message_area_wd').empty().append('<div class="login-alert">' + ajaxcalls_vars.login_loading + '</div>'); 1177 jQuery.ajax({ 1178 type: 'POST', 1179 dataType: 'json', 1180 url: ajaxurl, 1181 data: { 1182 'action' : 'wpestate_ajax_loginx_form', 1183 'login_user' : login_user, 1184 'login_pwd' : login_pwd, 1185 'ispop' : ispop, 1186 'security-login' : security, 1187 'propid' : 0, 1188 'tipul' : 2, 1189 'security' : nonce, 1190 }, 1191 1192 success: function (data) { 1193 jQuery('#login_message_area_wd').empty().append('<div class="login-alert">' + data.message + '<div>'); 1194 if (data.loggedin === true) { 1195 if (parseInt(data.ispop, 10) === 1) { 1196 ajaxcalls_vars.userid = data.newuser; 1197 jQuery('#ajax_login_container').remove(); 1198 } else { 1199 if(jQuery('body').hasClass('single-estate_property') ){ 1200 location.reload(); 1201 }else{ 1202 document.location.href = ajaxcalls_vars.login_redirect; 1203 } 1204 } 1205 jQuery('#user_not_logged_in').hide(); 1206 jQuery('#user_logged_in').show(); 1207 } else { 1208 jQuery('#login_user').val(''); 1209 jQuery('#login_pwd').val(''); 1210 } 1211 }, 1212 error: function (errorThrown) { 1213 } 1214 }); 1215} 1216 1217//////////////////////////////////////////////////////////////////////////////////////////// 1218/// on ready-jslint checked 1219//////////////////////////////////////////////////////////////////////////////////////////// 1220function wpestate_login_wd_mobile() { 1221 "use strict"; 1222 var login_user, login_pwd, ispop, ajaxurl, security; 1223 1224 login_user = jQuery('#login_user_wd_mobile').val(); 1225 login_pwd = jQuery('#login_pwd_wd_mobile').val(); 1226 security = jQuery('#security-login-mobile').val(); 1227 ispop = jQuery('#loginpop_mobile').val(); 1228 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1229 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1230 jQuery('#login_message_area_wd_mobile').empty().append('<div class="login-alert">
1230' + ajaxcalls_vars.login_loading + '</div>'); 1231 jQuery.ajax({ 1232 type: 'POST', 1233 dataType: 'json', 1234 url: ajaxurl, 1235 data: { 1236 'action' : 'wpestate_ajax_loginx_form', 1237 'login_user' : login_user, 1238 'login_pwd' : login_pwd, 1239 'ispop' : ispop, 1240 'security-login' : security, 1241 'propid' : 0, 1242 'tipul' : 1, 1243 'security' : nonce 1244 }, 1245 1246 success: function (data) { 1247 1248 1249 1250 1251 if (data.loggedin === true) { 1252 1253 1254 if (parseInt(data.ispop, 10) === 1) { 1255 1256 ajaxcalls_vars.userid = data.newuser; 1257 jQuery('#loginmodal').modal('hide'); 1258 1259 if(jQuery('body').hasClass('single-estate_property') ){ 1260 location.reload(); 1261 }else{ 1262 if(ajaxcalls_vars.redirect_users==='yes'){ 1263 location.reload(); 1264 }else{ 1265 if( ajaxcalls_vars.redirect_custom_link===''){ 1266 document.location.href = ajaxcalls_vars.login_redirect; 1267 }else{ 1268 document.location.href =ajaxcalls_vars.redirect_custom_link; 1269 } 1270 } 1271 } 1272 1273 } else { 1274 if(data.newlink!==''){ 1275 if(jQuery('body').hasClass('page-template-user_dashboard_add_step1') ){ 1276 document.location.href = data.newlink; 1277 }else if(jQuery('body').hasClass('single-estate_property') ){ 1278 location.reload(); 1279 }else{ 1280 if(ajaxcalls_vars.redirect_users==='yes'){ 1281 location.reload(); 1282 }else{ 1283 if( ajaxcalls_vars.redirect_custom_link===''){ 1284 document.location.href = data.newlink; 1285 }else{ 1286 document.location.href =ajaxcalls_vars.redirect_custom_link; 1287 } 1288 } 1289 1290 } 1291 }else{ 1292 1293 if(jQuery('body').hasClass('single-estate_property') ){ 1294 location.reload(); 1295 }else{ 1296 if(ajaxcalls_vars.redirect_users==='yes'){ 1297 location.reload(); 1298 }else{ 1299 if( ajaxcalls_vars.redirect_custom_link===''){ 1300 document.location.href = ajaxcalls_vars.login_redirect; 1301 }else{ 1302 document.location.href =ajaxcalls_vars.redirect_custom_link; 1303 } 1304 } 1305 } 1306 } 1307 1308 } 1309 jQuery('#user_not_logged_in').hide(); 1310 jQuery('#user_logged_in').show(); 1311 1312 1313 1314 } else { 1315 jQuery('#login_message_area_wd_mobile').empty().append('<div class="login-alert alert_err">' + data.message + '<div>'); 1316 jQuery('#login_user').val(''); 1317 jQuery('#login_pwd').val(''); 1318 } 1319 }, 1320 error: function (errorThrown) { 1321 1322 } 1323 }); 1324} 1325//////////////////////////////////////////////////////////////////////////////////////////// 1326/// on ready-jslint checked 1327//////////////////////////////////////////////////////////////////////////////////////////// 1328function wpestate_login_topbar() { 1329 "use strict"; 1330 var login_user, login_pwd, ispop, ajaxurl, security; 1331 1332 login_user = jQuery('#login_user_topbar').val(); 1333 login_pwd = jQuery('#login_pwd_topbar').val(); 1334 security = jQuery('#security-login-topbar').val(); 1335 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1336 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1337 jQuery('#login_message_area_topbar').empty().append('<div class="login-alert">
1337' + ajaxcalls_vars.login_loading + '</div>'); 1338 jQuery.ajax({ 1339 type: 'POST', 1340 dataType: 'json', 1341 url: ajaxurl, 1342 data: { 1343 'action' : 'wpestate_ajax_loginx_form_topbar', 1344 'login_user' : login_user, 1345 'login_pwd' : login_pwd, 1346 'security' : nonce 1347 }, 1348 1349 success: function (data) { 1350 jQuery('#login_message_area_topbar').empty().append('<div class="login-alert">' + data.message + '<div>'); 1351 if (data.loggedin === true) { 1352 if(jQuery('body').hasClass('single-estate_property') ){ 1353 location.reload(); 1354 }else{ 1355 document.location.href = ajaxcalls_vars.login_redirect; 1356 } 1357 } else { 1358 jQuery('#login_user').val(''); 1359 jQuery('#login_pwd').val(''); 1360 } 1361 }, 1362 error: function (errorThrown) { 1363 } 1364 }); 1365} 1366 1367 1368 1369//////////////////////////////////////////////////////////////////////////////// 1370// enable actions modal -jslint checked 1371//////////////////////////////////////////////////////////////////////////////// 1372function wpestate_enable_actions_modal() { 1373 "use strict"; 1374 1375 1376 jQuery('#loginmodal').on('hidden.bs.modal', function (e) { 1377 if( jQuery('body').hasClass('page-template-user_dashboard_add_step1') ){ 1378 window.location.href = ajaxcalls_vars.home; 1379 } 1380 }); 1381 1382 jQuery('#loginmodal').on('shown.bs.modal', function () { 1383 if( jQuery('#ajax_register_div').css('display')==='flex'){ 1384 jQuery('#user_login_register').focus(); 1385 }else{ 1386 jQuery('#login_user').focus(); 1387 } 1388 1389 }); 1390 1391 jQuery('#closeadvancedlogin').on('click',function () { 1392 jQuery('#ajax_login_container').remove(); 1393 jQuery('#cover').remove(); 1394 }); 1395 1396 jQuery('#reveal_register').on('click',function () { 1397 jQuery('#ajax_login_div').fadeOut(400, function () { 1398 jQuery('#ajax_login_div').removeClass('show'); 1399 jQuery('#ajax_register_div').removeClass('hidden'); 1400 jQuery('#ajax_register_div').fadeIn(); 1401 jQuery('#user_login_register').focus(); 1402 }); 1403 }); 1404 1405 jQuery('#reveal_login').on('click',function () { 1406 jQuery('#ajax_register_div').fadeOut(400, function () { 1407 jQuery('#ajax_register_div').removeClass('show'); 1408 jQuery('#ajax_login_div').removeClass('hidden'); 1409 jQuery('#ajax_login_div').fadeIn(); 1410 jQuery('#login_user').focus(); 1411 }); 1412 }); 1413 1414 jQuery('#forgot_password_mod').on('click',function (event) { 1415 event.preventDefault(); 1416 jQuery("#ajax_login_div").removeClass('show').hide(); 1417 jQuery("#forgot-pass-div_mod").show(); 1418 jQuery('#forgot_email_mod').focus(); 1419 1420 }); 1421 1422 1423 1424 jQuery('#return_login_mod').on('click',function (event) { 1425 event.preventDefault(); 1426 jQuery("#forgot-pass-div_mod").hide(); 1427 jQuery("#ajax_login_div").show(); 1428 jQuery('#login_user').focus(); 1429 }); 1430 1431 1432 1433 1434} 1435 1436//////////////////////////////////////////////////////////////////////////////// 1437// register function -jslint checked 1438//////////////////////////////////////////////////////////////////////////////// 1439function wpestate_register() { 1440 "use strict"; 1441 1442 var user_pass,user_pass_retype,capthca,user_login_register, user_email_register, nonce, ajaxurl,propid, user_type,user_phone; 1443 user_login_register = jQuery('#user_login_register').val(); 1444 user_email_register = jQuery('#user_email_register').val(); 1445 nonce = jQuery('#security-register').val(); 1446 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1447 propid = jQuery('#wp-login-but').attr('data-mixval'); 1448 user_type = jQuery("input[name=acc_type]:checked").val(); 1449 user_pass = jQuery('#user_password').val(); 1450 user_pass_retype = jQuery('#user_password_retype').val(); 1451 user_phone = jQuery('#user_phone_register').val(); 1452 1453 capthca=''; 1454 if(control_vars.usecaptcha==='yes'){ 1455 capthca= grecaptcha.getResponse( 1456 widgetId1 1457 ); 1458 } 1459 1460 1461 if ( !jQuery('#user_terms_register_sh').is(":checked") ) { 1462 jQuery('#register_message_area').empty().append('<div class="alert_err login-alert">
1462' + control_vars.terms_cond + '</div>'); 1463 grecaptcha.reset(); 1464 return; 1465 } 1466 1467 1468 1469 1470 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1471 1472 jQuery.ajax({ 1473 type: 'POST', 1474 url: ajaxurl, 1475 dataType: 'json', 1476 data: { 1477 'action' : 'wpestate_ajax_register_form', 1478 'user_login_register' : user_login_register, 1479 'user_email_register' : user_email_register, 1480 'security-register' : nonce, 1481 'propid' : propid, 1482 'user_type' : user_type, 1483 'capthca' : capthca, 1484 'user_pass' : user_pass, 1485 'user_pass_retype' : user_pass_retype, 1486 'user_phone' : user_phone, 1487 'security' : nonce, 1488 }, 1489 success: function (data) { 1490 1491 // This outputs the result of the ajax request 1492 if (data.register === true) { 1493 jQuery('#register_message_area').empty().append('<div class="login-alert">' + data.message + '</div>'); 1494 setTimeout(function(){ jQuery('#reveal_login').trigger('click') }, 1500); 1495 }else{ 1496 jQuery('#register_message_area').empty().append('<div class="alert_err login-alert">' + data.message + '</div>'); 1497 grecaptcha.reset(); 1498 } 1499 jQuery('#user_login_register').val(''); 1500 jQuery('#user_email_register').val(''); 1501 }, 1502 error: function (errorThrown) { 1503 1504 } 1505 }); 1506} 1507 1508//////////////////////////////////////////////////////////////////////////////// 1509// register function -jslint checked 1510//////////////////////////////////////////////////////////////////////////////// 1511function wpestate_register_sh() { 1512 "use strict"; 1513 var capthca,user_pass,user_pass_retype,user_login_register, user_email_register, nonce, ajaxurl,propid, user_type,user_phone; 1514 user_login_register = jQuery('#user_login_register_sh').val(); 1515 user_email_register = jQuery('#user_email_register_sh').val(); 1516 1517 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1518 propid = jQuery('#wp-login-but').attr('data-mixval'); 1519 user_type = jQuery("input[name=acc_type_sh]:checked").val(); 1520 user_pass = jQuery('#user_password_sh').val(); 1521 user_pass_retype = jQuery('#user_password_retype_sh').val(); 1522 user_phone = jQuery('#user_phone_register_sh').val(); 1523 1524 if ( !jQuery('#user_terms_register_sh_sh').is(":checked") ) { 1525 jQuery('#register_message_area_sh').empty().append('<div class="alert_err login-alert">' + control_vars.terms_cond + '</div>'); 1526 return; 1527 } 1528 1529 1530 capthca=''; 1531 if(control_vars.usecaptcha==='yes'){ 1532 capthca= grecaptcha.getResponse( 1533 widgetId4 1534 ); 1535 } 1536 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1537 jQuery.ajax({ 1538 type: 'POST', 1539 url: ajaxurl, 1540 dataType: 'json', 1541 data: { 1542 'action' : 'wpestate_ajax_register_form', 1543 'user_login_register' : user_login_register, 1544 'user_email_register' : user_email_register, 1545 'security-register' : nonce, 1546 'propid' : propid, 1547 'user_type' : user_type, 1548 'capthca' : capthca, 1549 'user_pass' : user_pass, 1550 'user_pass_retype' : user_pass_retype, 1551 'user_phone' : user_phone, 1552 'security' : nonce, 1553 }, 1554 success: function (data) { 1555 // This outputs the result of the ajax request 1556 if (data.register === true) { 1557 jQuery('#register_message_area_sh').empty().append('<div class="login-alert">
1557' + data.message + '</div>'); 1558 }else{ 1559 jQuery('#register_message_area_sh').empty().append('<div class="alert_err login-alert">' + data.message + '</div>'); 1560 } 1561 jQuery('#user_login_register_sh').val(''); 1562 jQuery('#user_email_register_sh').val(''); 1563 }, 1564 error: function (errorThrown) { 1565 1566 } 1567 }); 1568} 1569 1570 1571//////////////////////////////////////////////////////////////////////////////// 1572// login function -jslint checked 1573//////////////////////////////////////////////////////////////////////////////// 1574function wpestate_login() { 1575 "use strict"; 1576 var login_user, login_pwd, security, ispop, ajaxurl,propid; 1577 login_user = jQuery('#login_user').val(); 1578 login_pwd = jQuery('#login_pwd').val(); 1579 ispop = jQuery('#loginpop').val(); 1580 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1581 propid = jQuery('#wp-login-but').attr('data-mixval'); 1582 propid = parseInt(propid,10); 1583 1584 jQuery('#login_message_area').empty().removeClass('alert_err').append('<div class="login-alert">' + ajaxcalls_vars.login_loading + '</div>'); 1585 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1586 jQuery.ajax({ 1587 type: 'POST', 1588 dataType: 'json', 1589 url: ajaxurl, 1590 data: { 1591 'action' : 'wpestate_ajax_loginx_form', 1592 'login_user' : login_user, 1593 'login_pwd' : login_pwd, 1594 'ispop' : ispop, 1595 'propid' : propid, 1596 'security' : nonce, 1597 }, 1598 success: function (data) { 1599 1600 1601 1602 if (data.loggedin === true) { 1603 jQuery('#login_message_area').empty().append('<div class="login-alert">' + data.message + '<div>'); 1604 1605 1606 1607 1608 if (parseInt(data.ispop, 10) === 1) { 1609 1610 ajaxcalls_vars.userid = data.newuser; 1611 jQuery('#loginmodal').modal('hide'); 1612 1613 if(jQuery('body').hasClass('single-estate_property') ){ 1614 location.reload(); 1615 }else{ 1616 if(ajaxcalls_vars.redirect_users==='yes'){ 1617 location.reload(); 1618 }else{ 1619 if( ajaxcalls_vars.redirect_custom_link===''){ 1620 document.location.href = ajaxcalls_vars.login_redirect; 1621 }else{ 1622 document.location.href =ajaxcalls_vars.redirect_custom_link; 1623 } 1624 } 1625 } 1626 1627 } else { 1628 if(data.newlink!==''){ 1629 if(jQuery('body').hasClass('page-template-user_dashboard_add_step1') ){ 1630 document.location.href = data.newlink; 1631 }else if(jQuery('body').hasClass('single-estate_property') ){ 1632 location.reload(); 1633 }else{ 1634 if(ajaxcalls_vars.redirect_users==='yes'){ 1635 location.reload(); 1636 }else{ 1637 if( ajaxcalls_vars.redirect_custom_link===''){ 1638 document.location.href = data.newlink; 1639 }else{ 1640 document.location.href =ajaxcalls_vars.redirect_custom_link; 1641 } 1642 } 1643 1644 } 1645 }else{ 1646 1647 if(jQuery('body').hasClass('single-estate_property') ){ 1648 location.reload(); 1649 }else{ 1650 if(ajaxcalls_vars.redirect_users==='yes'){ 1651 location.reload(); 1652 }else{ 1653 if( ajaxcalls_vars.redirect_custom_link===''){ 1654 document.location.href = ajaxcalls_vars.login_redirect; 1655 }else{ 1656 document.location.href =ajaxcalls_vars.redirect_custom_link; 1657 } 1658 } 1659 } 1660 } 1661 1662 } 1663 jQuery('#user_not_logged_in').hide(); 1664 jQuery('#user_logged_in').show(); 1665 1666 1667 1668 } else { 1669 jQuery('#login_message_area').empty().addClass('alert_err').append('<div class="login-alert">
1669' + data.message + '<div>'); 1670 jQuery('#login_user').val(''); 1671 jQuery('#login_pwd').val(''); 1672 } 1673 }, 1674 error: function (errorThrown) { 1675 1676 } 1677 }); 1678} 1679function wpestate_login_sh() { 1680 "use strict"; 1681 var login_user, login_pwd, security, ispop, ajaxurl,propid; 1682 login_user = jQuery('#login_user_sh').val(); 1683 login_pwd = jQuery('#login_pwd_sh').val(); 1684 ispop = jQuery('#loginpop').val(); 1685 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1686 propid = jQuery('#wp-login-but').attr('data-mixval'); 1687 propid = parseInt(propid,10); 1688 1689 jQuery('#login_message_area').empty().removeClass('alert_err').append('<div class="login-alert">' + ajaxcalls_vars.login_loading + '</div>'); 1690 var nonce = jQuery('#wpestate_ajax_log_reg').val(); 1691 jQuery.ajax({ 1692 type: 'POST', 1693 dataType: 'json', 1694 url: ajaxurl, 1695 data: { 1696 'action' : 'wpestate_ajax_loginx_form', 1697 'login_user' : login_user, 1698 'login_pwd' : login_pwd, 1699 'ispop' : ispop, 1700 'propid' : propid, 1701 'security' : nonce 1702 }, 1703 success: function (data) { 1704 1705 1706 1707 if (data.loggedin === true) { 1708 jQuery('#login_message_area_sh').empty().append('<div class="login-alert">' + data.message + '<div>'); 1709 if (parseInt(data.ispop, 10) === 1) { 1710 ajaxcalls_vars.userid = data.newuser; 1711 jQuery('#loginmodal').modal('hide'); 1712 // wprentals_update_menu_bar(data.newuser); 1713 1714 if(jQuery('body').hasClass('single-estate_property') ){ 1715 location.reload(); 1716 }else{ 1717 1718 if( ajaxcalls_vars.redirect_custom_link===''){ 1719 document.location.href = ajaxcalls_vars.login_redirect; 1720 }else{ 1721 document.location.href =ajaxcalls_vars.redirect_custom_link; 1722 } 1723 1724 } 1725 } else { 1726 if(data.newlink!==''){ 1727 1728 if(jQuery('body').hasClass('single-estate_property') ){ 1729 location.reload(); 1730 }else{ 1731 document.location.href = data.newlink; 1732 } 1733 1734 }else{ 1735 if(jQuery('body').hasClass('single-estate_property') ){ 1736 location.reload(); 1737 }else{ 1738 if( ajaxcalls_vars.redirect_custom_link===''){ 1739 document.location.href = ajaxcalls_vars.login_redirect; 1740 }else{ 1741 document.location.href =ajaxcalls_vars.redirect_custom_link; 1742 } 1743 } 1744 } 1745 1746 } 1747 jQuery('#user_not_logged_in').hide(); 1748 jQuery('#user_logged_in').show(); 1749 } else { 1750 jQuery('#login_message_area_sh').empty().addClass('alert_err').append('<div class="login-alert">' + data.message + '<div>'); 1751 jQuery('#login_user_sh').val(''); 1752 jQuery('#login_pwd_sh').val(''); 1753 } 1754 }, 1755 error: function (errorThrown) { 1756 1757 } 1758 }); 1759} 1760 1761 1762 1763 1764//////////////////////////////////////////////////////////////////////////////// 1765// update bar after login -jslint checked 1766//////////////////////////////////////////////////////////////////////////////// 1767function wprentals_update_menu_bar(newuser) { 1768 "use strict"; 1769 var usericon, ajaxurl; 1770 ajaxurl = control_vars.admin_url + 'admin-ajax.php'; 1771 var nonce = jQuery('#wprentals_ajax_filtering').val(); 1772 jQuery.ajax({ 1773 type: 'POST', 1774 dataType: 'json', 1775 url: ajaxurl, 1776 data: { 1777 'action' : "wpestate_update_menu_bar", 1778 'newuser' : newuser 1779 }, 1780 success: function (data) { 1781 jQuery('#user_menu_u').addClass('user_loged'); 1782 jQuery('#user_menu_u').empty().append(data.premenu); 1783 jQuery('#user_menu_u').after(data.menu); 1784 }, 1785 error: function (errorThrown) { 1786 } 1787 });//end ajax 1788} 1789 1790//////////////////////////////////////////////////////////////////////////////////////////// 1791/// on ready -jslint checked 1792//////////////////////////////////////////////////////////////////////////////////////////// 1793jQuery(document).ready(function ($) { 1794 "use strict"; 1795 1796 $('.wpestate_social_login').on('click',function(){ 1797 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1798 var social_type = $(this).attr('data-social'); 1799 var nonce = $(this).parent().find('.wpestate_social_login_nonce').val(); 1800 $.ajax({
1801 type: 'POST', 1802 url: ajaxurl, 1803 data: { 1804 'action' : 'wpestate_social_login_generate_link', 1805 'social_type' : social_type, 1806 'nonce' : nonce 1807 1808 }, 1809 success: function (data) { 1810 wpestate_safe_redirect(data); 1811 }, 1812 error: function (errorThrown) { 1813 } 1814 }); 1815 1816 }); 1817 1818 1819 1820 1821 $('.disable_listing').on('click',function () { 1822 var prop_id = $(this).attr('data-postid'); 1823 var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1824 var nonce = jQuery('#wprentals_property_actions').val(); 1825 1826 $.ajax({ 1827 type: 'POST', 1828 url: ajaxurl, 1829 data: { 1830 'action' : 'wpestate_disable_listing', 1831 'prop_id' : prop_id, 1832 'security' : nonce 1833 1834 }, 1835 success: function (data) { 1836 location.reload(); 1837 }, 1838 error: function (errorThrown) { 1839 } 1840 }); 1841 }); 1842 1843 1844 /////////////////////////////////////////////////////////////////////////////////////////// 1845 //// stripe cancel 1846 /////////////////////////////////////////////////////////////////////////////////////////// 1847 $('#stripe_cancel').on('click',function(){ 1848 var stripe_user_id, ajaxurl; 1849 stripe_user_id = $(this).attr('data-stripeid'); 1850 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1851 $('#stripe_cancel').text(ajaxcalls_vars.saving); 1852 1853 var nonce = jQuery('#wprentals_stripe_cancel').val(); 1854 1855 $.ajax({
1856 type: 'POST', 1857 url: ajaxurl, 1858 data: { 1859 'action' : 'wpestate_cancel_stripe', 1860 'stripe_customer_id' : stripe_user_id, 1861 'security' : nonce 1862 1863 }, 1864 success: function (data) { 1865 $('#stripe_cancel').text(ajaxcalls_vars.stripecancel); 1866 }, 1867 error: function (errorThrown) { 1868 } 1869 }); 1870 }); 1871 1872 //////////////////////////////////////////////////////////////////////////////////////////// 1873 /// resend for approval 1874 /////////////////////////////////////////////////////////////////////////////////////////// 1875 $('.resend_pending').on('click',function () { 1876 var prop_id = $(this).attr('data-listingid'); 1877 wpestate_resend_for_approval(prop_id, $(this)); 1878 }); 1879 1880 /////////////////////////////////////////////////////////////////////////////////////////// 1881 //////// set featured inside membership 1882 /////////////////////////////////////////////////////////////////////////////////////////// 1883 $('.make_featured').on('click',function () { 1884 var prop_id = $(this).attr('data-postid'); 1885 wpestate_make_prop_featured(prop_id, $(this)); 1886 $(this).unbind( "click" ); 1887 }); 1888 1889 $('.duplicate_listing').on('click',function () { 1890 var prop_id = $(this).attr('data-postid'); 1891 wpestate_duplicate_listing(prop_id, $(this)); 1892 $(this).unbind( "click" ); 1893 }); 1894 1895 1896 jQuery('#wpestate_stripe_booking_recurring').on('click',function(){ 1897 1898 var modalid=jQuery(this).attr('data-modalid'); 1899 jQuery('#'+modalid).show(); 1900 jQuery('#'+modalid+' .wpestate_stripe_form_1').show(); 1901 1902 wpestate_start_stripe(1,modalid); 1903 }); 1904 1905 1906 /////////////////////////////////////////////////////////////////////////////////////////// 1907 //////// pack upgrade via paypal 1908 /////////////////////////////////////////////////////////////////////////////////////////// 1909 $('#pick_pack').on('click',function () { 1910 $(this).text(ajaxcalls_vars.processing); 1911 if ($('#pack_recuring').is(':checked')) { 1912 wpestate_recuring_pay_pack_via_paypal(); 1913 } else { 1914 wpestate_pay_pack_via_paypal(); 1915 } 1916 }); 1917 1918 /////////////////////////////////////////////////////////////////////////////////////////// 1919 //////// listing pay via paypal 1920 /////////////////////////////////////////////////////////////////////////////////////////// 1921 $('.listing_submit_normal').on('click',function () { 1922 var prop_id, featured_checker, is_featured, is_upgrade; 1923 prop_id = $(this).attr('data-listingid'); 1924 featured_checker = $(this).parent().find('input'); 1925 is_featured = 0; 1926 is_upgrade = 0; 1927 1928 if (featured_checker.prop('checked')) { 1929 is_featured = 1; 1930 } else { 1931 is_featured = 0; 1932 } 1933 1934 wpestate_listing_pay(prop_id, $(this), is_featured, is_upgrade); 1935 }); 1936 1937 1938 jQuery('.woo_pay_submit').on('click',function () { 1939 var pay_paypal, prop_id, book_id, invoice_id, is_featured, is_upgrade,ajaxurl,depozit,is_submit; 1940 prop_id = jQuery(this).attr('data-propid'); 1941 depozit = jQuery(this).attr('data-deposit'); 1942 is_featured = jQuery(this).attr('data-is_featured'); 1943 var pack_id = jQuery('#pack_select').val(); 1944 is_upgrade = 0; 1945 is_submit = 1; 1946 1947 if (jQuery('.pack-wrapper').length > 0) { 1948 is_submit = 0; 1949 } 1950 1951 1952 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 1953 jQuery.ajax({ 1954 type: 'POST', 1955 url: ajaxurl, 1956 data: { 1957 'action' : 'wpestate_woo_pay', 1958 'propid' : prop_id, 1959 'depozit' : depozit, 1960 'is_submit' : is_submit, 1961 'pack_id' : pack_id, 1962 'is_featured' : is_featured, 1963 // wpestate_woo_pay() verifies this nonce before touching the 1964 // cart. Without it the request 403s into the empty error 1965 // handler below and the button looks dead. dashboard_vars is 1966 // enqueued on every non-archive page, and the success handler 1967 // already relies on it for checkout_url. See issue #301. 1968 'security' : dashboard_vars.wpestate_woo_pay_nonce 1969 }, 1970 success: function (data) { 1971 1972 if(data!==false){ 1973 window.location.href= dashboard_vars.checkout_url; 1974 } 1975 }, 1976 error: function (errorThrown) {} 1977 });//end ajax 1978 });
1979 1980 1981 1982 1983 $('.listing_upgrade').on('click',function () { 1984 var is_upgrade, is_featured, prop_id; 1985 is_upgrade = 1; 1986 is_featured = 0; 1987 prop_id = $(this).attr('data-listingid'); 1988 wpestate_listing_pay(prop_id, $(this), is_featured, is_upgrade); 1989 }); 1990 1991 1992 1993 /////////////////////////////////////////////////////////////////////////////////////////// 1994 /////// Contact page + ajax call on contact 1995 /////////////////////////////////////////////////////////////////////////////////////////// 1996 $('#agent_submit_contact').on('click',function () { 1997 var contact_name, contact_email, contact_website, contact_coment, agent_email, property_id, nonce, ajaxurl; 1998 contact_name = $('#contact_name').val(); 1999 contact_email = $('#contact_email').val(); 2000 contact_website = $('#contact_website').val(); 2001 contact_coment = $('#agent_comment').val(); 2002 2003 2004 nonce = $('#agent_property_ajax_nonce').val(); 2005 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2006 2007 $('#alert-agent-contact').empty().removeClass('alert_err').append(ajaxcalls_vars.sending); 2008 2009 if(ajaxcalls_vars.use_gdpr==='yes'){ 2010 if ( !$('#wpestate_agree_gdpr').is(':checked') ){ 2011 $("#alert-agent-contact").empty().append(ajaxcalls_vars.gdpr_terms); 2012 return; 2013 } 2014 } 2015 2016 $.ajax({
2017 type: 'POST', 2018 dataType: 'json', 2019 url: ajaxurl, 2020 data: { 2021 'action' : 'wpestate_ajax_agent_contact_page', 2022 'name' : contact_name, 2023 'email' : contact_email, 2024 'website' : contact_website, 2025 'comment' : contact_coment, 2026 2027 'nonce' : nonce 2028 }, 2029 success: function (data) { 2030 // This outputs the result of the ajax request 2031 if (data.sent) { 2032 $('#contact_name').val(''); 2033 $('#contact_email').val(''); 2034 $('#contact_website').val(''); 2035 $('#agent_comment').val(''); 2036 $('#alert-agent-contact').empty().append(data.response); 2037 }else{ 2038 $('#alert-agent-contact').empty().addClass('alert_err').append(data.response); 2039 } 2040 2041 }, 2042 error: function (errorThrown) { 2043 } 2044 }); 2045 }); 2046 2047 2048 /////////////////////////////////////////////////////////////////////////////////////////// 2049 //////// property listing listing 2050 //////////////////////////////////////////////////////////////////////////////////////////// 2051 2052 $('.listing_filters_head li').on('click',function () { 2053 var pick, value, parent; 2054 pick = $(this).text(); 2055 value = $(this).attr('data-value'); 2056 parent = $(this).parent().parent(); 2057 parent.find('.filter_menu_trigger').text(pick).append('<span class="caret caret_filter"></span>').attr('data-value', value); 2058 wpestate_start_filtering(1); 2059 }); 2060 2061 /////////////////////////////////////////////////////////////////////////////////////////// 2062 //////// property listing listing 2063 //////////////////////////////////////////////////////////////////////////////////////////// 2064 2065 $('.booking_form_request li').on('click',function () { 2066 var pick, value, parent; 2067 pick = $(this).text(); 2068 value = $(this).attr('data-value'); 2069 parent = $(this).parent().parent(); 2070 parent.find('.filter_menu_trigger').text(pick).append('<span class="caret caret_filter"></span>').attr('data-value', value); 2071 2072 }); 2073 2074 2075 /////////////////////////////////////////////////////////////////////////////////////////// 2076 //////// Ajax add to favorites on listing 2077 //////////////////////////////////////////////////////////////////////////////////////////// 2078 $('.icon-fav').on('click',function (event) { 2079 event.stopPropagation(); 2080 var icon = $(this); 2081 wpestate_add_remove_favorite(icon); 2082 }); 2083 2084 // remove from fav listing on user profile 2085 $('.icon-fav-on-remove').on('click',function () { 2086 if(jQuery('.favorite_dashboard_property_list').length===0 ){ 2087 $(this).parent().parent().parent().parent().remove(); 2088 } 2089 2090 }); 2091 2092 /////////////////////////////////////////////////////////////////////////////////////////// 2093 //////// Ajax add to favorites on propr 2094 //////////////////////////////////////////////////////////////////////////////////////////// 2095 $('#add_favorites').on('click',function () { 2096 var post_id, securitypass, ajaxurl; 2097 2098 post_id = $('#add_favorites').attr('data-postid'); 2099 securitypass = $('#security-pass').val(); 2100 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2101 2102 if (parseInt(ajaxcalls_vars.userid, 10) === 0) { 2103 wpestate_show_login_form(1,1,0); 2104 } else { 2105 $('#add_favorites').text(ajaxcalls_vars.saving); 2106 var nonce = jQuery('#wprentals_ajax_filtering').val(); 2107 $.ajax({
2108 type: 'POST', 2109 url: ajaxurl, 2110 dataType: 'json', 2111 data: { 2112 'action' : 'wpestate_ajax_add_fav', 2113 'post_id' : post_id, 2114 'security' : nonce, 2115 }, 2116 success: function (data) { 2117 if (data.added) { 2118 $('#add_favorites').html(ajaxcalls_vars.favorite).removeClass('isnotfavorite').addClass('isfavorite'); 2119 } else { 2120 $('#add_favorites').html(ajaxcalls_vars.add_favorite).removeClass('isfavorite').addClass('isnotfavorite'); 2121 } 2122 }, 2123 error: function (errorThrown) { 2124 } 2125 }); //end ajax 2126 }// end check login 2127 }); 2128 2129 2130 //////////////////////////////////////////////////////////////////////////////// 2131 // register calls and functions 2132 //////////////////////////////////////////////////////////////////////////////// 2133 $('#wp-submit-register').on('click',function () { 2134 wpestate_register(); 2135 }); 2136 2137 $('#user_email_register, #user_login_register').keydown(function (e) { 2138 if (e.keyCode === 13 ) { 2139 e.preventDefault(); 2140 wpestate_register(); 2141 } 2142 }); 2143 2144 2145 //////////////////////////////////////////////////////////////////////////////// 2146 // register calls shortcode 2147 //////////////////////////////////////////////////////////////////////////////// 2148 $('#wp-submit-register_sh').on('click',function () { 2149 wpestate_register_sh();
2150 }); 2151 2152 $('#user_email_register_sh, #user_login_register_sh').keydown(function (e) { 2153 if (e.keyCode === 13 ) { 2154 e.preventDefault(); 2155 wpestate_register_sh(); 2156 } 2157 }); 2158 2159 2160 2161 2162 2163 /////////////////////////////////////////////////////////////////////////////////////////// 2164 //////// WIDGET Register mobile 2165 //////////////////////////////////////////////////////////////////////////////////////////// 2166 $('#wp-submit-register_wd_mobile').on('click',function () { 2167 wpestate_register_wd_mobile(); 2168 }); 2169 2170 2171 2172 $('#user_email_register_wd_mobile, #user_login_register_wd_mobile').keydown(function (e) { 2173 if (e.keyCode === 13) { 2174 e.preventDefault(); 2175 wpestate_register_wd_mobile(); 2176 } 2177 }); 2178 2179 /////////////////////////////////////////////////////////////////////////////////////////// 2180 //////// WIDGET Register ajax 2181 //////////////////////////////////////////////////////////////////////////////////////////// 2182 $('#wp-submit-register_wd').on('click',function () { 2183 wpestate_register_wd(); 2184 }); 2185 2186 2187 2188 $('#user_email_register_wd, #user_login_register_wd').keydown(function (e) { 2189 if (e.keyCode === 13) { 2190 e.preventDefault(); 2191 wpestate_register_wd(); 2192 } 2193 }); 2194 2195 /////////////////////////////////////////////////////////////////////////////////////////// 2196 //////// login/forgot password actions 2197 //////////////////////////////////////////////////////////////////////////////////////////// 2198 $('#forgot_pass').on('click',function (event) { 2199 event.preventDefault(); 2200 $("#login-div").hide(); 2201 $("#forgot-pass-div").show(); 2202 }); 2203 2204 $('#return_login').on('click',function (event) { 2205 event.preventDefault(); 2206 $("#forgot-pass-div").hide(); 2207 $("#login-div").show(); 2208 }); 2209 2210 2211 2212 2213 /////////////////////////////////////////////////////////////////////////////////////////// 2214 //////// forgot pass 2215 //////////////////////////////////////////////////////////////////////////////////////////// 2216 $('#wp-forgot-but_mod').on('click',function () { 2217 wpestate_forgot(2); 2218 }); 2219 2220 2221 $('#wp-forgot-but').on('click',function () { 2222 wpestate_forgot(3); 2223 }); 2224 2225 $('#forgot_email').keydown(function (e) { 2226 if (e.keyCode === 13) { 2227 e.preventDefault(); 2228 wpestate_forgot(2); 2229 } 2230 }); 2231 2232 2233 /////////////////////////////////////////////////////////////////////////////////////////// 2234 //////// TOPBAR login/forgot password actions 2235 //////////////////////////////////////////////////////////////////////////////////////////// 2236 $('#widget_register_topbar').on('click',function (event) { 2237 event.preventDefault(); 2238 $('#login-div_topbar').hide(); 2239 $('#register-div-topbar').show(); 2240 $('#login-div-title-topbar').hide(); 2241 $('#register-div-title-topbar').show(); 2242 }); 2243 2244 $('#widget_login_topbar').on('click',function (event) { 2245 event.preventDefault(); 2246 $('#login-div_topbar').show(); 2247 $('#register-div-topbar').hide(); 2248 $('#login-div-title-topbar').show(); 2249 $('#register-div-title-topbar').hide(); 2250 }); 2251 2252 2253 /////////////////////////////////////////////////////////////////////////////////////////// 2254 //////// WIDGET login/forgot password actions 2255 //////////////////////////////////////////////////////////////////////////////////////////// 2256 $('#widget_register_sw').on('click',function (event) { 2257 event.preventDefault(); 2258 $('.loginwd_sidebar #login-div').hide(); 2259 $('.loginwd_sidebar #register-div').show(); 2260 $('.loginwd_sidebar #login-div-title').hide(); 2261 $('.loginwd_sidebar #register-div-title').show(); 2262 }); 2263 2264 $('#widget_login_sw').on('click',function (event) { 2265 event.preventDefault(); 2266 $('.loginwd_sidebar #register-div').hide(); 2267 $('.loginwd_sidebar #login-div').show(); 2268 $('.loginwd_sidebar #register-div-title').hide(); 2269 $('.loginwd_sidebar #login-div-title').show(); 2270 });
2271 2272 $('#widget_register_mobile').on('click',function (event) { 2273 event.preventDefault(); 2274 $('.login_sidebar_mobile #login-div-mobile').hide(); 2275 $('.login_sidebar_mobile #register-div-mobile').show(); 2276 $('.login_sidebar_mobile #login-div-title-mobile').hide(); 2277 $('.login_sidebar_mobile #register-div-title-mobile').show(); 2278 jQuery('#user_login_register_wd_mobile').focus(); 2279 }); 2280 2281 2282 $('#widget_login_sw_mobile').on('click',function (event) { 2283 event.preventDefault(); 2284 $('.login_sidebar_mobile #register-div-mobile').hide(); 2285 $('.login_sidebar_mobile #login-div-mobile').show(); 2286 $('.login_sidebar_mobile #register-div-title-mobile').hide(); 2287 $('.login_sidebar_mobile #login-div-title-mobile').show(); 2288 jQuery('#login_user_wd_mobile').focus(); 2289 }); 2290 2291 2292 /////////////////////////////////////////////////////////////////////////////////////////// 2293 //////// login ajax 2294 //////////////////////////////////////////////////////////////////////////////////////////// 2295 $('#wp-login-but').on('click',function () { 2296 wpestate_login(); 2297 }); 2298 2299 $('#login_pwd, #login_user').keydown(function (e) { 2300 if (e.keyCode === 13) { 2301 e.preventDefault(); 2302 wpestate_login(); 2303 } 2304 }); 2305 2306 2307 /////////////////////////////////////////////////////////////////////////////////////////// 2308 //////// login shortcode 2309 //////////////////////////////////////////////////////////////////////////////////////////// 2310 $('#wp-login-but_sh').on('click',function () { 2311 wpestate_login_sh(); 2312 }); 2313 2314 $('#login_pwd_sh, #login_user_sh').keydown(function (e) { 2315 if (e.keyCode === 13) { 2316 e.preventDefault(); 2317 wpestate_login_sh(); 2318 } 2319 }); 2320 2321 2322 2323 /////////////////////////////////////////////////////////////////////////////////////////// 2324 //////// Mobile login ajax 2325 //////////////////////////////////////////////////////////////////////////////////////////// 2326 $('#wp-login-but-wd-mobile').on('click',function () { 2327 wpestate_login_wd_mobile(); 2328 }); 2329 2330 $('#login_pwd_wd_mobile, #login_user_wd_mobile').keydown(function (e) { 2331 if (e.keyCode === 13) { 2332 e.preventDefault(); 2333 wpestate_login_wd_mobile(); 2334 } 2335 }); 2336 2337 2338 $('#forgot_pass_widget_mobile').on('click',function (e) { 2339 e.preventDefault(); 2340 $('#mobile_forgot_wrapper').show(); 2341 $('#login-div-title-mobile,#login-div-mobile').hide(); 2342 jQuery('#forgot_email_mobile').focus(); 2343 }); 2344 2345 $('#return_login_shortcode_mobile').on('click',function(e){ 2346 e.preventDefault(); 2347 $('#login-div-title-mobile,#login-div-mobile').show(); 2348 $('#mobile_forgot_wrapper').hide(); 2349 jQuery('#login_user_wd_mobile').focus(); 2350 }); 2351 2352 $('#wp-forgot-but_mobile').on('click',function(e){ 2353 e.preventDefault(); 2354 wpestate_forgot(4); 2355 }); 2356 2357 2358 /////////////////////////////////////////////////////////////////////////////////////////// 2359 //////// WIDGET login ajax 2360 //////////////////////////////////////////////////////////////////////////////////////////// 2361 2362 $('#wp-login-but-wd').on('click',function () { 2363 wpestate_login_wd(); 2364 }); 2365 2366 $('#login_pwd_wd, #login_user_wd').keydown(function (e) { 2367 if (e.keyCode === 13) { 2368 e.preventDefault(); 2369 wpestate_login_wd(); 2370 } 2371 }); 2372 2373 2374 $('#forgot_pass_widget').on('click',function (e) { 2375 e.preventDefault(); 2376 $('#forgot-div-title_shortcode,#forgot-pass-div_shortcode').show(); 2377 $('#login-div-title,#login-div').hide(); 2378 }); 2379 2380 $('#return_login_shortcode').on('click',function(e){ 2381 e.preventDefault(); 2382 $('#login-div-title,#login-div').show(); 2383 $('#forgot-div-title_shortcode,#forgot-pass-div_shortcode').hide(); 2384 }); 2385 2386 $('#wp-forgot-but_shortcode').on('click',function(e){ 2387 e.preventDefault(); 2388 wpestate_forgot(3); 2389 });
2390 2391 /////////////////////////////////////////////////////////////////////////////////////////// 2392 //////// TOPBAR login ajax 2393 //////////////////////////////////////////////////////////////////////////////////////////// 2394 2395 $('#wp-login-but-topbar').on('click',function () { 2396 wpestate_login_topbar(); 2397 }); 2398 2399 $('#login_pwd_topbar, #login_user_topbar').keydown(function (e) { 2400 if (e.keyCode === 13) { 2401 e.preventDefault(); 2402 wpestate_login_topbar(); 2403 } 2404 }); 2405 2406 2407 /////////////////////////////////////////////////////////////////////////////////////////// 2408 //////// Ajax update password 2409 //////////////////////////////////////////////////////////////////////////////////////////// 2410 $('#oldpass, #newpass, #renewpass').keydown(function (e) { 2411 if (e.keyCode === 13) { 2412 e.preventDefault(); 2413 wpestate_change_pass_profile(); 2414 } 2415 }); 2416 2417 $('#change_pass').on('click',function () { 2418 wpestate_change_pass_profile(); 2419 }); 2420 2421 2422 2423 /////////////////////////////////////////////////////////////////////////////////////////// 2424 //////// Sms validation 2425 //////////////////////////////////////////////////////////////////////////////////////////// 2426 2427 $('#send_sms_pin').on('click',function(){ 2428 var ajaxurl; 2429 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2430 var nonce = jQuery('#wprentals_send_sms_nonce').val(); 2431 2432 $.ajax({
2433 type: 'POST', 2434 url: ajaxurl, 2435 data: { 2436 'action' : 'wpestate_send_valid_sms', 2437 'security' : nonce, 2438 }, 2439 success: function (data) { 2440 // Server returns {success:bool, data:msg}; sent = green, missing number = coral. Issue #140. 2441 var isok = !!(data && data.success); 2442 var msg = (data && typeof data.data !== 'undefined') ? data.data : data; 2443 wpestate_show_profile_message('#sms_profile_message', msg, isok ? 'success' : 'error'); 2444 }, 2445 error: function (errorThrown) { 2446 2447 } 2448 }); 2449 }); 2450 2451 2452 $('#validate_phone').on('click',function(){ 2453 var ajaxurl,validate_phoneno; 2454 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2455 validate_phoneno = $('#validate_phoneno').val(); 2456 var nonce = jQuery('#wprentals_send_sms_nonce').val(); 2457 $.ajax({ 2458 type: 'POST', 2459 url: ajaxurl, 2460 data: { 2461 'action' : 'wpestate_validate_mobile', 2462 'validate_phoneno' : validate_phoneno, 2463 'security' : nonce 2464 }, 2465 success: function (data) { 2466 // Server returns {success:bool, data:msg}; validated = green, wrong code = coral. Issue #140. 2467 var isok = !!(data && data.success); 2468 var msg = (data && typeof data.data !== 'undefined') ? data.data : data; 2469 wpestate_show_profile_message('#sms_profile_message', msg, isok ? 'success' : 'error'); 2470 }, 2471 error: function (errorThrown) { 2472 } 2473 }); 2474 2475 }); 2476 2477 /////////////////////////////////////////////////////////////////////////////////////////// 2478 //////// update profile 2479 //////////////////////////////////////////////////////////////////////////////////////////// 2480 2481 $('#update_profile').on('click',function () { 2482 var userwebsite,youtube,instagram,useridimageid,useridurl,payment_info,paypal_payments_to,live_in,i_speak, usermobile, userpinterest, userlinkedin, usertwitter, userfacebook, profile_image_url, profile_image_url_small, firstname, secondname, useremail, userphone, usertitle, description, ajaxurl, securityprofile, upload_picture, useridurl, useridimageid; 2483 firstname = $('#firstname').val(); 2484 secondname = $('#secondname').val(); 2485 useremail = $('#useremail').val(); 2486 userphone = $('#userphone').val(); 2487 usermobile = $('#usermobile').val(); 2488 userwebsite = $('#userwebsite').val(); 2489 2490 description = $('#about_me').val(); 2491 userfacebook = $('#userfacebook').val(); 2492 usertwitter = $('#usertwitter').val(); 2493 userlinkedin = $('#userlinkedin').val(); 2494 userpinterest = $('#userpinterest').val(); 2495 2496 instagram = $('#userinstagram').val(); 2497 youtube = $('#useryoutube').val(); 2498 2499 live_in = $('#live_in').val(); 2500 i_speak = $('#i_speak').val(); 2501 2502 paypal_payments_to = $('#paypal_payments_to').val(); 2503 payment_info = $('#payment_info').val(); 2504 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2505 securityprofile = $('#security-profile').val(); 2506 upload_picture = $('#upload_picture').val(); 2507 profile_image_url = $('#profile-image').attr('data-profileurl'); 2508 profile_image_url_small = $('#profile-image').attr('data-smallprofileurl'); 2509 2510 useridurl = $('#user-id-image').attr('data-useridurl'); 2511 useridimageid = $('#user-id-image').attr('data-useridimageid'); 2512 2513 // Show a "saving" message below the Update Profile button (issue #140). 2514 wpestate_show_profile_message('#update_profile_message', ajaxcalls_vars.saving, ''); 2515 var nonce = jQuery('#wprentals_update_profile_nonce').val(); 2516 2517 2518 $.ajax({
2519 type: 'POST', 2520 url: ajaxurl, 2521 data: { 2522 'action' : 'wpestate_ajax_update_profile', 2523 'firstname' : firstname, 2524 'secondname' : secondname, 2525 'useremail' : useremail, 2526 'userphone' : userphone, 2527 'usermobile' : usermobile, 2528 'description' : description, 2529 'upload_picture' : upload_picture, 2530 'security-profile' : securityprofile, 2531 'profile_image_url' : profile_image_url, 2532 'profile_image_url_small':profile_image_url_small, 2533 'user_id_url' : useridurl, 2534 'user_id_image_id' : useridimageid, 2535 'userfacebook' : userfacebook, 2536 'usertwitter' : usertwitter, 2537 'userlinkedin' : userlinkedin, 2538 'userpinterest' : userpinterest, 2539 'live_in' : live_in, 2540 'i_speak' : i_speak, 2541 'paypal_payments_to': paypal_payments_to, 2542 'payment_info' : payment_info, 2543 'security' : nonce, 2544 'instagram' : instagram, 2545 'youtube' : youtube, 2546 'userwebsite' : userwebsite, 2547 2548 }, 2549 success: function (data) { 2550 // Server returns {success:bool, data:msg}; map it to green (success) or coral (warning). Issue #140. 2551 var isok = !!(data && data.success); 2552 var msg = (data && typeof data.data !== 'undefined') ? data.data : data; 2553 wpestate_show_profile_message('#update_profile_message', msg, isok ? 'success' : 'error'); 2554 }, 2555 error: function (errorThrown) { 2556 } 2557 }); 2558 }); 2559 2560 2561 2562 $('#delete_profile').on('click',function () { 2563 var ajaxurl; 2564 ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; 2565 2566 var result = confirm(ajaxcalls_vars.delete_account); 2567 if (result) { 2568 var nonce = jQuery('#wprentals_update_profile_nonce').val(); 2569 2570 $.ajax({
2571 type: 'POST', 2572 url: ajaxurl, 2573 data: { 2574 'action' : 'wpestate_delete_profile', 2575 'security' : nonce 2576 }, 2577 success: function (data) { 2578 window.location = '/'; 2579 }, 2580 error: function (errorThrown) { 2581 2582 } 2583 }); 2584 } 2585 }); 2586 2587//end delete profile 2588 2589 2590}); // end ready jquery 2591//End ready ********************************************************************
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.