1(function ($) { 2 "use strict"; 3 4 if (!$.wjbExtensions) 5 $.wjbExtensions = {}; 6 7 function WJBMainCore() { 8 var self = this; 9 self.init(); 10 }; 11 12 WJBMainCore.prototype = { 13 /** 14 * Initialize 15 */ 16 init: function() { 17 var self = this; 18 19 self.fileUpload($('.label-can-drag')); 20 21 self.recaptchaCallback(); 22 23 self.submitProperty(); 24 25 self.userLoginRegister(); 26 27 self.userChangePass(); 28 29 self.removeProperty(); 30 31 // favorite 32 self.addPropertyFavorite(); 33 34 self.removePropertyFavorite(); 35 36 // add agent 37 self.agencyAddAgent(); 38 39 // compare 40 self.addPropertyCompare(); 41 42 self.removePropertyCompare(); 43 44 self.reviewInit(); 45 46 self.propertySavedSearch(); 47 48 self.select2Init(); 49 50 self.filterListing(); 51 52 // property detail 53 self.propertyChartInit(); 54 55 self.propertyNearbyYelp(); 56 57 self.propertyNearbyGooglePlaces(); 58 59 self.propertyWalkScore(); 60 61 // mixes 62 self.mixesFn(); 63 64 self.loadExtension(); 65 }, 66 loadExtension: function() { 67 var self = this; 68 69 // if ($.wjbExtensions.ajax_upload) { 70 // $.wjbExtensions.ajax_upload.call(self); 71 // } 72 }, 73 recaptchaCallback: function() { 74 if ( wp_realestate_opts.recaptcha_enable ) { 75 if (!window.grecaptcha) { 76 } else { 77 setTimeout(function(){ 78 var recaptchas = document.getElementsByClassName("ga-recaptcha"); 79 for(var i=0; i<recaptchas.length; i++) { 80 var recaptcha = recaptchas[i]; 81 var sitekey = recaptcha.dataset.sitekey; 82 83 grecaptcha.render(recaptcha, { 84 'sitekey' : sitekey 85 }); 86 } 87 }, 500); 88 } 89 } 90 }, 91 fileUpload: function($el){ 92 93 var isAdvancedUpload = function() { 94 var div = document.createElement('div'); 95 return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window; 96 }(); 97 98 if (isAdvancedUpload) { 99 100 var droppedFiles = false; 101 $el.each(function(){ 102 var label_self = $(this); 103 label_self.on('drag dragstart dragend dragover dragenter dragleave drop', function(e) { 104 e.preventDefault(); 105 e.stopPropagation(); 106 }).on('dragover dragenter', function() { 107 label_self.addClass('is-dragover'); 108 }).on('dragleave dragend drop', function() { 109 label_self.removeClass('is-dragover'); 110 }).on('drop', function(e) { 111 droppedFiles = e.originalEvent.dataTransfer.files; 112 label_self.parent().find('input[type="file"]').prop('files', droppedFiles).trigger('change'); 113 }); 114 }); 115 } 116 $(document).on('click', '.label-can-drag', function(){ 117 $(this).parent().find('input[type="file"]').trigger('click'); 118 }); 119 }, 120 submitProperty: function() { 121 var self = this; 122 $('.cmb-repeatable-group').on('cmb2_add_row', function (event, newRow) { 123 124 // Reinitialise the field we previously destroyed 125 $(newRow).find('.label-can-drag').each(function () { 126 self.fileUpload($(this)); 127 }); 128 129 }); 130 }, 131 userLoginRegister: function() { 132 var self = this; 133 134 // sign in proccess 135 $('body').on('submit', 'form.login-form', function(){ 136 var $this = $(this); 137 $('.alert', this).remove(); 138 $this.addClass('loading'); 139 $.ajax({
140 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_login' ), 141 type:'POST', 142 dataType: 'json', 143 data: $(this).serialize()+"&action=wp_realestate_ajax_login" 144 }).done(function(data) { 145 $this.removeClass('loading'); 146 if ( data.status ) { 147 $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' ); 148 setTimeout(function(){ 149 if ( data.role == 'wp_realestate_agency' ) { 150 window.location.href = wp_realestate_opts.after_login_page_agency_url; 151 } else if ( data.role == 'wp_realestate_agent' ) { 152 window.location.href = wp_realestate_opts.after_login_page_agent_url; 153 } else { 154 window.location.href = wp_realestate_opts.after_login_page_user_url; 155 } 156 157 }, 500); 158 } else { 159 $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' ); 160 } 161 }); 162 return false; 163 } ); 164 $('body').on('click', '.back-link', function(e){ 165 e.preventDefault(); 166 var $con = $(this).closest('.login-form-wrapper'); 167 $con.find('.form-container').hide(); 168 $($(this).attr('href')).show(); 169 return false; 170 } ); 171 172 // lost password in proccess 173 $('body').on('submit', 'form.forgotpassword-form', function(){ 174 var $this= $(this); 175 $('.alert', this).remove(); 176 $this.addClass('loading'); 177 $.ajax({
178 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_forgotpass' ), 179 type:'POST', 180 dataType: 'json', 181 data: $(this).serialize()+"&action=wp_realestate_ajax_forgotpass" 182 }).done(function(data) { 183 $this.removeClass('loading'); 184 if ( data.status ) { 185 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 186 setTimeout(function(){ 187 window.location.reload(true); 188 }, 500); 189 } else { 190 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 191 } 192 }); 193 return false; 194 } ); 195 $('body').on('click', '#forgot-password-form-wrapper form .btn-cancel', function(e){ 196 e.preventDefault(); 197 $('#forgot-password-form-wrapper').hide(); 198 $('#login-form-wrapper').show(); 199 } ); 200 201 202 // register 203 var register_step = '1'; 204 $('body').on('submit', 'form.register-form', function(){ 205 var $this = $(this), 206 $parent_div = $this.closest('.register-form-wrapper'); 207 $('.alert', this).remove(); 208 if ( $this.hasClass('loading') ) { 209 return; 210 } 211 $this.addClass('loading'); 212 213 var action = 'wp_realestate_ajax_register'; 214 if ( wp_realestate_opts.approval_type === 'phone_approve' ) { 215 if ( register_step == '1' ) { 216 action = 'wp_realestate_ajax_get_opt' 217 } 218 } 219 $.ajax({
220 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ), 221 type:'POST', 222 dataType: 'json', 223 data: $(this).serialize()+"&action=" + action 224 }).done(function(data) { 225 $this.removeClass('loading'); 226 if ( data.status ) { 227 if ( wp_realestate_opts.approval_type === 'phone_approve' ) { 228 if ( register_step == '1' ) { 229 $this.hide(); 230 var $otp_form = $parent_div.find('form.register-form-otp'); 231 $otp_form.find('.sent-txt .no-txt').html(data.msg); 232 $otp_form.show(); 233 234 var $resendLink = $otp_form.find('.resend-link'), 235 $timer = $otp_form.find('.resend-timer'), 236 resendTime = parseInt( wp_realestate_opts.resend_otp_wait_time ); 237 238 if( resendTime > 0 ) { 239 $resendLink.addClass('disabled'); 240 var resendTimer; 241 clearInterval( resendTimer ); 242 243 resendTimer = setInterval(function(){ 244 $timer.html('('+resendTime+')'); 245 if( resendTime <= 0 ){ 246 clearInterval( resendTimer ); 247 $resendLink.removeClass('disabled'); 248 $timer.html(''); 249 } 250 resendTime--; 251 },1000); 252 } 253 254 } else if ( register_step == '2' ) { 255 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 256 if ( data.redirect ) { 257 setTimeout(function(){ 258 if ( data.role == 'wp_realestate_agency' ) { 259 window.location.href = wp_realestate_opts.after_login_page_agency_url; 260 } else if ( data.role == 'wp_realestate_agent' ) { 261 window.location.href = wp_realestate_opts.after_login_page_agent_url; 262 } else { 263 window.location.href = wp_realestate_opts.after_login_page_user_url; 264 } 265 }, 500); 266 } 267 } 268 } else { 269 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 270 if ( data.redirect ) { 271 setTimeout(function(){ 272 if ( data.role == 'wp_realestate_agency' ) { 273 window.location.href = wp_realestate_opts.after_login_page_agency_url; 274 } else if ( data.role == 'wp_realestate_agent' ) { 275 window.location.href = wp_realestate_opts.after_login_page_agent_url; 276 } else { 277 window.location.href = wp_realestate_opts.after_login_page_user_url; 278 } 279 }, 500); 280 } 281 } 282 } else { 283 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 284 if ( wp_realestate_opts.recaptcha_enable ) { 285 if (!window.grecaptcha) { 286 } else { 287 grecaptcha.reset(); 288 } 289 } 290 } 291 }); 292 return false; 293 } ); 294 295 // verify otp 296 $('body').on('submit', 'form.register-form-otp', function(){ 297 var $this = $(this), 298 $parent_div = $this.closest('.register-form-wrapper'), 299 $register_form = $parent_div.find('form.register-form'); 300 301 if ( $this.hasClass('loading') ) { 302 return; 303 } 304 $('.alert', this).remove(); 305 $this.addClass('loading'); 306 307 var otp = ''; 308 $this.find('.otp-input-cont input').each( function( index, input ){ 309 otp += $(this).val(); 310 }); 311 312 var form_data = { 313 'otp': otp, 314 'token': $register_form.find('.register-form-token').val(), 315 } 316 317 $.ajax({
318 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_verify_opt' ), 319 type:'POST', 320 dataType: 'json', 321 data: form_data 322 }).done(function(data) { 323 $this.removeClass('loading'); 324 if ( data.status ) { 325 register_step = '2'; 326 $this.hide(); 327 $register_form.show().trigger('submit'); 328 } else { 329 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 330 } 331 }); 332 return false; 333 } ); 334 335 //Switch Input 336 $('.otp-input-cont input.otp-input').on('keyup', function(){ 337 console.log('aaa'); 338 if( $(this).val().length === parseInt( $(this).attr('maxlength') ) && $(this).next('input.otp-input').length !== 0 ){ 339 $(this).next('input.otp-input').focus(); 340 } 341 342 //Backspace is pressed 343 if( $(this).val().length === 0 && event.keyCode == 8 && $(this).prev('input.otp-input').length !== 0 ){ 344 $(this).prev('input.otp-input').focus().val(''); 345 } 346 }); 347 348 // resend otp 349 $('body').on('click', '.resend-link:not(.disabled)', function(){ 350 var $this = $(this), 351 $parent_div = $this.closest('.register-form-wrapper'), 352 $otp_form = $this.closest('form'); 353 354 if ( $otp_form.hasClass('loading') ) { 355 return; 356 } 357 $('.alert', this).remove(); 358 $otp_form.addClass('loading'); 359 360 $.ajax({
361 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_resend_opt' ), 362 type:'POST', 363 dataType: 'json', 364 }).done(function(data) { 365 $otp_form.removeClass('loading'); 366 if ( data.status ) { 367 368 var $resendLink = $otp_form.find('.resend-link'), 369 $timer = $otp_form.find('.resend-timer'), 370 resendTime = parseInt( wp_realestate_opts.resend_otp_wait_time ); 371 372 if( resendTime > 0 ) { 373 $resendLink.addClass('disabled'); 374 var resendTimer; 375 clearInterval( resendTimer ); 376 377 resendTimer = setInterval(function(){ 378 $timer.html('('+resendTime+')'); 379 if( resendTime <= 0 ){ 380 clearInterval( resendTimer ); 381 $resendLink.removeClass('disabled'); 382 $timer.html(''); 383 } 384 resendTime--; 385 },1000); 386 } 387 388 } else { 389 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 390 } 391 }); 392 return false; 393 } ); 394 395 $(document).on('click', 'form.register-form-otp .no-change', function(){ 396 var $this = $(this); 397 var $parent_div = $this.closest('.register-form-wrapper'); 398 $this.closest('form').hide(); 399 register_step = '1'; 400 $parent_div.find('form.register-form').show(); 401 }); 402 403 // wp-realestate-resend-approve-account-btn 404 $(document).on('click', '.wp-realestate-resend-approve-account-btn', function(e) { 405 e.preventDefault(); 406 var $this = $(this), 407 $container = $(this).parent(); 408 $this.addClass('loading'); 409 $.ajax({
410 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_resend_approve_account' ), 411 type:'POST', 412 dataType: 'json', 413 data: { 414 action: 'wp_realestate_ajax_resend_approve_account', 415 login: $this.data('login'), 416 } 417 }).done(function(data) { 418 $this.removeClass('loading'); 419 if ( data.status ) { 420 $container.html( data.msg ); 421 } else { 422 $container.html( data.msg ); 423 } 424 }); 425 }); 426 427 }, 428 userChangePass: function() { 429 var self = this; 430 $('body').on('submit', 'form.change-password-form', function(){ 431 var $this = $(this); 432 $('.alert', this).remove(); 433 $this.addClass('loading'); 434 $.ajax({
435 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_change_password' ), 436 type:'POST', 437 dataType: 'json', 438 data: $(this).serialize()+"&action=wp_realestate_ajax_change_password" 439 }).done(function(data) { 440 $this.removeClass('loading'); 441 if ( data.status ) { 442 $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' ); 443 setTimeout(function(){ 444 window.location.href = wp_realestate_opts.login_register_url; 445 }, 500); 446 } else { 447 $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' ); 448 } 449 }); 450 return false; 451 } ); 452 }, 453 removeProperty: function() { 454 var self = this; 455 $('.property-button-delete').on('click', function() { 456 var $this = $(this); 457 var r = confirm( wp_realestate_opts.rm_item_txt ); 458 if ( r == true ) { 459 $this.addClass('loading'); 460 var property_id = $(this).data('property_id'); 461 var nonce = $(this).data('nonce'); 462 $.ajax({
463 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property' ), 464 type:'POST', 465 dataType: 'json', 466 data: { 467 'property_id': property_id, 468 'nonce': nonce, 469 'action': 'wp_realestate_ajax_remove_property', 470 } 471 }).done(function(data) { 472 $this.removeClass('loading'); 473 if ( data.status ) { 474 $this.closest('.my-properties-item').remove(); 475 } 476 self.showMessage(data.msg, data.status); 477 }); 478 } 479 }); 480 }, 481 addPropertyFavorite: function() { 482 var self = this; 483 $(document).on('click', '.btn-add-property-favorite', function() { 484 var $this = $(this); 485 $this.addClass('loading'); 486 var property_id = $(this).data('property_id'); 487 var nonce = $(this).data('nonce'); 488 $.ajax({
489 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_add_property_favorite' ), 490 type:'POST', 491 dataType: 'json', 492 data: { 493 'property_id': property_id, 494 'nonce': nonce, 495 'action': 'wp_realestate_ajax_add_property_favorite', 496 } 497 }).done(function(data) { 498 $this.removeClass('loading'); 499 if ( data.status ) { 500 $this.removeClass('btn-add-property-favorite').addClass('btn-added-property-favorite'); 501 $this.data('nonce', data.nonce); 502 503 $(document).trigger( "after_add_property_favorite", [$this, data] ); 504 } 505 self.showMessage(data.msg, data.status); 506 }); 507 }); 508 }, 509 removePropertyFavorite: function() { 510 var self = this; 511 $(document).on('click', '.btn-added-property-favorite', function() { 512 var $this = $(this); 513 $this.addClass('loading'); 514 var property_id = $(this).data('property_id'); 515 var nonce = $(this).data('nonce'); 516 $.ajax({
517 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_favorite' ), 518 type:'POST', 519 dataType: 'json', 520 data: { 521 'property_id': property_id, 522 'nonce': nonce, 523 'action': 'wp_realestate_ajax_remove_property_favorite', 524 } 525 }).done(function(data) { 526 $this.removeClass('loading'); 527 if ( data.status ) { 528 $this.removeClass('btn-added-property-favorite').addClass('btn-add-property-favorite'); 529 $this.data('nonce', data.nonce); 530 531 $(document).trigger( "after_remove_property_favorite", [$this, data] ); 532 } 533 self.showMessage(data.msg, data.status); 534 }); 535 }); 536 537 $('.btn-remove-property-favorite').on('click', function() { 538 var $this = $(this); 539 $this.addClass('loading'); 540 var property_id = $(this).data('property_id'); 541 var nonce = $(this).data('nonce'); 542 $.ajax({
543 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_favorite' ), 544 type:'POST', 545 dataType: 'json', 546 data: { 547 'property_id': property_id, 548 'nonce': nonce, 549 'action': 'wp_realestate_ajax_remove_property_favorite', 550 } 551 }).done(function(data) { 552 $this.removeClass('loading'); 553 if ( data.status ) { 554 $this.closest('.property-favorite-wrapper').remove(); 555 556 $(document).trigger( "after_remove_property_favorite", [$this, data] ); 557 } 558 self.showMessage(data.msg, data.status); 559 }); 560 }); 561 }, 562 // compare 563 agencyAddAgent: function() { 564 var self = this; 565 566 if($.ui != undefined && $.ui.autocomplete != undefined){ 567 $('#team-agent-autocomplete').autocomplete({ 568 source: function(request, response) { 569 $.ajax({
570 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_get_agents' ), 571 type:'POST', 572 dataType: 'json', 573 data: { 574 action: 'wp_realestate_ajax_get_agents', 575 q: request.term 576 }, 577 success: function(data) { 578 response(data); 579 } 580 }); 581 }, 582 select: function( event, ui ) { 583 $( "#team-agent-autocomplete" ).val(''); 584 var html = '<div class="team-agent-inner">'; 585 html += '<input type="hidden" name="agent_id" value="'+ui.item.value+'">'; 586 html += '<div class="team-agent-img">'; 587 if ( ui.item.img ) { 588 html += '<img src="'+ui.item.img+'">'; 589 } else { 590 html += '<i class="fa fa-user"></i>'; 591 } 592 html += '</div>'; 593 html += '<div class="team-agent-content">'; 594 html += '<span class="team-agent-label">'+ui.item.label+'</span>'; 595 html += '<span class="team-agent-remove"><i class="fas fa-times"></i></span>'; 596 html += '</div>'; 597 html += '</div>'; 598 $( "#team-agent-autocomplete" ).closest('.team-agent-autocomplete-wrapper').find('.team-agent-wrapper').html(html); 599 $(document).on('click', '.team-agent-remove', function(e) { 600 $(this).closest('.team-agent-inner').remove(); 601 }); 602 return false; 603 }, 604 create: function () { 605 $(this).data( "ui-autocomplete" )._renderItem = function( ul, item ) { 606 var html = '<div class="team-agent-list-inner">'; 607 html += '<div class="team-agent-list-img">'; 608 if ( item.img ) { 609 html += '<img src="'+item.img+'">'; 610 } else { 611 html += '<i class="fa fa-user"></i>'; 612 } 613 html += '</div>'; 614 html += '<div class="team-agent-list-content">'; 615 html += '<span class="team-agent-list-label">'+item.label+'</span>'; 616 html += '</div>'; 617 html += '</div>'; 618 619 return $( "<li>" ).append( html ).appendTo( ul ); 620 }; 621 } 622 }); 623 } 624 // add 625 $(document).on('submit', 'form.agency-add-agents-form', function(e) { 626 e.preventDefault(); 627 var $this = $(this); 628 $this.addClass('loading'); 629 $.ajax({
630 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_agency_add_agent' ), 631 type:'POST', 632 dataType: 'json', 633 data: $this.serialize() + '&action=wp_realestate_ajax_agency_add_agent' 634 }).done(function(data) { 635 $this.removeClass('loading'); 636 if ( data.status ) { 637 $('.agency-agents-list-inner').append(data.html); 638 $this.find('.team-agent-inner').remove(); 639 } 640 self.showMessage(data.msg, data.status); 641 }); 642 return false; 643 }); 644 // remove 645 $(document).on('click', '.btn-agency-remove-agent', function() { 646 var $this = $(this); 647 var r = confirm( wp_realestate_opts.rm_item_txt ); 648 if ( r == true ) { 649 $this.addClass('loading'); 650 var agent_id = $(this).data('agent_id'); 651 var nonce = $(this).data('nonce'); 652 $.ajax({
653 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_agency_remove_agent' ), 654 type:'POST', 655 dataType: 'json', 656 data: { 657 'agent_id': agent_id, 658 'nonce': nonce, 659 'action': 'wp_realestate_ajax_agency_remove_agent', 660 } 661 }).done(function(data) { 662 $this.removeClass('loading'); 663 if ( data.status ) { 664 $this.closest('article.agent-team').remove(); 665 } 666 self.showMessage(data.msg, data.status); 667 }); 668 } 669 }); 670 }, 671 // compare 672 addPropertyCompare: function() { 673 var self = this; 674 $(document).on('click', '.btn-add-property-compare', function() { 675 var $this = $(this); 676 $this.addClass('loading'); 677 var property_id = $(this).data('property_id'); 678 var nonce = $(this).data('nonce'); 679 $.ajax({
680 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_add_property_compare' ), 681 type:'POST', 682 dataType: 'json', 683 data: { 684 'property_id': property_id, 685 'nonce': nonce, 686 'action': 'wp_realestate_ajax_add_property_compare', 687 } 688 }).done(function(data) { 689 $this.removeClass('loading'); 690 if ( data.status ) { 691 $this.removeClass('btn-add-property-compare').addClass('btn-added-property-compare'); 692 $this.data('nonce', data.nonce); 693 694 $(document).trigger( "after_add_property_compare", [$this, data] ); 695 } 696 self.showMessage(data.msg, data.status); 697 }); 698 }); 699 }, 700 removePropertyCompare: function() { 701 var self = this; 702 $(document).on('click', '.btn-added-property-compare', function() { 703 var $this = $(this); 704 $this.addClass('loading'); 705 var property_id = $(this).data('property_id'); 706 var nonce = $(this).data('nonce'); 707 $.ajax({
708 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_compare' ), 709 type:'POST', 710 dataType: 'json', 711 data: { 712 'property_id': property_id, 713 'nonce': nonce, 714 'action': 'wp_realestate_ajax_remove_property_compare', 715 } 716 }).done(function(data) { 717 $this.removeClass('loading'); 718 if ( data.status ) { 719 $this.removeClass('btn-added-property-compare').addClass('btn-add-property-compare'); 720 $this.data('nonce', data.nonce); 721 722 $(document).trigger( "after_remove_property_compare", [$this, data] ); 723 } 724 self.showMessage(data.msg, data.status); 725 }); 726 }); 727 728 $('.btn-remove-property-compare').on('click', function() { 729 var $this = $(this); 730 $this.addClass('loading'); 731 var property_id = $(this).data('property_id'); 732 var nonce = $(this).data('nonce'); 733 $.ajax({
734 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_property_compare' ), 735 type:'POST', 736 dataType: 'json', 737 data: { 738 'property_id': property_id, 739 'nonce': nonce, 740 'action': 'wp_realestate_ajax_remove_property_compare', 741 } 742 }).done(function(data) { 743 $this.removeClass('loading'); 744 if ( data.status ) { 745 location.reload(); 746 } 747 self.showMessage(data.msg, data.status); 748 }); 749 }); 750 }, 751 reviewInit: function() { 752 var self = this; 753 754 if ( $('.comment-form-rating').length > 0 ) { 755 $('.comment-form-rating .rating-inner').each(function(){ 756 var e_this = $(this); 757 var $star = e_this.find('.review-stars'); 758 var $review = e_this.find('input.rating'); 759 $star.find('li').on('mouseover', 760 function () { 761 $(this).nextAll().find('span').removeClass('active'); 762 $(this).prevAll().find('span').removeClass('active').addClass('active'); 763 $(this).find('span').removeClass('active').addClass('active'); 764 } 765 ); 766 $star.on('mouseout', function(){ 767 var current = $review.val() - 1; 768 var current_e = $star.find('li').eq(current); 769 770 current_e.nextAll().find('span').removeClass('active'); 771 current_e.prevAll().find('span').removeClass('active').addClass('active'); 772 current_e.find('span').removeClass('active').addClass('active'); 773 }); 774 775 $star.find('li').on('click', function () { 776 $(this).nextAll().find('span').removeClass('active'); 777 $(this).prevAll().find('span').removeClass('active').addClass('active'); 778 $(this).find('span').removeClass('active').addClass('active'); 779 780 $review.val($(this).index() + 1); 781 } ); 782 783 }); 784 } 785 }, 786 propertySavedSearch: function() { 787 var self = this; 788 $('.btn-saved-search').magnificPopup({ 789 mainClass: 'wp-realestate-mfp-container', 790 type:'inline', 791 midClick: true 792 }); 793 794 $(document).on('submit', 'form.saved-search-form', function() { 795 var $this = $(this); 796 if ( $this.hasClass('loading') ) { 797 return false; 798 } 799 800 $this.find('.alert').remove(); 801 802 $this.addClass('loading'); 803 var url_vars = self.getUrlVars(); 804 $.ajax({
805 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_add_saved_search' ), 806 type:'POST', 807 dataType: 'json', 808 data: $this.serialize() + '&action=wp_realestate_ajax_add_saved_search' + url_vars 809 }).done(function(data) { 810 $this.removeClass('loading'); 811 if ( data.status ) { 812 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 813 setTimeout(function(){ 814 $.magnificPopup.close(); 815 }, 1500); 816 } else { 817 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 818 } 819 }); 820 821 return false; 822 }); 823 824 // Remove property alert 825 $(document).on('click', '.btn-remove-saved-search', function() { 826 var $this = $(this); 827 $this.addClass('loading'); 828 var saved_search_id = $(this).data('saved_search_id'); 829 var nonce = $(this).data('nonce'); 830 $.ajax({
831 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_remove_saved_search' ), 832 type:'POST', 833 dataType: 'json', 834 data: { 835 'saved_search_id': saved_search_id, 836 'nonce': nonce, 837 'action': 'wp_realestate_ajax_remove_saved_search', 838 } 839 }).done(function(data) { 840 $this.removeClass('loading'); 841 if ( data.status ) { 842 $this.closest('.saved-search-wrapper').remove(); 843 } 844 self.showMessage(data.msg, data.status); 845 }); 846 }); 847 }, 848 getUrlVars: function() { 849 var self = this; 850 var vars = ''; 851 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 852 for(var i = 0; i < hashes.length; i++) { 853 vars += '&' +hashes[i]; 854 } 855 return vars; 856 }, 857 select2Init: function() { 858 var self = this; 859 if ( $.isFunction( $.fn.select2 ) && typeof wp_realestate_select2_opts !== 'undefined' ) { 860 var select2_args = wp_realestate_select2_opts; 861 select2_args['allowClear'] = false; 862 select2_args['minimumResultsForSearch'] = 10; 863 select2_args['width'] = 'auto'; 864 865 select2_args['language'] = { 866 noResults: function(){ 867 return wp_realestate_select2_opts.language_result; 868 } 869 }; 870 871 if($('select').hasClass('orderby')){ 872 select2_args.theme = 'default orderby'; 873 $('select.orderby').select2( select2_args ); 874 } 875 $('select.property_id').select2( select2_args ); 876 } 877 }, 878 filterListing: function() { 879 var self = this; 880 881 $(document).on('click', 'form .toggle-field .heading-label', function(){ 882 var container = $(this).closest('.form-group'); 883 container.find('.form-group-inner').slideToggle(); 884 if ( container.hasClass('hide-content') ) { 885 container.removeClass('hide-content'); 886 } else { 887 container.addClass('hide-content'); 888 } 889 }); 890 $(document).on('click', '.toggle-filter-list', function() { 891 var $this = $(this); 892 var container = $(this).closest('.form-group'); 893 container.find('.terms-list .more-fields').each(function(){ 894 if ( $(this).hasClass('active') ) { 895 $(this).removeClass('active'); 896 $this.find('.text').text(wp_realestate_opts.show_more); 897 } else { 898 $(this).addClass('active'); 899 $this.find('.text').text(wp_realestate_opts.show_less); 900 } 901 }); 902 }); 903 904 if ( $.isFunction( $.fn.slider ) ) { 905 $('.search-distance-slider').each(function(){ 906 var $this = $(this); 907 var search_distance = $this.closest('.search-distance-wrapper').find('input[name^=filter-distance]'); 908 var search_wrap = $this.closest('.search_distance_wrapper'); 909 $(this).slider({ 910 range: "min", 911 value: search_distance.val(), 912 min: 0, 913 max: 100, 914 slide: function( event, ui ) { 915 search_distance.val( ui.value ); 916 $('.text-distance', search_wrap).text( ui.value ); 917 $('.distance-custom-handle', $this).attr( "data-value", ui.value ); 918 search_distance.trigger('change'); 919 }, 920 create: function() { 921 $('.distance-custom-handle', $this).attr( "data-value", $( this ).slider( "value" ) ); 922 } 923 } ); 924 } ); 925 926 $('.main-range-slider').each(function(){ 927 var $this = $(this); 928 $this.slider({ 929 range: true, 930 min: $this.data('min'), 931 max: $this.data('max'), 932 values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ], 933 slide: function( event, ui ) { 934 $this.parent().find('.from-text').text( ui.values[ 0 ] ); 935 $this.parent().find('.filter-from').val( ui.values[ 0 ] ) 936 $this.parent().find('.to-text').text( ui.values[ 1 ] ); 937 $this.parent().find('.filter-to').val( ui.values[ 1 ] ); 938 $this.parent().find('.filter-to').trigger('change'); 939 } 940 } ); 941 }); 942 943 $('.price-range-slider').each(function(){ 944 var $this = $(this); 945 $this.slider({ 946 range: true, 947 min: $this.data('min'), 948 max: $this.data('max'), 949 values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ], 950 slide: function( event, ui ) { 951 var $from_price = ui.values[ 0 ]; 952 var $to_price = ui.values[ 1 ]; 953 if ( wp_realestate_opts.enable_multi_currencies === 'yes' ) { 954 $from_price = self.shortenNumber($from_price); 955 $to_price = self.shortenNumber($to_price); 956 } else { 957 $from_price = self.addCommas($from_price); 958 $to_price = self.addCommas($to_price); 959 } 960 $this.parent().find('.from-text .price-text').text( $from_price ); 961 $this.parent().find('.filter-from').val( ui.values[ 0 ] ) 962 $this.parent().find('.to-text .price-text').text( $to_price ); 963 $this.parent().find('.filter-to').val( ui.values[ 1 ] ); 964 $this.parent().find('.filter-to').trigger('change'); 965 } 966 } ); 967 }); 968 } 969 970 $('.find-me').on('click', function() { 971 $(this).addClass('loading'); 972 var this_e = $(this); 973 var container = $(this).closest('.form-group'); 974 975 navigator.geolocation.getCurrentPosition(function (position) { 976 container.find('input[name="filter-center-latitude"]').val(position.coords.latitude); 977 container.find('input[name="filter-center-longitude"]').val(position.coords.longitude); 978 container.find('input[name="filter-center-location"]').val('Location'); 979 container.find('.clear-location').removeClass('hidden'); 980 981 var position = [position.coords.latitude, position.coords.longitude]; 982 983 if ( typeof L.esri.Geocoding.geocodeService != 'undefined' ) { 984 985 var geocodeService = L.esri.Geocoding.geocodeService(); 986 geocodeService.reverse().latlng(position).run(function(error, result) { 987 container.find('input[name="filter-center-location"]').val(result.address.Match_addr); 988 }); 989 } 990 991 return this_e.removeClass('loading'); 992 }, function (e) { 993 return this_e.removeClass('loading'); 994 }, { 995 enableHighAccuracy: true 996 }); 997 }); 998 999 $('.clear-location').on('click', function() { 1000 var container = $(this).closest('.form-group'); 1001 1002 container.find('input[name="filter-center-latitude"]').val(''); 1003 container.find('input[name="filter-center-longitude"]').val(''); 1004 container.find('input[name="filter-center-location"]').val(''); 1005 container.find('.clear-location').addClass('hidden');
1006 container.find('.leaflet-geocode-container').html(''); 1007 }); 1008 $('input[name="filter-center-location"]').on('keyup', function(){ 1009 var container = $(this).closest('.form-group'); 1010 var val = $(this).val(); 1011 if ( $(this).val() !== '' ) { 1012 container.find('.clear-location').removeClass('hidden'); 1013 } else { 1014 container.find('.clear-location').removeClass('hidden').addClass('hidden'); 1015 } 1016 }); 1017 $('input[name="filter-center-location"]').each(function(){ 1018 var container = $(this).closest('.form-group'); 1019 var val = $(this).val(); 1020 if ( $(this).val() !== '' ) { 1021 container.find('.clear-location').removeClass('hidden'); 1022 } else { 1023 container.find('.clear-location').removeClass('hidden').addClass('hidden'); 1024 } 1025 }); 1026 1027 // search autocomplete location 1028 if ( wp_realestate_opts.map_service == 'google-map' ) { 1029 if (typeof google === 'object' && typeof google.maps === 'object') { 1030 function search_location_initialize() { 1031 1032 $('input[name="filter-center-location"]').each(function(){ 1033 var $id = $(this).attr('id'); 1034 1035 if ( typeof $id !== 'undefined' ) { 1036 var container = $('#'+$id).closest('.form-group-inner'); 1037 var input = document.getElementById($id); 1038 var autocomplete = new google.maps.places.Autocomplete(input); 1039 autocomplete.setTypes([]); 1040 1041 if ( wp_realestate_opts.geocoder_country ) { 1042 autocomplete.setComponentRestrictions({ 1043 country: [wp_realestate_opts.geocoder_country], 1044 }); 1045 } 1046 1047 autocomplete.addListener( 'place_changed', function () { 1048 var place = autocomplete.getPlace(); 1049 place.toString(); 1050 1051 if (!place.geometry) { 1052 window.alert("No details available for input: '" + place.name + "'"); 1053 return; 1054 } 1055 1056 container.find('input[name=filter-center-latitude]').val(place.geometry.location.lat()); 1057 container.find('input[name=filter-center-longitude]').val(place.geometry.location.lng()); 1058 1059 }); 1060 } 1061 }); 1062 } 1063 google.maps.event.addDomListener(window, 'load', search_location_initialize); 1064 } 1065 } else { 1066 if ( typeof L.Control.Geocoder.Nominatim != 'undefined' ) { 1067 if ( wp_realestate_opts.geocoder_country ) { 1068 var geocoder = new L.Control.Geocoder.Nominatim({ 1069 geocodingQueryParams: {countrycodes: wp_realestate_opts.geocoder_country} 1070 }); 1071 } else { 1072 var geocoder = new L.Control.Geocoder.Nominatim(); 1073 } 1074 1075 function delay(fn, ms) { 1076 let timer = 0 1077 return function(...args) { 1078 clearTimeout(timer) 1079 timer = setTimeout(fn.bind(this, ...args), ms || 0) 1080 } 1081 } 1082 1083 $("input[name=filter-center-location]").attr('autocomplete', 'off').after('<div class="leaflet-geocode
1083-container"></div>'); 1084 $("input[name=filter-center-location]").on("keyup", delay(function (e) { 1085 var s = $(this).val(), $this = $(this), container = $(this).closest('.form-group-inner'); 1086 if (s && s.length >= 2) { 1087 1088 $this.parent().addClass('loading'); 1089 geocoder.geocode(s, function(results) { 1090 var output_html = ''; 1091 for (var i = 0; i < results.length; i++) { 1092 output_html += '<li class="result-item" data-latitude="'+results[i].center.lat+'" data-longitude="'+results[i].center.lng+'" ><i class="fas fa-map-marker-alt" aria-hidden="true"></i> '+results[i].name+'</li>'; 1093 } 1094 if ( output_html ) { 1095 output_html = '<ul>'+ output_html +'</ul>'; 1096 } 1097 1098 container.find('.leaflet-geocode-container').html(output_html).addClass('active'); 1099 1100 var highlight_texts = s.split(' '); 1101 1102 highlight_texts.forEach(function (item) { 1103 container.find('.leaflet-geocode-container').highlight(item); 1104 }); 1105 1106 $this.parent().removeClass('loading'); 1107 }); 1108 } else { 1109 container.find('.leaflet-geocode-container').html('').removeClass('active'); 1110 } 1111 }, 500)); 1112 $('.form-group-inner').on('click', '.leaflet-geocode-container ul li', function() { 1113 var container = $(this).closest('.form-group-inner'); 1114 container.find('input[name=filter-center-latitude]').val($(this).data('latitude')); 1115 container.find('input[name=filter-center-longitude]').val($(this).data('longitude')); 1116 container.find('input[name=filter-center-location]').val($(this).text()); 1117 container.find('.leaflet-geocode-container').removeClass('active').html(''); 1118 }); 1119 } 1120 } 1121 1122 // advance 1123 $('.filter-toggle-adv').on('click', function(e){ 1124 $('.filter-advance-fields').slideToggle(); 1125 return false; 1126 }); 1127 }, 1128 propertyChartInit: function() { 1129 var $this = $('#property_chart_wrapper'); 1130 if( $this.length <= 0 ) { 1131 return; 1132 } 1133 if ( $this.hasClass('loading') ) { 1134 return; 1135 } 1136 $this.addClass('loading'); 1137 1138 $.ajax({
1139 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_get_property_chart' ), 1140 type:'POST', 1141 dataType: 'json', 1142 data: { 1143 action: 'wp_realestate_get_property_chart', 1144 property_id: $this.data('property_id'), 1145 nonce: $this.data('nonce'), 1146 } 1147 }).done(function(response) { 1148 if (response.status == 'error') { 1149 $this.remove(); 1150 } else { 1151 var ctx = $this.get(0).getContext("2d"); 1152 var myNewChart = new Chart(ctx); 1153 var data = { 1154 labels: response.stats_labels, 1155 datasets: [ 1156 { 1157 label: response.stats_view, 1158 backgroundColor: response.bg_color, 1159 borderColor: response.border_color, 1160 borderWidth: 1, 1161 data: response.stats_values 1162 }, 1163 ] 1164 }; 1165 1166 var options = { 1167 //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value 1168 scaleBeginAtZero : true, 1169 //Boolean - Whether grid lines are shown across the chart 1170 scaleShowGridLines : false, 1171 //String - Colour of the grid lines 1172 scaleGridLineColor : "rgba(0,0,0,.05)", 1173 //Number - Width of the grid lines 1174 scaleGridLineWidth : 1, 1175 //Boolean - Whether to show horizontal lines (except X axis) 1176 scaleShowHorizontalLines: true, 1177 //Boolean - Whether to show vertical lines (except Y axis) 1178 scaleShowVerticalLines: true, 1179 //Boolean - If there is a stroke on each bar 1180 barShowStroke : false, 1181 //Number - Pixel width of the bar stroke 1182 barStrokeWidth : 2, 1183 //Number - Spacing between each of the X value sets 1184 barValueSpacing : 5, 1185 //Number - Spacing between data sets within X values 1186 barDatasetSpacing : 1, 1187 legend: { display: false }, 1188 1189 tooltips: { 1190 enabled: true, 1191 mode: 'x-axis', 1192 cornerRadius: 4 1193 }, 1194 } 1195 1196 var myBarChart = new Chart(ctx, { 1197 type: response.chart_type, 1198 data: data, 1199 options: options 1200 }); 1201 1202 $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) { 1203 var target = $(e.target).attr("href"); 1204 var $con = $("#property_chart_wrapper", target); 1205 1206 if ($con.length > 0 ) { 1207 myBarChart.update(); 1208 } 1209 }); 1210 } 1211 $this.removeClass('loading'); 1212 }); 1213 }, 1214 propertyNearbyYelp: function() { 1215 var $this = $('#property-section-nearby_yelp'); 1216 if ( $this.length <= 0 ) { 1217 return; 1218 } 1219 if ( $this.hasClass('loading') ) { 1220 return; 1221 } 1222 $this.addClass('loading'); 1223 1224 $.ajax({
1225 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_get_nearby_yelp' ), 1226 type:'POST', 1227 dataType: 'json', 1228 data: { 1229 action: 'wp_realestate_get_nearby_yelp', 1230 property_id: $this.data('property_id'), 1231 nonce: $this.data('nonce'), 1232 } 1233 }).done(function(response) { 1234 if (response.status) { 1235 $this.html( response.html ); 1236 } else { 1237 $this.remove(); 1238 } 1239 $(document).trigger( "after_nearby_yelp_content", [$this, response] ); 1240 $this.removeClass('loading'); 1241 }); 1242 }, 1243 propertyNearbyGooglePlaces: function() { 1244 var $this = $('#property-section-google-places'); 1245 if ( $this.length <= 0 ) { 1246 return; 1247 } 1248 if ( $this.hasClass('loading') ) { 1249 return; 1250 } 1251 $this.addClass('loading'); 1252 1253 $.ajax({
1254 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_get_nearby_google_places' ), 1255 type:'POST', 1256 dataType: 'json', 1257 data: { 1258 action: 'wp_realestate_get_nearby_google_places', 1259 property_id: $this.data('property_id'), 1260 nonce: $this.data('nonce'), 1261 } 1262 }).done(function(response) { 1263 if (response.status) { 1264 $this.find('.property-section-content').html( response.html ); 1265 } else { 1266 $this.remove(); 1267 } 1268 $(document).trigger( "after_nearby_google_place_content", [$this, response] ); 1269 $this.removeClass('loading'); 1270 }); 1271 }, 1272 propertyWalkScore: function() { 1273 var $this = $('#property-section-walk_score'); 1274 if ( $this.length <= 0 ) { 1275 return; 1276 } 1277 if ( $this.hasClass('loading') ) { 1278 return; 1279 } 1280 $this.addClass('loading'); 1281 1282 $.ajax({
1283 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_get_walk_score' ), 1284 type:'POST', 1285 dataType: 'json', 1286 data: { 1287 action: 'wp_realestate_get_walk_score', 1288 property_id: $this.data('property_id'), 1289 nonce: $this.data('nonce'), 1290 } 1291 }).done(function(response) { 1292 if (response.status) { 1293 $this.html( response.html ); 1294 } else { 1295 $this.remove(); 1296 } 1297 $(document).trigger( "after_walk_score_content", [$this, response] ); 1298 $this.removeClass('loading'); 1299 }); 1300 }, 1301 mixesFn: function() { 1302 var self = this; 1303 1304 $( '.my-properties-ordering' ).on( 'change', 'select.orderby', function() { 1305 $( this ).closest( 'form' ).submit(); 1306 }); 1307 1308 $('.contact-form-wrapper').on('submit', function(){ 1309 var $this = $(this); 1310 $this.addClass('loading'); 1311 $this.find('.alert').remove(); 1312 $.ajax({
1313 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_contact_form' ), 1314 type:'POST', 1315 dataType: 'json', 1316 data: $this.serialize() + '&action=wp_realestate_ajax_contact_form' 1317 }).done(function(data) { 1318 $this.removeClass('loading'); 1319 if ( data.status ) { 1320 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 1321 } else { 1322 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 1323 } 1324 }); 1325 1326 return false; 1327 }); 1328 1329 $(document).on( 'submit', 'form.delete-profile-form', function() { 1330 var $this = $(this); 1331 $this.addClass('loading'); 1332 $(this).find('.alert').remove(); 1333 $.ajax({ 1334 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_realestate_ajax_delete_profile' ), 1335 type:'POST', 1336 dataType: 'json', 1337 data: $this.serialize() + '&action=wp_realestate_ajax_delete_profile' 1338 }).done(function(data) { 1339 $this.removeClass('loading'); 1340 if ( data.status ) { 1341 $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' ); 1342 window.location.href = wp_realestate_opts.home_url; 1343 } else { 1344 $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' ); 1345 } 1346 }); 1347 1348 return false; 1349 }); 1350 1351 if ( $( 'input.field-datetimepicker' ).length > 0 && $.isFunction( $.fn.datetimepicker ) ) { 1352 $('input.field-datetimepicker').datetimepicker({ 1353 timepicker: false, 1354 format: 'Y-m-d' 1355 }); 1356 } 1357 1358 // Location Change 1359 $('body').on('change', 'select.select-field-region', function(){ 1360 var val = $(this).val(); 1361 var next = $(this).data('next'); 1362 var main_select = 'select.select-field-region' + next; 1363 if ( $(main_select).length > 0 ) { 1364 1365 var select2_args = wp_realestate_select2_opts; 1366 select2_args['allowClear'] = true; 1367 select2_args['minimumResultsForSearch'] = 10; 1368 select2_args['width'] = '100%'; 1369 1370 select2_args['language'] = { 1371 noResults: function(){ 1372 return wp_realestate_select2_opts.language_result; 1373 } 1374 }; 1375 1376 $(main_select).prop('disabled', true); 1377 $(main_select).val('').trigger('change'); 1378 1379 if ( val ) { 1380 $(main_select).parent().addClass('loading'); 1381 $.ajax({
1382 url: wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wpre_process_change_location' ), 1383 type:'POST', 1384 dataType: 'json', 1385 data:{ 1386 'action': 'wpre_process_change_location', 1387 'parent': val, 1388 'taxonomy': $(main_select).data('taxonomy'), 1389 'security': wp_realestate_opts.ajax_nonce, 1390 } 1391 }).done(function(data) { 1392 $(main_select).parent().removeClass('loading'); 1393 1394 $(main_select).find('option').remove(); 1395 if ( data ) { 1396 $.each(data, function(i, item) { 1397 var option = new Option(item.name, item.id, true, true); 1398 $(main_select).append(option); 1399 }); 1400 } 1401 $(main_select).prop("disabled", false); 1402 $(main_select).val(null).select2("destroy").select2(select2_args); 1403 }); 1404 } else { 1405 $(main_select).find('option').remove(); 1406 $(main_select).prop("disabled", false); 1407 $(main_select).val(null).select2("destroy").select2(select2_args); 1408 } 1409 } 1410 }); 1411 1412 $('body').on('change', '.properties-currencies input', function(){ 1413 $(this).closest('form').trigger('submit'); 1414 }); 1415 }, 1416 shortenNumber: function($number) { 1417 var self = this; 1418 1419 var divisors = wp_realestate_opts.divisors; 1420 1421 $.each(divisors, function( $index, $value ) { 1422 if ($number < ($value['divisor'] * 1000)) { 1423 $number = $number / $value['divisor']; 1424 return self.addCommas($number) + $value['key']; 1425 } 1426 }); 1427 1428 return $number; 1429 }, 1430 addCommas: function(str) { 1431 var parts = (str + "").split("."), 1432 main = parts[0], 1433 len = main.length, 1434 output = "", 1435 first = main.charAt(0), 1436 i; 1437 1438 if (first === '-') { 1439 main = main.slice(1); 1440 len = main.length; 1441 } else { 1442 first = ""; 1443 } 1444 i = len - 1; 1445 while(i >= 0) { 1446 output = main.charAt(i) + output; 1447 if ((len - i) % 3 === 0 && i > 0) { 1448 output = wp_realestate_opts.money_thousands_separator + output; 1449 } 1450 --i; 1451 } 1452 // put sign back 1453 output = first + output; 1454 // put decimal part back 1455 if (parts.length > 1) { 1456 output += wp_realestate_opts.money_dec_point + parts[1]; 1457 } 1458 return output; 1459 }, 1460 showMessage: function(msg, status) { 1461 if ( msg ) { 1462 var classes = 'alert bg-warning'; 1463 if ( status ) { 1464 classes = 'alert bg-info'; 1465 } 1466 var $html = '<div id="wp-realestate-popup-message" class="animated fadeInRight"><div class="message-inner '+ classes +'">'+ msg +'</div></div>'; 1467 $('body').find('#wp-realestate-popup-message').remove(); 1468 $('body').append($html).fadeIn(500); 1469 setTimeout(function() { 1470 $('body').find('#wp-realestate-popup-message').removeClass('fadeInRight').addClass('delay-2s fadeOutRight'); 1471 }, 1500); 1472 } 1473 }, 1474 setCookie: function(cname, cvalue, exdays) { 1475 var d = new Date(); 1476 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 1477 var expires = "expires="+d.toUTCString(); 1478 document.cookie = cname + "=" + cvalue + "; " + expires+";path=/"; 1479 }, 1480 getCookie: function(cname) { 1481 var name = cname + "="; 1482 var ca = document.cookie.split(';'); 1483 for(var i=0; i<ca.length; i++) { 1484 var c = ca[i];
1485 while (c.charAt(0)==' ') c = c.substring(1); 1486 if (c.indexOf(name) == 0) return c.substring(name.length,c.length); 1487 } 1488 return ""; 1489 }, 1490 } 1491 1492 $.wjbMainCore = WJBMainCore.prototype; 1493 1494 $(document).ready(function() { 1495 // Initialize script 1496 new WJBMainCore(); 1497 1498 }); 1499 1500})(jQuery); 1501
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.