PageSourceSearch

https://boisehunterhomes.com/wp-content/themes/wpresidence/js/control.js?ver=5.3.0

js boisehunterhomes.com collected 2026-10-05 01:32:08 UTC 190,349 bytes, 5,435 lines download raw bytes

1/*global $,Modernizr, jQuery, ajaxcalls_vars,wpestate_custom_search_start_filtering_ajax,imagesLoaded,wpestate_restart_js_after_ajax, panorama,wpestate_toggleStreetView,wpestate_start_filtering_ajax,map,google,wpestate_new_open_close_map,document,initialGeop,placeCircle,wpestate_custom_search_start_filtering_ajax,first_time_wpestate_show_inpage_ajax_half,wpestate_show_pins, wpestate_load_stats,wpestate_enable_half_map_pin_action,wpestate_change_map_type,wpestate_load_stats_tabs,control_vars,mapfunctions_vars, wpestate_map_shortcode_function,grecaptcha,window*/
2var width,height;
3width   = jQuery(window).width();
4height  = jQuery(window).height();
5var scroll_trigger  =   0;
6var scroll_modal_save,scroll_modal;
7var modal_url       = window.location.href;
8var modal_title     = document.getElementsByTagName("title")[0];
9var slider_counter = 0;
10
11
12
13jQuery(window).bind("load", function() {
14    wpestate_lazy_load_carousel_property_unit();
15});
16
17
18if(document.getElementById("search_wrapper")){
19    var searchbar       = document.getElementById("search_wrapper");
20    var sticky_search   = searchbar.offsetTop;
21}
22
23
24
25var switch_logo;
26switch_logo = jQuery('.header_wrapper_inside').attr('data-sticky-logo');
27
28if(jQuery('.header5_top_row').length > 0){
29    switch_logo = jQuery('.header5_top_row').attr('data-sticky-logo');
30}
31if(wpestate_isRetinaDisplay()){
32    switch_logo=wpestate_get_custom_retina_pin(switch_logo);
33    
34}
35
36
37var switch_logo_original = jQuery('.header_wrapper_inside').attr('data-logo');
38if(jQuery('.header5_top_row').length > 0){
39    switch_logo_original = jQuery('.header5_top_row').attr('data-logo');
40}
41
42if(wpestate_isRetinaDisplay()){
43    switch_logo_original=wpestate_get_custom_retina_pin(switch_logo_original);
44}
45
46function wpestate_get_custom_retina_pin(custom_img){
47    "use strict";
48    
49    if(typeof(custom_img) === "undefined"){
50        return;
51    }
52    var custom_img_retina;
53    custom_img_retina=custom_img.replace(".png","_2x.png");
54
55    jQuery.get(custom_img_retina)
56        .done(function() {
57            custom_img = custom_img_retina;
58        }).fail(function() {
59        });
60    return custom_img;
61}
62
63
64
65
66jQuery(window).scroll(function () {
67    "use strict";
68    var scroll =scroll_modal= jQuery(window).scrollTop();
69
70    if(control_vars.stiky_search==='yes'){
71        wpestate_adv_search_sticky(scroll);
72    }else{
73        wpestate_header_sticky(scroll);
74    }
75
76
77    if (scroll >= control_vars.scroll_trigger) {
78        jQuery('.contact-box').addClass('islive');
79        jQuery('.backtop').addClass('islive');
80    }else{
81        jQuery('.contact-box ').removeClass('islive');
82        jQuery('.backtop').removeClass('islive');
83        jQuery('.contactformwrapper').addClass('hidden');
84    }
85    jQuery('.contact_close_button').on( 'click', function(event) {
86        event.preventDefault();
87        jQuery('.contactformwrapper').addClass('hidden');
88    });
89
90});
91
92
93
94
95
96
97var sticky_search_local = document.getElementById("search_wrapper") ? document.getElementById("search_wrapper").offsetTop : 0;
98var search_height = jQuery('#search_wrapper').height();
99
100
101
102/*
103* When we advanced search sticky
104*
105*
106*/
107// Global variable to store the scroll position at which the searchbar
108// should be considered as "exiting" the viewport
109var searchbarExitingThreshold;
110
111/**
112 * Calculates the threshold at which the searchbar is considered to be exiting the viewport.
113 * This function should be called on page load and window resize to ensure accuracy.
114 */
115function calculateSearchbarThreshold() {
116    "use strict";
117    var searchbar = jQuery('.search_wrapper_sticky_search');
118    if (searchbar.length > 0) {
119        // Get the initial top position of the searchbar
120        var searchbarInitialPosition = searchbar.offset().top;
121        // Get the height of the searchbar
122        var searchbarHeight = searchbar.outerHeight();
123        // Calculate the threshold by adding the initial position and height
124        searchbarExitingThreshold = searchbarInitialPosition + searchbarHeight;
125      
126    }
127}
128
129/**
130 * Main function to handle the sticky behavior of the advanced search bar.
131 * This function is called on scroll events.
132 * 
133 * @param {number} scroll - The current scroll position of the window.
134 */
135function wpestate_adv_search_sticky(scroll) {
136    "use strict";
137
138    // Early return if the search wrapper doesn't exist
139    if (!document.getElementById("search_wrapper")) {
140        return;
141    }
142    // Early return for mobile devices (screens smaller than 1024px)
143    if (screen.width < 1024) {
144        return;
145    }
146
147    var searchbar = jQuery('.search_wrapper_sticky_search.with_search_form_float');
148    // Early return if the searchbar doesn't exist
149    if (searchbar.length === 0) {
150        return;
151    }
152
153    if (scroll >= searchbarExitingThreshold) {
154        // The searchbar is exiting or has exited the screen
155        if (!searchbar.hasClass('sticky_adv_anime')) {
156            // Add the class only if it's not already present
157            searchbar.addClass('sticky_adv_anime');
158      
159        }
160    } else {
161        // The searchbar is visible on the screen
162        if (searchbar.hasClass('sticky_adv_anime')) {
163            // Remove the class only if it's present
164            searchbar.removeClass('sticky_adv_anime');
165       
166        }
167    }
168}
169
170
171
172
173
174
175
176
177
178function wpestate_header_sticky(scroll){
179
180    "use strict";
181
182    var sticky_class="master_header_sticky";
183    var control_vars_scroll_trigger=parseInt(control_vars.scroll_trigger);
184
185    if(control_vars.content_type!='' && control_vars.content_type!=='tabs' && jQuery('.wpestate_top_property_navigation_link').length!==0){
186         sticky_class=sticky_class+" "+"sticky_property_menu"
187    }
188    
189
190    if(jQuery('.admin-bar').length>0){
191        control_vars_scroll_trigger=control_vars_scroll_trigger+32;
192    }
193            
194    if (scroll >= control_vars_scroll_trigger) {
195        if (!Modernizr.mq('only all and (max-width: 1023px)')) {
196
197            jQuery(".master_header").addClass(sticky_class);
198            jQuery('.logo').addClass('miclogo');
199            if( switch_logo!=='' ){
200                jQuery('#logo_image').attr('src',switch_logo);
201            }
202
203            if( !jQuery(".header_wrapper").hasClass('header_type4') ){
204                jQuery(".header_wrapper").addClass("navbar-fixed-top");
205     
206            }
207        
208            jQuery('#user_menu_open').hide();
209            jQuery('.navicon-button').removeClass('opensvg');
210            jQuery('#wpestate_header_shoping_cart').hide();
211
212            jQuery('.wpestate_top_property_navigation').addClass('sticky_property_menu_visible');
213
214        }
215
216    } else {
217        jQuery(".master_header").removeClass(sticky_class);
218        jQuery(".header_wrapper").removeClass("navbar-fixed-top");
219
220
221      
222        jQuery('#user_menu_open').hide();
223        jQuery('#wpestate_header_shoping_cart').hide();
224        jQuery('.logo').removeClass('miclogo');
225
226        jQuery('.wpestate_top_property_navigation').removeClass('sticky_property_menu_visible');
227
228
229        if( switch_logo!=='' ){
230           
231            jQuery('#logo_image').attr('src',switch_logo_original);
232        }
233    }
234}
235
236
237
238function wpestate_isRetinaDisplay() {
239    "use strict";
240    if (window.matchMedia) {
241        var mq = window.matchMedia("only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen  and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)");
242        return (mq && mq.matches || (window.devicePixelRatio > 1));
243    }
244}
245
246
247/**
248 * Property Navigation Scroll Handler
249 * 
250 * Manages smooth scrolling to property sections and highlights
251 * active navigation items based on scroll position.
252 * 
253 * Dependencies:
254 * - jQuery
255 * - .wpestate_top_property_navigation element with anchor links
256 * - .property-panel elements with matching IDs
257 */
258
259function wpestate_property_sticky() {
260    'use strict';
261    
262    const SCROLL_OFFSET = 80;
263    const SCROLL_DURATION = 500;
264    const $navigation = jQuery('.wpestate_top_property_navigation a');
265
266    // Handle navigation click events
267    $navigation.on('click', function(event) {
268        event.preventDefault();
269        
270        // Get target section
271        const targetId = jQuery(this).attr('href');
272        const $targetElement = jQuery(targetId);
273        
274        // Update active state
275        $navigation.removeClass('item_active');
276        jQuery(this).addClass('item_active');
277        
278        // Smooth scroll to target
279        jQuery('html, body').animate({
280            scrollTop: $targetElement.offset().top - SCROLL_OFFSET
281        }, SCROLL_DURATION);
282    });
283    
284    // Handle scroll events
285    jQuery(window).on('scroll', function() {
286        const scrollTop = jQuery(window).scrollTop() + SCROLL_OFFSET;
287        let currentSection = null;
288
289        // Find the current section
290        jQuery('.property-panel').each(function() {
291            const sectionTop = jQuery(this).offset().top;
292            const sectionBottom = sectionTop + jQuery(this).outerHeight();
293            
294            if (scrollTop >= sectionTop && scrollTop < sectionBottom) {
295                currentSection = this.id;
296                return false; // Break the loop when found
297            }
298        });
299
300        // Update active state only if a section is found
301        $navigation.removeClass('item_active');
302        jQuery('.wpestate_top_property_navigation a').removeClass('item_active');
303      
304        if (currentSection) {
305            $navigation.filter(`[href="#${currentSection}"]`).addClass('item_active');
306         
307        }
308    });
309}
310
311
312jQuery(window).resize(function() {
313    "use strict";
314    if(jQuery(window).width() != width ){
315        jQuery('#mobile_menu').hide('10');
316    }
317    wpestate_adjustMegaMenuPosition();
318    wpestate_half_map_responsive();
319    wpestat_resize_wpestate_property_slider_v2();
320
321});
322
323function wpestate_half_map_responsive(){
324    if (Modernizr.mq('only screen and (min-width: 640px)') && Modernizr.mq('only screen and (max-width: 1025px)')) {
325        var half_map_header = jQuery('.master_header ').height();
326    }
327
328}
329
330function wpestate_half_map_controls(){
331
332    jQuery('.half_mobile_toggle_listings').on('click',function(){
333
334        jQuery('.half_map_controllers_wrapper div').removeClass('half_control_visible');
335        jQuery(this).addClass('half_control_visible');
336        jQuery('#google_map_prop_list_wrapper').removeAttr('style');
337        jQuery('#google_map_prop_list_sidebar').show();
338        jQuery('.half_mobile_hide').hide();
339        jQuery('#colophon').show();
340        wpestate_adjust_sticky_footer();
341    });
342
343
344     jQuery('.half_mobile_toggle_map').on('click',function(){
345
346        jQuery('.half_map_controllers_wrapper div').removeClass('half_control_visible');
347        jQuery(this).addClass('half_control_visible');
348        jQuery('#google_map_prop_list_sidebar').hide();
349        jQuery('#google_map_prop_list_wrapper').css('height','100%');
350        jQuery('#google_map_prop_list_wrapper').css('position','relative');
351        jQuery('#googleMap').css('min-height','100vh');
352
353        // Hide footer
354        jQuery('#colophon').hide();
355        jQuery('.wpresidence_main_wrapper_class').css('margin-bottom','0px');
356
357
358        jQuery('.half_mobile_hide').show();
359
360        wpresidence_map_general_fit_to_bounds(1);
361      if(wp_estate_kind_of_map===1){
362
363    }else if(wp_estate_kind_of_map===2){
364      map.invalidateSize();
365        map.fitBounds(bounds_list);
366    }
367    });
368}
369
370
371
372
373
374Number.prototype.format = function(n, x) {
375    var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\.' : '$') + ')';
376    return this.toFixed(Math.max(0, ~~n)).replace(new RegExp(re, 'g'), '$&'+control_vars.price_separator);
377};
378
379function wpestate_element_hide(item){
380    "use strict";
381    jQuery(document).on( 'click', function(event) {
382        if (!jQuery(item).is(event.target) && jQuery(item).has(event.target).length === 0 ){
383            jQuery('#results').fadeOut();
384
385        }
386    });
387}
388wpestate_element_hide('.search_wrapper');
389
390function wpestate_lazy_load_carousel_property_unit(){
391    "use strict";
392
393    jQuery('.property_unit_carousel img').each(function(event){
394          var new_source='';
395          new_source=jQuery(this).attr('data-lazy-load-src');
396          if(typeof (new_source)!=='undefined' && new_source!==''){
397
398            jQuery(this).attr('src',new_source);
399          }
400      });
401}
402 //recaptha
403
404
405function wpestate_card_unit_contact_actions(){
406
407
408    jQuery('.wpestate_property_card_contact_wrapper_phone').on('click',function(event){
409        event.stopPropagation(); 
410       
411        var prop_id = jQuery(this).attr('data-item-id');
412        var parent = jQuery(this).parent().parent();
413       
414        parent.find('.wpestate_card_unit_call_'+prop_id).appendTo("body");
415        jQuery('body> .wpestate_card_unit_call_'+prop_id).first().modal("show");
416    });
417
418    jQuery('.wpestate_property_card_contact_wrapper_email').on('click',function(event){
419        event.stopPropagation();  
420        var prop_id = jQuery(this).attr('data-item-id');
421        var parent = jQuery(this).parent().parent();
422        parent.find('.wpestate_card_unit_email_'+prop_id).appendTo("body");
423        jQuery('body> .wpestate_card_unit_email_'+prop_id).first().modal("show");
424    });
425
426    jQuery('.wpestate_property_card_contact_wrapper_whatsupp').on('click',function(event){
427        event.stopPropagation();
428      
429    });
430
431}
432
433
434
435
436
437
438wpestate_advnced_filters_bars();
439
440function wpresidence_advanced_searc_6_actions(){
441      ////////// adv serach 6
442    jQuery('.adv6_tab_head,.elementor_search_tab_head').on( 'click', function(event) {
443        
444   
445
446        var tab_controls;
447        var parent=jQuery(this).parent().parent();
448        parent.find('.adv_search_tab_item').removeClass('active');
449        jQuery(this).parent().addClass('active');
450        
451        
452        tab_controls = jQuery(this).attr('aria-controls');
453        jQuery('.adv6_price_low').removeClass('price_active');
454        jQuery('.adv6_price_max').removeClass('price_active');
455
456        jQuery('#'+tab_controls).find('.adv6_price_low').addClass('price_active');
457        jQuery('#'+tab_controls).find('.adv6_price_max').addClass('price_active');
458
459    });
460
461}
462
463
464
465/**
466 * Trigger Login Modal Open Action
467 * 
468 * This function sets up an event listener for the login trigger modal button.
469 * When clicked, it calls the function to open the login modal.
470 *
471 * @since 1.0.0
472 * 
473 * @requires jQuery
474 * @requires wpestate_trigger_login_modal_open
475 * 
476 * @return {void}
477 */
478function wpestate_trigger_login_modal_open_action() {
479    jQuery('#login_trigger_modal').on('click', function(event) {
480        wpestate_trigger_login_modal_open(2);
481    });
482}
483
484/**
485 * Open Login Modal
486 * 
487 * This function handles the opening of the login modal. It's used in various scenarios
488 * such as saving to favorites, saving a search, or adding a property when login is required.
489 * The function behaves differently based on the screen size (desktop vs mobile).
490 *
491 * @since 1.0.0
492 * 
493 * @requires jQuery
494 * @requires Modernizr
495 * 
496 * @return {void}
497 */
498function wpestate_trigger_login_modal_open(stayOnPage) {
499    // Check if the screen width is greater than 768px (non-mobile devices)
500    // stayOnPage is a flag that indicates if the page should be reloaded after login 1-yes, 0-no will reload page from theme option , 2 - no will reload current page
501    if(!wpestate_isMobileOrTablet()){
502        // Desktop behavior
503        var login_modal = jQuery('#modal_login_wrapper');
504        
505        // Show the login modal
506        login_modal.show();
507        // Set focus to the first focusable element in the modal
508        login_modal.find('[autofocus]').focus();
509        
510        // Set the loginpop value to 1 (indicating a popup login)
511        login_modal.find('.loginpop').val(stayOnPage);
512    } else {
513        // Mobile behavior
514        // Trigger the mobile user menu
515        jQuery('.mobile-trigger-user').trigger('click');
516        
517        // Set the loginpop value to 1 in the mobile wrapper
518        jQuery('.mobilewrapper-user .loginpop').val(stayOnPage);
519    }
520}
521
522
523function wpestate_bootstrap53_dropdown(){
524    jQuery('.wpresidence_dropdown .dropdown-menu li').on('click', function() {
525        // Get the selected value and label
526        var selectedValue = jQuery(this).data('value');
527        var selectedLabel = jQuery(this).text();
528
529        // Update the button text
530        jQuery(this).closest('.wpresidence_dropdown').find('.dropdown-toggle').text(selectedLabel);
531
532        // Update the hidden input value
533        jQuery(this).closest('.wpresidence_dropdown').find('input[type="hidden"]').val(selectedValue);
534
535        // Optionally close the dropdown after selection
536        jQuery(this).closest('.dropdown').removeClass('show');
537        jQuery(this).closest('.dropdown').find('.dropdown-menu').removeClass('show');
538    });
539}
540
541
542
543jQuery(document).ready(function () {
544    "use strict";
545
546    wpestate_bootstrap53_dropdown();
547    wpestate_initializeTooltips_bootstrap53();
548
549    // Calculate the initial threshold for advanced search sticky
550    calculateSearchbarThreshold();  
551    // Get the initial scroll position
552    var initialScroll = jQuery(window).scrollTop();
553    // Call the function to set the correct initial state for advanced search sticky
554    wpestate_adv_search_sticky(initialScroll);
555
556    // trigger login modal open 
557    wpestate_trigger_login_modal_open_action();
558
559
560   jQuery('#login_user_wd').focus({ preventScroll: true });
561
562    if(jQuery('.wpestate_anime').length>0 ){
563        jQuery('.wpestate_anime').each( function(){
564            var element_id = jQuery(this).attr('id');
565            wpestate_property_list_sh('#'+element_id+' .wpestate_item_list_sh', '#'+element_id+' .control_tax_sh');
566        });
567
568    }
569    wpestate_change_currency_dropdown_action();
570    wpestate_adjustMegaMenuPosition();
571    wpestate_reposion_dropdowns();
572    wpestate_beds_baths_component();
573    wpestate_price_component_item();
574    wpestate_price_component_item_v3();
575
576    wpestate_blog_list_widget();
577    wpestate_get_location();
578    wpestate_grid_list_controls();
579
580    wpestate_slider_box();
581    wpestate_enable_share_unit();
582    wpestate_control_media_buttons();
583    wpestate_card_unit_contact_actions();
584    wpestate_morgate_widget_action();
585    wpestate_zillow_widget_action();
586    wpestate_save_search_actions();
587    wpestate_delete_save_search_actions();
588    wpestate_overview_map();
589    wpestate_extended_search_function();
590    wpresidence_advanced_searc_6_actions();
591    wpestate_show_hide_search_form_hidden_fields();
592    wpestate_adjust_sticky_footer();
593    wpestate_map_types_control();
594    
595
596    ////////////////////////////////////////////////////////////////////////////////////////////
597    ///city-area-selection
598    ///////////////////////////////////////////////////////////////////////////////////////////
599
600    wpestate_filter_city_area('filter_city','filter_area');
601    wpestate_filter_city_area('sidebar-adv-search-city','sidebar-adv-search-area');
602    wpestate_filter_city_area('adv-search-city','adv-search-area');
603    wpestate_filter_city_area('half-adv-search-city','half-adv-search-area');
604    wpestate_filter_city_area('shortcode-adv-search-city','shortcode-adv-search-area');
605    wpestate_filter_city_area('mobile-adv-search-city','mobile-adv-search-area');
606    wpestate_filter_city_area('property_city_submit', 'property_area_submit');
607    wpestate_filter_city_area('a_filter_cities', 'a_filter_areas');
608    wpestate_filter_city_area('advanced_city', 'advanced_area');
609
610    ////////////////////////////////////////////////////////////////////////////////////////////
611    //county-city-selection
612    ///////////////////////////////////////////////////////////////////////////////////////////
613    wpestate_filter_county_city( 'filter_county', 'filter_city' );
614    wpestate_filter_county_city( 'sidebar-adv-search-countystate', 'sidebar-adv-search-city' );
615    wpestate_filter_county_city( 'adv-search-countystate', 'adv-search-city' );
616    wpestate_filter_county_city( 'half-adv-search-countystate', 'half-adv-search-city' );
617    wpestate_filter_county_city( 'shortcode-adv-search-countystate', 'shortcode-adv-search-city' );
618    wpestate_filter_county_city( 'mobile-adv-search-countystate', 'mobile-adv-search-city' );
619    wpestate_filter_county_city( 'a_filter_county', 'a_filter_cities' );
620    wpestate_filter_county_city( 'county-state', 'advanced_city' );
621 
622
623
624    if(jQuery('.googleMap_shortcode_class').length>0 ){
625        if(  jQuery(".single-estate_property").length==0 ){
626            wpestate_map_shortcode_function();
627        }else{
628            if(  jQuery("#googleMap").length==0 &&  jQuery("#googleMapSlider").length==0 ){
629            }
630        }
631    }
632
633
634    jQuery('body').on('click', '.add_custom_parameter', function(){
635        const cloned = `
636        <div class="cliche_row row">
637            <div class="col-md-5">
638                <label for="agent_custom_label">${control_vars.agent_field_name}</label>
639                <input type="text" class="form-control agent_custom_label" value="" name="agent_custom_label[]">
640            </div>
641            <div class="col-md-5">
642                <label for="agent_custom_value">${control_vars.agent_field_value}</label>
643                <input type="text" class="form-control agent_custom_value" value="" name="agent_custom_value[]">
644            </div>
645            <div class="col-md-2">
646                <button type="button" class="wpresidence_button remove_parameter_button">${control_vars.remove}</button>
647            </div>
648        </div>
649    `;
650    
651        jQuery('input', cloned).val('');
652        jQuery('.wpresidence_button.add_custom_parameter').before( cloned );
653    });
654
655
656
657
658    jQuery('body').on('click', '.remove_parameter_button', function(){
659        var pnt = jQuery(this).parents( '.cliche_row' );
660        pnt.fadeOut(500, function(){
661                pnt.replaceWith('');
662        });
663    });
664
665
666    jQuery('.buy_package_sh a').on( 'click', function(event) {
667        if (parseInt(ajaxcalls_vars.userid, 10) === 0 ) {
668            event.preventDefault();
669            jQuery('#modal_login_wrapper').show();
670             jQuery('#modal_login_wrapper').find('[autofocus]').focus();
671            jQuery('.loginpop').val('1');
672        }
673    });
674
675    if (typeof wpestate_enable_half_map_pin_action == 'function'){
676        wpestate_enable_half_map_pin_action();
677    }  
678
679   
680
681    var screen_width,screen_height,map_tab;
682
683    jQuery.datepicker.setDefaults( jQuery.datepicker.regional[control_vars.datepick_lang] );
684
685
686
687
688    estate_splash_slider();
689
690
691    var new_height;
692    if (jQuery(".full_screen_yes").length) {
693
694        if( jQuery('.header_transparent').length > 0){
695            new_height = jQuery( window ).height();
696        }else{
697            new_height = jQuery( window ).height() - jQuery('.master_header').height();
698        }
699
700        if( jQuery('.with_search_on_start').length>0 ){
701            new_height=new_height- jQuery('.search_wrapper.with_search_on_start ').height();
702        }
703
704        jQuery('.wpestate_header_image,.wpestate_header_video,.theme_slider_wrapper,.theme_slider_classic,.theme_slider_wrapper .item_type2 ').css('height',new_height);
705    }
706
707
708   
709
710
711
712    jQuery('.wp-block-residence-gutenberg-block-testimonial-slider').each(function(){
713
714       if( jQuery(this).find('.type_class_3 ').length>0 ){
715           jQuery(this).addClass('container_type_3');
716       }
717
718    })
719
720
721
722
723
724
725    jQuery('#preview_view_all').on( 'click', function(event) {
726
727        if( (mapfunctions_vars.adv_search_type==='6' || mapfunctions_vars.adv_search_type==='7' || mapfunctions_vars.adv_search_type==='8' || mapfunctions_vars.adv_search_type==='9' ) ){
728
729            jQuery('.search_wrapper .tab-pane.active .wpresidence_button').trigger('click');
730        }else{
731            jQuery('.search_wrapper .wpresidence_button').trigger('click');
732        }
733    });
734
735
736    jQuery('.theme_slider_2 .prop_new_details ').on( 'click', function(event) {
737
738        var new_link;
739        new_link =  jQuery(this).attr('data-href');
740        window.open (new_link,'_self',false);
741    });
742
743    jQuery('.theme_slider_classic').on( 'click', function(event) {
744
745       if (event.target == this)  {
746            var new_link;
747            new_link =  jQuery(this).attr('data-href');
748            window.open (new_link,'_self',false);
749        }
750    });
751
752    setTimeout(function() {   wpresidence_list_view_arrange(); }, 300);
753
754    ////////// map shortcode
755    map_tab=0;
756    jQuery('#propmaptrigger').on( 'click', function(event) {
757        if(map_tab===0){
758
759            wpestate_map_shortcode_function();
760            map_tab=1;
761
762        }
763    });
764
765
766    setTimeout(function(){
767        jQuery('.theme_slider_2 .theme_slider_2_contact_agent').fadeIn();
768    }, 700);
769
770
771	////////////////////////////
772	// taxonomy slick slider
773	////////////////////////////
774    wpestate_half_map_responsive();
775    wpestate_half_map_controls();
776
777    jQuery('.show_stats').on( 'click', function(event) {
778        event.preventDefault();
779        var parent,listing_id;
780        parent = jQuery(this).parent().parent().parent();
781        listing_id = jQuery(this).attr('data-listingid');
782        //jQuery('.statistics_wrapper').slideUp();
783
784        if( parent.find('.statistics_wrapper').hasClass('is_slide')  ){
785               parent.find('.statistics_wrapper').slideUp().removeClass('is_slide');
786        }else{
787            parent.find('.statistics_wrapper').slideDown().addClass('is_slide');
788            wpestate_load_stats(listing_id);
789        }
790
791
792
793
794    });
795
796     jQuery('.tabs_stats,#1462452319500-8587db8d-e959,#1462968563400-b8613baa-7092').on( 'click', function(event) {
797       var parent,listing_id;
798       listing_id = jQuery(this).attr('data-listingid');
799       if(typeof(listing_id)==='undefined'){
800           listing_id =  jQuery('.estate_property_first_row').attr('data-prp-listingid');
801       }
802
803
804       wpestate_load_stats_tabs(listing_id);
805    });
806
807
808
809    ////////////////////////////////////////////////////////////////////////////
810    //new retina script
811    ////////////////////////////////////////////////////////////////////////////
812
813        jQuery('.retina_ready').dense({
814            'ping'      : true,
815            'dimension' : 'preserve'
816        });
817        var image_unnit = jQuery('<div data-1x="'+control_vars.path+'/css/css-images/unit.png" data-2x="'+control_vars.path+'/css/css-images/unit_2x.png" />').dense('getImageAttribute');
818        var image_unnit = jQuery('<div data-1x="'+control_vars.path+'/css/css-images/unitshare.png" data-2x="'+control_vars.path+'/css/css-images/unitshare_2x.png" />').dense('getImageAttribute');
819
820    ////////////////////////////////////////////////////////////////////////////
821    //invoice filters
822    ////////////////////////////////////////////////////////////////////////////
823
824
825   jQuery(function() {
826        jQuery("#invoice_start_date,#invoice_end_date").datepicker({
827            dateFormat : "yy-mm-dd",
828        }).datepicker('widget').wrap('<div class="ll-skin-melon"/>');
829    });
830
831
832    ////////////////////////////////////////////////////////////////////////////
833    //new mobile menu 1.10
834    ////////////////////////////////////////////////////////////////////////////
835
836    jQuery('.all-elements').animate({
837            minHeight: 100+'%'
838    });
839
840    jQuery('.header-tip').addClass('hide-header-tip');
841
842    wpestate_mobile_menu_slideout();
843    wpestate_mobile_menu_open_submenu();
844    wpestate_elementor_mobile_menu_trigger_open();
845
846
847   
848
849
850   
851
852    ////////////////////////////////////////////////////////////////////////////
853    // easure unit cookige
854    ////////////////////////////////////////////////////////////////////////////
855
856    jQuery('.list_sidebar_measure_unit li').on( 'click', function(event) {
857        var ajaxurl,value, pick;
858        value = jQuery(this).attr('data-value');
859
860        var parent_pointer = jQuery(this).parents('.dropdown ');
861        pick = jQuery(this).text();
862        jQuery('.sidebar_filter_menu', parent_pointer).text(pick).append('<span class="caret caret_sidebar"></span>');
863        var nonce = jQuery('#wpestate_change_measure').val();
864        ajaxurl     =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
865        jQuery.ajax({
866            type: 'POST',
867            url: ajaxurl,
868            data: {
869                'action'    :   'wpestate_set_cookie_measure_unit',
870                'value'     :   value,
871                'security'  : nonce
872            },
873            success: function (data) {
874
875               location.reload();
876            },
877            error: function (errorThrown) {}
878        });//end ajax
879
880    });
881
882
883
884
885
886
887
888
889
890
891    ////////////////////////////////////////////////////////////////////////////
892    /// slider price
893    ////////////////////////////////////////////////////////////////////////////
894
895    var price_low_val= parseInt( jQuery('#price_low').val() );
896    var price_max_val= parseInt( jQuery('#price_max').val() );
897    var my_custom_curr_symbol  =   decodeURI ( wpestate_getCookie('my_custom_curr_symbol') );
898    var my_custom_curr_coef    =   parseFloat( wpestate_getCookie('my_custom_curr_coef'));
899    var my_custom_curr_pos     =   parseFloat( wpestate_getCookie('my_custom_curr_pos'));
900    var my_custom_curr_cur_post=   wpestate_getCookie('my_custom_curr_cur_post');
901
902
903    wpestate_enable_slider('slider_price', 'price_low', 'price_max', 'amount', my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef);
904    jQuery( "#slider_price" ).slider({
905        stop: function( event, ui ) {
906            if (typeof (wpestate_show_pins) !== "undefined") {
907                first_time_wpestate_show_inpage_ajax_half=1;
908
909                wpestate_show_pins();
910            }
911        }
912    });
913    wpestate_enable_slider('slider_price_sh', 'price_low_sh', 'price_max_sh', 'amount_sh', my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef);
914    wpestate_enable_slider('slider_price_widget', 'price_low_widget', 'price_max_widget', 'amount_wd', my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef);
915    wpestate_enable_slider('slider_price_mobile', 'price_low_mobile', 'price_max_mobile', 'amount_mobile', my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef);
916
917  
918    wpestate_enable_slider_elementor();
919
920    if(control_vars.adv6_taxonomy_term!==''){
921        control_vars.adv6_taxonomy_term.forEach(wpestate_advtabs_function);
922    }
923
924
925
926
927
928    ////////////////////////////////////////////////////////////////////////////
929
930
931
932
933
934    jQuery('#estate-carousel .slider-content h3 a,#estate-carousel .slider-content .read_more ').on( 'click', function(event) {
935      var new_link;
936      new_link =  jQuery(this).attr('href');
937      window.open (new_link,'_self',false);
938    });
939
940
941  
942
943
944
945    ////////////////////////////////////////////////////////////////////////////////////////////
946    ///mobile
947    ///////////////////////////////////////////////////////////////////////////////////////////
948
949
950    jQuery('#adv-search-header-mobile').on( 'click', function(event) {
951        jQuery('#adv-search-mobile').fadeToggle('300');
952
953    });
954
955
956    ////////////////////////////////////////////////////////////////////////////////////////////
957    ///navigational links
958    ///////////////////////////////////////////////////////////////////////////////////////////
959
960    jQuery('.nav-prev,.nav-next ').on( 'click', function(event) {
961        event.preventDefault();
962        var link = jQuery(this).find('a').attr('href');
963        window.open (link,'_self',false);
964    });
965
966    ////////////////////////////////////////////////////////////////////////////////////////////
967    /// featured agent
968    ///////////////////////////////////////////////////////////////////////////////////////////
969
970
971    jQuery('.featured_agent_details_wrapper, .agent-listing-img-wrapper').on( 'click', function(event) {
972        var newl= jQuery( this ).attr('data-link');
973        window.open (newl,'_self',false);
974    });
975
976    jQuery('.see_my_list_featured').on( 'click', function(event) {
977            event.stopPropagation();
978    });
979
980    ////////////////////////////////////////////////////////////////////////////////////////////
981    /// featuerd property
982    ///////////////////////////////////////////////////////////////////////////////////////////
983
984    jQuery('.featured_cover').on( 'click', function(event) {
985        var newl= jQuery( this ).attr('data-link');
986        window.open (newl,'_self',false);
987    });
988
989
990    jQuery( '.agent_face' )
991        .on('mouseenter', function(){   jQuery(this).find('.agent_face_details').fadeIn('500'); })
992        .on('mouseleave', function(){  jQuery(this).find('.agent_face_details').fadeOut('500'); });
993
994
995    ////////////////////////////////////////////////////////////////////////////////////////////
996    /// listings unit navigation
997    ///////////////////////////////////////////////////////////////////////////////////////////
998    jQuery('.places_cover,.agent_unit, .blog_unit , .featured_widget_image,.blog3v .property_listing_blog,.featured_img_type2').on( 'click', function(event) {
999        var link;
1000        link = jQuery(this).attr('data-link');
1001
1002        window.open(link, '_self');
1003    });
1004
1005
1006
1007    jQuery('.property_listing').on( 'click', function(event) {
1008       
1009        if (
1010            event.target.classList.contains('demo-icon') || 
1011            event.target.classList.contains('carousel-control-next-icon') || 
1012            event.target.classList.contains('carousel-control-prev-icon')   
1013        ){
1014        
1015            return;
1016        }
1017  
1018        if(control_vars.property_modal === '1' && !Modernizr.mq('only all and (max-width: 1024px)') ){
1019            event.preventDefault();
1020            event.stopPropagation();
1021            scroll_modal_save=scroll_modal;
1022
1023            var listing_id  =   jQuery(this).parent().attr('data-listid');
1024            var main_img_url=   jQuery(this).parent().attr('data-main-modal');
1025            var main_title  =   jQuery(this).parent().attr('data-modal-title');
1026            var link        =   jQuery(this).parent().attr('data-modal-link');
1027            wpestate_enable_property_modal(listing_id,main_img_url,main_title,link);
1028        }else{
1029
1030            if(control_vars.new_page_link==='_blank' && !jQuery(this).hasClass('places_listing')){
1031                return;
1032            }
1033            var link;
1034            link = jQuery(this).attr('data-link');
1035
1036          window.open(link, '_self');
1037        }
1038    });
1039
1040
1041
1042
1043
1044
1045    jQuery('.share_unit').on( 'click', function(event) {
1046        event.stopPropagation();
1047    });
1048
1049    jQuery('.related_blog_unit_image').on( 'click', function(event) {
1050         var link;
1051        link = jQuery(this).attr('data-related-link');
1052        window.open(link, '_self');
1053    });
1054
1055    ////////////////////////////////////////////////////////////////////////////////////////////
1056    /// user menu
1057    ///////////////////////////////////////////////////////////////////////////////////////////
1058
1059    wpestate_open_menu();
1060
1061    jQuery('#wpresidence_elementor_register').on( 'click', function(event) {
1062
1063        event.preventDefault();
1064        jQuery('.login-links').show();
1065  
1066        jQuery('#modal_login_wrapper').show();      
1067        event.preventDefault();
1068        jQuery('#login-div_topbar,#widget_register_topbar,#login-div-title-topbar,#forgot-div-title-topbar,#forgot-pass-div').hide();
1069        jQuery('#register-div-topbar,#register-div-title-topbar,#widget_login_topbar,#forgot_pass_topbar').show().find('[autofocus]').focus();
1070
1071        jQuery('#modal_login_wrapper').find('[autofocus]').focus();
1072    });
1073
1074    jQuery('#wpresidence_elementor_login').on( 'click', function(event) {
1075
1076        event.preventDefault();
1077        jQuery('.login-links').show();
1078        jQuery('#modal_login_wrapper').show();
1079        jQuery('#login-div_topbar,#widget_register_topbar,#login-div-title-topbar,#forgot_pass_topbar').show().find('[autofocus]').focus();
1080        jQuery('#register-div-topbar,#register-div-title-topbar,#widget_login_topbar,#forgot-div-title-topbar,#forgot-pass-div').hide();
1081  
1082
1083        jQuery('#modal_login_wrapper').find('[autofocus]').focus();
1084    });
1085
1086
1087   
1088
1089    jQuery('#user_menu_u.user_not_loged .submit_action').on( 'click', function(event) {
1090        jQuery('.login-links').show();
1091        jQuery('#modal_login_wrapper').show();
1092        jQuery('#modal_login_wrapper').find('[autofocus]').focus();
1093    });
1094
1095   
1096
1097    jQuery('#property_details_modal_close').on('click',function(event){
1098        jQuery('.website-wrapper').removeAttr('style');
1099        window.scrollTo(0, parseInt(scroll_modal_save) );
1100        jQuery('#property_details_modal_wrapper').hide();
1101        window.history.pushState("", modal_title,modal_url);
1102    });
1103
1104    jQuery('#shopping-cart').on('click',function (event) {
1105
1106        jQuery('#user_menu_open').removeClass('iosfixed').fadeOut(400);
1107        if (jQuery('#wpestate_header_shoping_cart').is(":visible")) {
1108            jQuery('#wpestate_header_shoping_cart').fadeOut(400);
1109        } else {
1110            jQuery('#wpestate_header_shoping_cart').fadeIn(400);
1111        }
1112        event.stopPropagation();
1113    });
1114
1115
1116    jQuery(document).on( 'click', function(event) {
1117
1118        var clicka  =   event.target.id;
1119        var clicka2 =   jQuery(event.target).attr('share_unit');
1120        jQuery('#wpestate_header_shoping_cart').fadeOut(400);
1121        if ( !jQuery('#'+clicka).parents('.topmenux').length) {
1122            jQuery('#user_menu_open').removeClass('iosfixed').hide(400);
1123            jQuery('.navicon-button').removeClass('opensvg');
1124            jQuery('#user_menu_u .navicon-button').removeClass('open');
1125        }
1126
1127        jQuery('.share_unit').hide();
1128
1129
1130        if (event.target.id == "header_type3_wrapper" || jQuery(event.target).parents("#header_type3_wrapper").size()) {
1131
1132        } else {
1133            var css_right   = parseFloat( jQuery('.header_type3_menu_sidebar').css('right') );
1134            var css_left    = parseFloat( jQuery('.header_type3_menu_sidebar').css('left') );
1135            if(css_right===0 || css_left===0 ){
1136                jQuery('.header_type3_menu_sidebar.header_left.sidebaropen').css("right","-300px");
1137                jQuery('.header_type3_menu_sidebar.header_right.sidebaropen').css("left","-300px");
1138                jQuery('.container.main_wrapper.has_header_type3').css("padding","0p
1138x");
1139                jQuery('.elementor-section.elementor-top-section ').css("padding-right","0px");
1140                jQuery('.elementor-section.elementor-top-section ').css("padding-left","0px");
1141                jQuery('.master_header').removeAttr('style');
1142
1143            }
1144        }
1145    });
1146
1147
1148    jQuery('#header_type3_trigger').on( 'click', function(event) {
1149
1150        event.preventDefault();
1151        if ( !jQuery('.container').hasClass('is_boxed') ){
1152            if( jQuery('.header_type3_menu_sidebar').hasClass('header_left') ){
1153                jQuery(".header_type3_menu_sidebar").css("right","0px");
1154                jQuery(".container.main_wrapper ").css("padding-right","300px");
1155                jQuery('.elementor-section.elementor-top-section ').css("padding-right","300px");
1156                jQuery(".master_header").css("right","150px");
1157            }else{
1158                jQuery(".header_type3_menu_sidebar").css("left","0px");
1159                jQuery(".container.main_wrapper ").css("padding-left","300px");
1160                jQuery('.elementor-section.elementor-top-section ').css("padding-left","300px");
1161                jQuery(".master_header").css("left","150px");
1162            
1163            }
1164            jQuery(".header_type3_menu_sidebar").addClass("sidebaropen");
1165        }else{
1166             if( jQuery('.header_type3_menu_sidebar').hasClass('header_left') ){
1167                jQuery(".header_type3_menu_sidebar").css("right","0px");
1168
1169            }else{
1170                jQuery(".header_type3_menu_sidebar").css("left","0px");
1171
1172            }
1173            jQuery(".header_type3_menu_sidebar").addClass("sidebaropen");
1174        }
1175    });
1176
1177
1178    ////////////////////////////////////////////////////////////////////////////////////////////
1179    /// new controls for upload pictures
1180    ///////////////////////////////////////////////////////////////////////////////////////////
1181
1182    jQuery('#imagelist i.fa-trash-alt').on( 'click', function(event) {
1183          var curent='';
1184          jQuery(this).parent().remove();
1185
1186          jQuery('#imagelist .uploaded_images').each(function(){
1187             curent=curent+','+jQuery(this).attr('data-imageid');
1188          });
1189          jQuery('#attachid').val(curent);
1190
1191      });
1192
1193    jQuery('#imagelist img').dblclick(function(){
1194
1195        jQuery('#imagelist .uploaded_images .thumber').each(function(){
1196            jQuery(this).remove();
1197        });
1198
1199        jQuery(this).parent().append('<i class="fa thumber fa-star"></i>');
1200        jQuery('#attachthumb').val(   jQuery(this).parent().attr('data-imageid') );
1201    });
1202
1203
1204
1205
1206
1207    jQuery('#switch').on( 'click', function(event) {
1208        jQuery('.main_wrapper').toggleClass('wide');
1209    });
1210
1211
1212    jQuery('#accordion_prop_addr, #accordion_prop_details, #accordion_prop_features').on('shown.bs.collapse', function () {
1213        jQuery(this).find('h4').removeClass('carusel_closed');
1214    });
1215
1216    jQuery('#accordion_prop_addr, #accordion_prop_details, #accordion_prop_features').on('hidden.bs.collapse', function () {
1217        jQuery(this).find('h4').addClass('carusel_closed');
1218    });
1219
1220    ///////////////////////////////////////////////////////////////////////////////////////////
1221    //////// advanced search filters
1222    ////////////////////////////////////////////////////////////////////////////////////////////
1223
1224    var elems = ['.directory_sidebar','.search_wrapper' , 
1225        '#advanced_search_shortcode', '#advanced_search_shortcode_2', '.adv-search-mobile','.advanced_search_sidebar'];
1226
1227    jQuery.each( elems, function( i, elem ) {
1228
1229        jQuery(elem+' li').on( 'click', function(event) {
1230            event.preventDefault();
1231            var pick, value, parent,parent_replace;
1232            parent_replace='.filter_menu_trigger';
1233            if(elem === '.advanced_search_sidebar'  ){
1234                parent_replace='.sidebar_filter_menu';
1235            }
1236
1237            pick = jQuery(this).text();
1238            value = jQuery(this).attr('data-value');
1239
1240			// agents search patch
1241			//if( jQuery(this).parents('.advanced_search_sidebar').hasClass('ag_ag_dev_search_widget') ){
1242			if( jQuery(this).parent().hasClass('aag_picker') ){
1243				jQuery('.ag_ag_dev_search_selector').hide();
1244				jQuery('.selector_for_'+value).fadeIn();
1245			}
1246
1247
1248            parent = jQuery(this).parent().parent();
1249            if(elem === '.directory_sidebar' ){
1250                parent.find(parent_replace).text(pick).attr('data-value',value);
1251            }else{
1252                parent.find(parent_replace).text(pick).attr('data-value',value);
1253            }
1254            parent.find('input').val(value);
1255        });
1256    });
1257
1258
1259
1260
1261    jQuery('.search_wrapper li, .extended_search_check_wrapper input[type="checkbox"]').on( 'click', function(event) {
1262
1263        if(jQuery(this).hasClass('wpestate_prevent_ajax')){
1264            return;
1265        }
1266
1267        if (typeof (wpestate_show_pins) !== "undefined") {
1268            first_time_wpestate_show_inpage_ajax_half=1;
1269            wpestate_show_pins();
1270        }
1271    });
1272
1273
1274
1275
1276
1277    var typingTimer;                //timer identifier
1278    var doneTypingInterval = 1500;  //time in ms, 5 second for example
1279    var jQueryinput = jQuery('#adv_location,.search_wrapper input[type=text]');
1280
1281    jQueryinput.on('keyup', function (event) {
1282        if(jQuery(this).attr('id')=='geolocation_search' || jQuery(this).attr('id')=='geolocation_search2') {
1283            return;
1284        }
1285        if (event.keyCode === 13) { 
1286            first_time_wpestate_show_inpage_ajax_half=1;
1287            wpestate_show_pins();
1288        }
1289    });
1290
1291    //on keydown, clear the countdown
1292    jQueryinput.on('keydown', function () {
1293      clearTimeout(typingTimer);
1294    });
1295
1296
1297
1298    ///////////////////////////////////////////////////////////////////////////////////////////
1299    //////// advanced search filters
1300    ////////////////////////////////////////////////////////////////////////////////////////////
1301
1302    jQuery('#openmap').on( 'click', function(event) {
1303
1304        if( jQuery(this).find('i').hasClass('fa-angle-down') ){
1305            jQuery(this).empty().append('<i class="fas fa-angle-up"></i>'+control_vars.close_map);
1306
1307            if (control_vars.show_adv_search_map_close === 'no') {
1308                jQuery('.search_wrapper').addClass('adv1_close');
1309                wpestate_adv_search_click();
1310            }
1311
1312        }else{
1313            jQuery(this).empty().append('<i class="fas fa-angle-down"></i>'+control_vars.open_map);
1314
1315        }
1316        wpestate_new_open_close_map(2);
1317
1318    });
1319
1320
1321    ///////////////////////////////////////////////////////////////////////////////////////////
1322    //////// full screen map
1323    ////////////////////////////////////////////////////////////////////////////////////////////
1324    var wrap_h;
1325    var map_h;
1326
1327    jQuery('#gmap-full').on( 'click', function(event) {
1328
1329
1330        if(  jQuery('#gmap_wrapper').hasClass('fullmap') ){
1331            jQuery('#google_map_prop_list_wrapper').removeClass('fullhalf');
1332
1333            jQuery('#gmap_wrapper').removeClass('fullmap').css('height',wrap_h+'px');
1334            jQuery('#googleMap').removeClass('fullmap').css('height',map_h+'px');
1335            jQuery('.master_header ').removeClass('header_full_map');
1336            jQuery('#search_wrapper').removeClass('fullscreen_search');
1337            jQuery('#search_wrapper').removeClass('fullscreen_search_open');
1338            
1339                if(  !jQuery('#google_map_prop_list_wrapper').length ){
1340                    jQuery('.content_wrapper').show();
1341                }
1342            jQuery('body,html').animate({
1343                 scrollTop: 0
1344            }, "slow");
1345            jQuery('#openmap').show();
1346            jQuery(this).empty().append('<i class="fas fa-arrows-alt"></i>'+control_vars.fullscreen).removeClass('spanselected');
1347
1348            jQuery('#google_map_prop_list_wrapper').removeClass('fullscreen');
1349            jQuery('#google_map_prop_list_sidebar').removeClass('fullscreen');
1350
1351
1352        }else{
1353            jQuery('#gmap_wrapper,#googleMap').css('height','100%').addClass('fullmap');
1354
1355            jQuery('#google_map_prop_list_wrapper').addClass('fullscreen');
1356            jQuery('#google_map_prop_list_sidebar').addClass('fullscreen');
1357
1358
1359
1360
1361            jQuery('#google_map_prop_list_wrapper').addClass('fullhalf');
1362
1363
1364            wrap_h=jQuery('#gmap_wrapper').outerHeight();
1365            map_h=jQuery('#googleMap').outerHeight();
1366
1367            jQuery('.master_header ').addClass('header_full_map');
1368
1369
1370            jQuery('#search_wrapper').addClass('fullscreen_search');
1371         
1372            if(  !jQuery('#google_map_prop_list_wrapper').length ){
1373                jQuery('.content_wrapper').hide();
1374            }
1375
1376            jQuery('#openmap').hide();
1377            jQuery(this).empty().append('<i class="fas fa-square"></i>'+control_vars.default).addClass('spanselected');
1378
1379        }
1380        wpresidence_map_resise();
1381
1382
1383
1384    });
1385
1386
1387    jQuery('#street-view').on( 'click', function(event) {
1388         wpestate_toggleStreetView();
1389    });
1390
1391
1392
1393
1394
1395    ///////////////////////////////////////////////////////////////////////////////////////////
1396    ///////     caption-wrapper
1397    ///////////////////////////////////////////////////////////////////////////////////////////
1398
1399    jQuery('.caption-wrapper').on( 'click', function(event) {
1400        jQuery(this).toggleClass('closed');
1401        jQuery('.carusel-back').toggleClass('rowclosed');
1402        jQuery('.wpestate_horizontal_slider_wrapper  .carousel-indicators').toggleClass('rowclosed');
1403    });
1404
1405    jQuery('.carousel-round-indicators li').on( 'click', function(event) {
1406        jQuery('.carousel-round-indicators li').removeClass('active');
1407        jQuery(this).addClass('active');
1408    });
1409
1410    jQuery('.videoitem iframe').on( 'click', function(event) {
1411        jQuery('.estate_video_control').remove();
1412    });
1413    ///////////////////////////////////////////////////////////////////////////////////////
1414    ////// Advanced search
1415    /////////////////////////////////////////////////////////////////////////////////////////
1416
1417    wpestate_adv_search_click();
1418
1419
1420     jQuery('.custom_details_container .send_email_agent').on( 'click', function(event) {
1421         event.preventDefault();
1422
1423         jQuery('body,html').animate({
1424               scrollTop: ( jQuery("#show_contact").offset().top-100)
1425          }, "slow");
1426
1427     });
1428
1429    ///////////////////////////////////////////////////////////////////////////////////////////
1430    ///////   back to top
1431    ///////////////////////////////////////////////////////////////////////////////////////////
1432
1433
1434     jQuery('.backtop').on( 'click', function(event) {
1435         event.preventDefault();
1436
1437         jQuery('body,html').animate({
1438                scrollTop: 0
1439          }, "slow");
1440
1441     });
1442
1443    ///////////////////////////////////////////////////////////////////////////////////////////
1444    ///////    footer contact
1445    ///////////////////////////////////////////////////////////////////////////////////////////
1446
1447    jQuery('.contact-box ').on( 'click', function(event) {
1448        event.preventDefault();
1449        jQuery('.contactformwrapper').toggleClass('hidden');
1450        wpestate_contact_footer_starter();
1451    });
1452
1453
1454
1455
1456
1457    ///////////////////////////////////////////////////////////////////////////////////////////
1458    /////// Search widget
1459    ///////////////////////////////////////////////////////////////////////////////////////////
1460    jQuery('#searchform input').focus(function(){
1461      jQuery(this).val('');
1462    }).blur(function(){
1463
1464    });
1465
1466
1467
1468    ////////////////////////////////////////////////////////////////////////////////////////////
1469    /// adding total for featured listings
1470    ///////////////////////////////////////////////////////////////////////////////////////////
1471    jQuery('.extra_featured').on('change', function(){
1472       var parent= jQuery(this).parent().parent();
1473       var price_regular  = parseFloat( parent.find('.submit-price-no').text(),10 );
1474       var price_featured = parseFloat( parent.find('.submit-price-featured').text(),10 );
1475       var total= price_regular+price_featured;
1476
1477       if( jQuery(this).is(':checked') ){
1478            parent.find('.submit-price-total').text(total);
1479            parent.find('.stripe_form_featured').show();
1480            parent.find('.stripe_form_simple').hide();
1481       }else{
1482           //substract from total
1483            parent.find('.submit-price-total').text(price_regular);
1484            parent.find('.stripe_form_featured').hide();
1485            parent.find('.stripe_form_simple').show();
1486       }
1487    });
1488
1489
1490    
1491    /////////////////////////////////////////////////////////////////////////////////////////
1492    /////// grid to list view 
1493    ///////////////////////////////////////////////////////////////////////////////////////////
1494
1495
1496    jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function(){
1497       jQuery(this).parent().addClass('wrap_custom_image');
1498    });
1499
1500
1501
1502
1503
1504
1505    ///////////////////////////////////////////////////////////////////////////////////////////
1506    ///////   compare action
1507    ///////////////////////////////////////////////////////////////////////////////////////////
1508    var already_in=[];
1509    jQuery('#compare_close').on( 'click', function(event) {
1510        jQuery('.prop-compare').animate({
1511            right: "-240px"
1512        });
1513    });
1514
1515    jQuery('.compare-action').on( 'click', function(e) {
1516
1517        e.preventDefault();
1518        e.stopPropagation();
1519        jQuery('.prop-compare').animate({
1520                            right: "0px"
1521                        });
1522
1523        var post_id = jQuery(this).attr('data-pid');
1524         for(var i = 0; i < already_in.length; i++) {
1525            if(already_in[i] === post_id) {
1526                return;
1527            }
1528        }
1529
1530        already_in.push(post_id);
1531
1532
1533        var post_image = jQuery(this).attr('data-pimage');
1534
1535        var to_add = '<div class="items_compare" style="display:none;"><img src="' + post_image + '"  class="img-responsive"><input type="hidden" value="' + post_id + '" name="selected_id[]" /></div>';
1536        jQuery('div.items_compare:first-child').css('background', 'red');
1537        if (parseInt(jQuery('.items_compare').length,10) > 3) {
1538            jQuery('.items_compare:first').remove();
1539        }
1540        jQuery('#submit_compare').before(to_add);
1541
1542        jQuery('#submit_compare').on( 'click', function(event) {
1543            jQuery('#form_compare').trigger('submit');
1544        });
1545
1546        jQuery('.items_compare').fadeIn(500);
1547    });
1548
1549    jQuery('#submit_compare').on( 'click', function(event) {
1550        jQuery('#form_compare').trigger('submit');
1551    });
1552
1553
1554
1555     /////////////////////////////////////////////////////////////////////////////////////////
1556     ////// form upload
1557     /////////////////////////////////////////////////////////////////////////////////////////
1558
1559    jQuery('#form_submit_2,#form_submit_1 ').on( 'click', function(event) {
1560        var loading_modal;
1561        window.scrollTo(0, 0);
1562        loading_modal='<div class="modal fade" id="loadingmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body listing-submit"><span>'+control_vars.addprop+'</div></div></div></div></div>';
1563
1564        jQuery('body').append(loading_modal);
1565        jQuery('#loadingmodal').modal();
1566    });
1567
1568
1569    jQuery('#add-new-image').on( 'click', function(event) {
1570        jQuery('<p><label for="file">New Image:</label><input type="file" name="upload_attachment[]" id="file_featured"></p> ').appendTo('#files_area');
1571    });
1572
1573
1574
1575    jQuery('.delete_image').on( 'click', function(event) {
1576        var image_id=jQuery(this).attr('data-imageid');
1577
1578        var curent=jQuery('#images_todelete').val();
1579        if(curent===''){
1580              curent=image_id;
1581        }else{
1582              curent=curent+','+image_id;
1583        }
1584
1585        jQuery('#images_todelete').val(curent) ;
1586        jQuery(this).parent().remove();
1587   });
1588
1589     /////////////////////////////////////////////////////////////////////////////////////////
1590     ////// mouse over map tooltip
1591     /////////////////////////////////////////////////////////////////////////////////////////
1592
1593    jQuery('#googleMap').on('mousemove', function(e){
1594       jQuery('.tooltip').css({'top':e.pageY,'left':e.pageX, 'z-index':'1'});
1595    });
1596
1597    setTimeout(function(){  jQuery('.tooltip').fadeOut("fast");},10000);
1598});
1599
1600/////////////////////////////////////////////////////
1601////////////////// END ready
1602
1603
1604/**
1605 * Initializes Bootstrap tooltips for all elements with the 'data-bs-toggle="tooltip"' attribute.
1606 * This function selects all elements that should have tooltips and applies the Bootstrap tooltip
1607 * functionality to each of them. It should be called after the DOM is fully loaded to ensure all
1608 * elements are accessible.
1609 */
1610function wpestate_initializeTooltips_bootstrap53() {
1611    // Select all elements with the 'data-bs-toggle="tooltip"' attribute
1612    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
1613
1614    // Initialize a Bootstrap tooltip for each selected element
1615    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
1616      return new bootstrap.Tooltip(tooltipTriggerEl);
1617    });
1618}
1619
1620
1621
1622/*
1623* control google map types
1624*
1625*/
1626
1627function wpestate_map_types_control(){
1628    
1629
1630    jQuery('#map-view').on( 'click', function(event) {
1631        jQuery('.wpresidence_map_styles_wrapper').toggle();
1632    });
1633
1634    jQuery('.map-type').on( 'click', function(event) {
1635        var map_type;
1636        jQuery('.wpresidence_map_styles_wrapper').hide();
1637        map_type=jQuery(this).attr('id');
1638        wpestate_change_map_type(map_type);
1639
1640    });
1641
1642  
1643
1644}
1645
1646
1647/*
1648* adjust sticky footer
1649*
1650*/
1651
1652
1653
1654function wpestate_adjust_sticky_footer(){
1655    if(control_vars.sticky_footer==='yes'){
1656        var footer_height=jQuery('#colophon').height();
1657        jQuery('.wpresidence_main_wrapper_class:not(.has_header_type4)').css('margin-bottom', footer_height);
1658        jQuery('.wpresidence_wrapper_for_header_4_colum').css('padding-bottom',footer_height);
1659    }
1660
1661}
1662
1663
1664/*
1665*multiple currency set coookie
1666*
1667*/
1668
1669
1670function wpestate_change_currency_dropdown_action(){
1671   
1672    jQuery('.list_sidebar_currency li').on( 'click', function(event) {
1673
1674        var ajaxurl,data,pos,symbol,coef,curpos, pick;
1675
1676        data=jQuery(this).attr('data-value');
1677        pos=jQuery(this).attr('data-pos');
1678        symbol=jQuery(this).attr('data-symbol');
1679        coef=jQuery(this).attr('data-coef');
1680        curpos=jQuery(this).attr('data-curpos');
1681
1682		var parent_pointer = jQuery(this).parents('.dropdown ');
1683	
1684        ajaxurl     =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
1685        var nonce = jQuery('#wpestate_change_currency').val();
1686        jQuery.ajax({
1687            type: 'POST',
1688            url: ajaxurl,
1689            data: {
1690                'action'    :   'wpestate_set_cookie_multiple_curr',
1691                'curr'      :   data,
1692                'pos'       :   pos,
1693                'symbol'    :   symbol,
1694                'coef'      :   coef,
1695                'curpos'    :   curpos,
1696                'security'  :   nonce
1697            },
1698            success: function (data) {
1699
1700                location.reload();
1701            },
1702            error: function (errorThrown) {}
1703        });//end ajax
1704
1705    });
1706
1707}
1708
1709/*
1710*
1711*
1712*
1713*/
1714
1715
1716
1717
1718function wpestate_adjustMegaMenuPosition() {
1719    jQuery(".wpestate_mega_menu2_wrapper").each(function() {
1720      var $megaMenu = jQuery(this);
1721      var parentOffset = $megaMenu.closest("li").offset().left;
1722        var viewportWidth = jQuery(window).width();
1723      $megaMenu.css({
1724    
1725        left: -parentOffset + "px",
1726        width: viewportWidth + "px",
1727        "max-width": viewportWidth + "px",
1728      });
1729    });
1730}
1731
1732
1733/**
1734 * WpEstate Advanced Filters Multi-Select
1735 * Handles the chained filtering between County/State -> City -> Area dropdowns
1736 * Uses Bootstrap Select plugin for enhanced multi-select functionality
1737 * 
1738 * HTML Structure Expected:
1739 * - Multi-select dropdowns with class 'wpestatemultiselectselectpicker'
1740 * - Options with data-taxonomy (county / state, cities, areas)
1741 * - Options with data-parent-value matching parent selection values
1742 * 
1743 * @since 5.0.5
1744 */
1745/**
1746 * WpEstate Advanced Filters Multi-Select
1747 * Handles the chained filtering between County/State -> City -> Area dropdowns
1748 */
1749function wpestate_advnced_filters_bars() {
1750    function initializeSelectPicker(element) {
1751        element.selectpicker({
1752            styleBase: 'wpestate-multiselect-custom-style',
1753            size: 7
1754        }).on('changed.bs.select', function(e, clickedIndex, isSelected, previousValue) {
1755        
1756            
1757            var elememtParent = jQuery(this).closest('.tab-pane.active');
1758            if (elememtParent.length == 0) {
1759                elememtParent = jQuery(this).parents().eq(2);
1760            }
1761            
1762            var elementId = jQuery(this).attr('id');
1763            
1764            const county_relations = {
1765                'county-state': 'advanced_city',
1766                'sidebar-county-state': 'sidebar-advanced_city',
1767                'shortcode-county-state': 'shortcode-advanced_city',
1768                'mobile-county-state': 'mobile-advanced_city'
1769            };
1770            
1771            const city_relations = {
1772                'advanced_city': 'advanced_area',
1773                'sidebar-advanced_city': 'sidebar-advanced_area',
1774                'shortcode-advanced_city': 'shortcode-advanced_area',
1775                'mobile-advanced_city': 'mobile-advanced_area'
1776            };
1777            
1778            var selectedOption = jQuery(this).find('option').eq(clickedIndex);
1779            var attributeTaxonomy = selectedOption.attr('data-taxonomy');
1780            var selectedOptions = jQuery(this).find('option:selected');
1781            
1782            if (attributeTaxonomy === 'cities' || attributeTaxonomy === 'county / state') {
1783                triggerChangeOn = county_relations[elementId];
1784                if (attributeTaxonomy === 'cities') {
1785                    triggerChangeOn = city_relations[elementId];
1786                }
1787                
1788                var selectedValues = jQuery(this).find('option:selected').map(function() {
1789                    return jQuery(this).val();
1790                }).get();
1791                
1792                var elementCousin = elememtParent.find('#' + triggerChangeOn);
1793                elementCousin.find('option').each(function() {
1794                    var optionValue = jQuery(this).data('parent-value');
1795                    if (selectedValues.length === 0 || selectedValues.indexOf(optionValue) !== -1) {
1796                        jQuery(this).show();
1797                    } else {
1798                        jQuery(this).hide();
1799                    }
1800                });
1801                
1802                // Destroy and reinitialize with all event handlers
1803                elementCousin.selectpicker('destroy');
1804                initializeSelectPicker(elementCousin);
1805            }
1806            
1807            first_time_wpestate_show_inpage_ajax_half = 1;
1808            wpestate_show_pins();
1809            
1810        }).on('shown.bs.select', function(e) {
1811            var thisButton = jQuery(this);
1812            
1813            var windowWidth = jQuery(window).width();
1814            var buttonOffset = thisButton.offset();
1815            var buttonWidth = thisButton.outerWidth();
1816            var $dropdownMenu = jQuery(this).parent().find('.dropdown-menu.open');
1817            
1818            var distanceFromLeft = buttonOffset.left;
1819            var distanceFromRight = windowWidth - (buttonOffset.left + buttonWidth);
1820            
1821            if (distanceFromLeft <= 150) {
1822                $dropdownMenu.css('left', 0);
1823                $dropdownMenu.css('right', 'auto');
1824            } else if (distanceFromRight <= 150) {
1825                $dropdownMenu.css('left', 'auto');
1826                $dropdownMenu.css('right', 0);
1827            }
1828        });
1829    }
1830    
1831    // Initialize all selectpickers
1832    jQuery('.wpestatemultiselectselectpicker').each(function() {
1833        initializeSelectPicker(jQuery(this));
1834    });
1835}
1836
1837
1838
1839
1840/**
1841 * Function to show/hide hidden fields in the WP Estate search form.
1842 * This function handles both floating and non-floating search forms,
1843 * providing smooth animations for expanding and collapsing advanced search options.
1844 */
1845function wpestate_show_hide_search_form_hidden_fields(){
1846    // Variable to store the original top position of the search wrapper
1847    var handler_top;
1848
1849    // Attach click event handler to the advanced search toggle button
1850    jQuery('.adv_handler').on('click', function(event) {
1851        // Prevent the default action of the click event
1852        event.preventDefault();
1853
1854        // Select the hidden fields container
1855        var check_row = jQuery('.adv_search_hidden_fields');
1856
1857        // Check if the search form is floating
1858        if (jQuery('#search_wrapper').hasClass('with_search_form_float')) {
1859            // Handle floating search form
1860            if (!jQuery('#search_wrapper').hasClass('openmore')) {
1861                // If the form is not expanded, prepare to open it
1862
1863                // Temporarily set display to flex and hide to measure accurate height
1864                // This is necessary because flex display can affect the element's dimensions
1865                check_row.css({'display': 'flex', 'visibility': 'hidden'});
1866                var height = check_row.outerHeight();
1867                // Reset to original state before animation
1868                check_row.css({'visibility': '', 'display': 'none'});
1869               
1870                // Get the current top position of the search wrapper
1871                handler_top = parseInt(jQuery('#search_wrapper').css('top'));
1872                // Calculate the new top position
1873                
1874                
1875               
1876                // Slide down hidden fields and set to flex display after animation
1877                // This ensures smooth animation while achieving the desired flex layout
1878                check_row.slideDown({
1879                    duration: 200,
1880                    queue: false,
1881                    complete: function() {
1882                        jQuery(this).css('display', 'flex');
1883                    }
1884                });
1885               
1886                // Mark the search wrapper as expanded
1887                jQuery('#search_wrapper').addClass('openmore');
1888            } else {
1889                // If the form is already expanded, close it
1890
1891                // Animate the search wrapper back to its original position
1892                jQuery('#search_wrapper').animate({
1893                    'top': handler_top
1894                }, { duration: 200, queue: false });
1895               
1896                // Slide up the hidden fields
1897                check_row.slideUp({ duration: 200, queue: false });
1898                // Remove the expanded state class
1899                jQuery('#search_wrapper').removeClass('openmore');
1900            }
1901        } else {
1902            // Handle non-floating search form
1903            if (check_row.css('display') === 'none') {
1904                // If hidden fields are not visible, show them
1905                // Set display to flex, hide it, then slide down for smooth animation
1906                check_row.css('display', 'flex').hide().slideDown(200);
1907            } else {
1908                // If hidden fields are visible, hide them
1909                check_row.slideUp(200);
1910            }
1911        }
1912    });
1913}
1914
1915
1916
1917
1918/**
1919 * Function to control "more options" in search form
1920 * 
1921 * This function sets up event handlers for expanding and collapsing
1922 * additional search options in  real estate search form.
1923 * 
1924 * 
1925 */
1926function wpestate_extended_search_function(){
1927    // Event handler for expanding the search options
1928    jQuery('.residence_adv_extended_options_text').on('click', function(event) {
1929        var parent_wrapper = jQuery(this).parent();
1930        
1931        // Hide the "More options" text
1932        jQuery(this).hide();
1933        
1934        // Find and show the extended search options
1935        var check_row = parent_wrapper.find('.extended_search_check_wrapper');
1936        check_row.slideDown({ duration: 200, queue: false });
1937        
1938        // Show the close button
1939        parent_wrapper.find('.adv_extended_close_button').show();
1940    });
1941
1942    // Event handler for collapsing the search options
1943    jQuery('.adv_extended_close_button').on('click', function(event) {
1944        var parent_wrapper = jQuery(this).parent().parent();
1945        
1946        // Hide the close button
1947        jQuery(this).hide();
1948        
1949        // Show the "More options" text
1950        parent_wrapper.find('.residence_adv_extended_options_text').show();
1951        
1952        // Hide the extended search options
1953        parent_wrapper.find('.extended_search_check_wrapper').slideUp({ duration: 200, queue: false });
1954    });
1955}
1956
1957
1958
1959/*
1960 * wp_estate_baths_component_item
1961 *
1962 * This function sets up the behavior for a beds and baths selection component
1963 * in a real estate WordPress theme or plugin.
1964 */
1965function wpestate_beds_baths_component() {
1966   
1967    /**
1968     * Handles the click event on beds or baths items
1969     * @param {string} itemClass - The class of the clicked item
1970     * @param {string} inputClass - The class of the input to update
1971     */
1972    function handleItemClick(itemClass, inputClass) {
1973        var selected_item = jQuery(this);
1974        var parent = selected_item.parent();
1975        var component = selected_item.closest('.wpestate-beds-baths-popoup-component');
1976        // Remove selected class from all items and add it to the clicked item
1977        parent.find(itemClass).removeClass('wp_estate_component_item_selected');
1978        selected_item.addClass('wp_estate_component_item_selected');
1979        // Update the hidden input value
1980        var selected_value = selected_item.attr('data-value');
1981        jQuery(inputClass).val(selected_value);
1982        update_label(component);
1983    }
1984
1985    /**
1986     * Updates the label of the component with the selected beds and baths
1987     * @param {jQuery} component - The component to update
1988     */
1989    function update_label(component){
1990        var selected_beds = component.find('.wp_estate_beds_component_item.wp_estate_component_item_selected').length > 0 ? component.find('.wp_estate_beds_component_item.wp_estate_component_item_selected').attr('data-value') : '0';
1991        var selected_baths = component.find('.wp_estate_baths_component_item.wp_estate_component_item_selected').length > 0 ? component.find('.wp_estate_baths_component_item.wp_estate_component_item_selected').attr('data-value') : '0';
1992        var update_label=parseFloat(selected_beds)+'+ '+control_vars.bd+'/'+parseFloat(selected_baths)+'+ '+control_vars.ba;
1993        component.find('.dropdown-toggle').text(update_label);
1994    }
1995
1996    // Attach event handlers
1997    // Handler for bed selection
1998    jQuery('.wp_estate_beds_component_item').on('click', function(event) {
1999        event.stopPropagation();
2000        handleItemClick.call(this, '.wp_estate_beds_component_item', '.wpresidence-componentsbeds');
2001    });
2002
2003    // Handler for bath selection
2004    jQuery('.wp_estate_baths_component_item').on('click', function(event) {
2005        event.stopPropagation();
2006        handleItemClick.call(this, '.wp_estate_baths_component_item', '.wpresidence-componentsbaths');
2007    });
2008
2009    // Handler for resetting the selection
2010    jQuery('.wpestate-beds-baths-popoup-reset').on('click', function(event) {
2011        event.stopPropagation();
2012        var parent = jQuery(this).closest('.wpestate-beds-baths-popoup-wrapper');
2013        // Remove selected class from all items
2014        parent.find('.wp_estate_baths_component_item').removeClass('wp_estate_component_item_selected');
2015        parent.find('.wp_estate_beds_component_item').removeClass('wp_estate_component_item_selected');
2016        // Clear input values
2017        parent.find('.wpresidence-componentsbeds, .wpresidence-componentsbaths').val('');
2018        // Reset the label
2019        var component = jQuery(this).closest('.wpestate-beds-baths-popoup-component');
2020        var update_value=jQuery(this).attr('data-default-value')+'<span class="caret caret_filter "></span>';
2021        component.find('.dropdown-toggle').html(update_value);
2022    });
2023
2024    // Handler for completing the selection
2025    jQuery('.wpestate-beds-baths-popoup-done').on('click', function() {
2026        first_time_wpestate_show_inpage_ajax_half=1;
2027        wpestate_show_pins();
2028    });
2029 
2030}
2031
2032
2033/*
2034 * wp_estate_price_component_item
2035 *
2036 * This function sets up the behavior for a price range selection component
2037 * in a real estate WordPress theme or plugin.
2038 */
2039function wpestate_price_component_item(){
2040
2041    // Prevent click event propagation on the price popup wrapper
2042    jQuery('.wpestate-price-popoup-wrapper').on('click', function(event) {
2043        event.stopPropagation();
2044    });
2045
2046    // Clear input value on focus for price range inputs
2047    jQuery('.component_adv_search_elementor_price_low,.component_adv_search_elementor_price_max').on('focus',function(){
2048        jQuery(this).val('');
2049    })
2050
2051    // Ensure only numeric input for price range fields
2052    jQuery('.component_adv_search_elementor_price_low,.component_adv_search_elementor_price_max').on('input', function() {
2053        // Replace non-digit characters with an empty string
2054        jQuery(this).val(jQuery(this).val().replace(/\D/g, ''));
2055    });
2056
2057    // Update slider when price input changes
2058    jQuery('.component_adv_search_elementor_price_low,.component_adv_search_elementor_price_max').on('change',function(event) {
2059        var inputValue = jQuery(this).val();
2060        var parent = jQuery(this).closest('.wpestate-price-popoup-wrapper');
2061        var numericValue = parseFloat(inputValue)
2062        var slider = parent.find('.ui-slider')
2063        
2064        // Update slider based on which input changed (low or max)
2065        if( jQuery(this).hasClass('component_adv_search_elementor_price_low') ){      
2066            slider.slider('values', 0, numericValue);
2067            slider.slider("option", "slide").call(slider, null, { values: [numericValue, slider.slider("values")[1]] });
2068        }else{
2069            slider.slider('values', 1, numericValue);
2070            slider.slider("option", "slide").call(slider, null, { values: [slider.slider("values")[0], numericValue] });
2071        }
2072    });
2073
2074    // Reset price component to default values
2075    jQuery('.wpestate-price-component-popoup-reset').on('click',function(event){
2076        event.stopPropagation();
2077        var parent = jQuery(this).closest('.wpestate-price-popoup-wrapper');
2078        var low_value_label = parent.find('.wpestate-price-popoup-field-low').attr('data-value');
2079        var max_value_label = parent.find('.wpestate-price-popoup-field-max').attr('data-value');
2080       
2081        // Reset values based on the type of price input present
2082        if(parent.find('.adv_search_elementor_price_low').length>0 ){
2083            var low_value = parent.find('.adv_search_elementor_price_low').attr('data-value');
2084            var max_value = parent.find('.adv_search_elementor_price_max').attr('data-value');
2085            parent.find('.adv_search_elementor_price_low').val(low_value);
2086            parent.find('.adv_search_elementor_price_max').val(max_value);
2087        }else{
2088            if( parent.find('.adv6_price_low').length > 0 ){
2089                var low_value = parent.find('.adv6_price_low').attr('data-value');
2090                var max_value = parent.find('.adv6_price_max').attr('data-value');
2091                parent.find('.adv6_price_low').val(low_value);
2092                parent.find('.adv6_price_max').val(max_value);
2093            }else{
2094                var low_value = parent.find('.single_price_low').attr('data-value');
2095                var max_value = parent.find('.single_price_max').attr('data-value');
2096                parent.find('.adv6_price_low').val(low_value);
2097                parent.find('.adv6_price_max').val(max_value);
2098            }
2099        }
2100
2101        // Reset dropdown button text
2102        var button_item = parent.parent().find('.dropdown-toggle');
2103        button_item.html( button_item.attr('data-default-value')+' <sp
2103an class="caret caret_filter "></span>' ) ;
2104        
2105        // Reset price range fields
2106        parent.find('.wpestate-price-popoup-field-low').val(low_value_label);
2107        parent.find('.wpestate-price-popoup-field-max').val(max_value_label);
2108   
2109        // Reset slider label and values
2110        var slider_label = parent.find('.wpresidence_slider_price').attr('data-default');
2111        parent.find('.wpresidence_slider_price').text(slider_label);
2112        var slider = parent.find('.ui-slider')
2113        slider.slider('values', 0, parseFloat(low_value)); // sets first handle (e.g., min value)
2114        slider.slider('values', 1, parseFloat(max_value));
2115    })
2116
2117    // Handle 'Done' button click
2118    jQuery('.wpestate-price-component-popoup-done').on('click',function(event){
2119        var parent_wrapper = jQuery('body');
2120        var fake_click_item = parent_wrapper.parent();
2121        fake_click_item.trigger('click');
2122        wpestate_show_pins();
2123    })
2124}
2125
2126
2127
2128/*
2129*
2130* format a price
2131*
2132*/
2133function wpestate_format_a_price(priceValue){
2134    thousandSeparator   = control_vars.price_separator;
2135    decimalPoints       = control_vars.decimal_poins;
2136    decimalSeparator    = control_vars.decimal_poins_separator;
2137
2138    if (!isNaN(priceValue)) {
2139        priceValue= parseFloat(priceValue);
2140        var formattedPrice = priceValue.toFixed(decimalPoints).replace(/\d(?=(\d{3})+\.)/g, '$&' + thousandSeparator);
2141        formattedPrice = formattedPrice.replace('.', decimalSeparator);
2142        var formattedPriceWithCurrency= wpestate_return_price_with_multi_currency(formattedPrice);
2143        return formattedPriceWithCurrency;
2144    }
2145
2146
2147}
2148
2149
2150/*
2151*
2152* add currency to a price
2153*
2154*/
2155
2156function wpestate_return_price_with_multi_currency(theValue){
2157    var return_string='';
2158    var my_custom_curr_symbol  =   decodeURI ( wpestate_getCookie('my_custom_curr_symbol') );
2159    var my_custom_curr_coef    =   parseFloat( wpestate_getCookie('my_custom_curr_coef'));
2160    var my_custom_curr_pos     =   parseFloat( wpestate_getCookie('my_custom_curr_pos'));
2161    var my_custom_curr_cur_post=   wpestate_getCookie('my_custom_curr_cur_post');
2162
2163   
2164
2165    if (!isNaN(my_custom_curr_pos) && my_custom_curr_pos !== -1) {
2166        if (my_custom_curr_cur_post === 'before') {
2167            return_string= wpestate_replace_plus( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + theValue;
2168        } else {
2169            return_string=theValue + " " +  wpestate_replace_plus( decodeURIComponent ( my_custom_curr_symbol ) ) ;
2170        }
2171    } else {
2172
2173        if (control_vars.where_curency === 'before') {      
2174            return_string= wpestate_replace_plus( decodeURIComponent ( control_vars.curency ) ) + " " + theValue;
2175        } else {     
2176            return_string=theValue + " " +  wpestate_replace_plus( decodeURIComponent ( control_vars.curency ) ) ;
2177        }
2178    }
2179
2180    return return_string;
2181
2182
2183
2184}
2185/*
2186*
2187* wp estate price component_item v3
2188*
2189*/
2190function wpestate_price_component_item_v3(){
2191    jQuery('.wpestate-price-popoup-wrapper_v3').on('click', function(event) {
2192
2193        event.stopPropagation();
2194        jQuery(this).find('.dropdown-menu').hide();  
2195    });
2196
2197      
2198    jQuery('.wpestate_child_dropdown_item').on("click", function(e) {
2199        jQuery(this).parent().find('.dropdown-menu').toggle();  
2200        e.stopPropagation();
2201    });
2202
2203   
2204    jQuery('.wpestate-price-component-popoup-reset_v3').on('click',function(event){
2205        event.stopPropagation();
2206        var parent = jQuery(this).closest('.wpestate-price-popoup-wrapper_v3');
2207    
2208        parent.find('.wpestate-price-component-select').each(function() {
2209            jQuery(this).val(jQuery(this).find('option:first').val());
2210        });
2211
2212        var component = parent.closest('.wpestate-beds-baths-popoup-component');
2213        var update_value=jQuery(this).attr('data-default-value')+'<span class="caret caret_filter"></span>';
2214
2215        var item_update_value = jQuery(this).attr('data-default-value2')+'<span class="caret caret_filter"></span>';
2216        component.find('.dropdown-toggle').html(update_value);
2217        component.find('.wpestate_child_dropdown_item').html(item_update_value);
2218        component.find('.wpresidence-component3_input_class').val('');
2219        component.find('.price_label_component').val('');
2220
2221    })
2222
2223    jQuery('.wpestate-price-component-popoup-done_v3').on('click',function(event){
2224        var parent_wrapper = jQuery('body');
2225        var fake_click_item= parent_wrapper.parent();
2226        fake_click_item.trigger('click');
2227        first_time_wpestate_show_inpage_ajax_half=1;
2228        wpestate_show_pins();
2229    })
2230 
2231 
2232    jQuery('.wpestate-price-popoup-wrapper_v3 li').on("click", function(e){      
2233        
2234        var parent = jQuery(this).closest('.wpestate-price-popoup-wrapper_v3');
2235        var component = parent.closest('.wpestate-beds-baths-popoup-component');
2236        var parent_ul = jQuery(this).parent();
2237        var selected_value = jQuery(this).attr('data-value');
2238
2239        if(parent_ul.hasClass('wpresidence-component3-min-price_class')){
2240            var selectedmin =selected_value;
2241            var selectedmax = parent.find('.wpresidence-component3-max-price_input_class').val();
2242        }else{
2243            var selectedmin = parent.find('.wpresidence-component3-min-price_input_class').val();
2244            var selectedmax = selected_value
2245        }
2246
2247
2248        var update_value=wpestate_return_price_with_multi_currency(selectedmin)+" - "+wpestate_return_price_with_multi_currency(selectedmax);
2249        component.find('.wpestate-beds-baths-popoup-component-toggle').html(update_value);
2250        component.find('.price_label_component').val(update_value);        
2251        parent_ul.hide();
2252    });
2253
2254}
2255
2256
2257
2258
2259/*
2260*
2261*wpestate-price-popoup-wrapper_v3
2262*/
2263function wpestate_reposion_dropdowns(){
2264    jQuery('.wpestate-multiselect-custom-style').on('click', function() {
2265       
2266    var $popupWrapper = jQuery(this);
2267    var $searchWrapper = $popupWrapper.closest('.search_wrapper'); // Get the closest parent with the class '.search_wrapper'
2268
2269    if($searchWrapper.length===0){
2270        return;
2271    }
2272
2273    var $dropdownMenu = jQuery(this).next('.wpestate-price-popoup-wrapper_v3');
2274
2275    if($dropdownMenu.length==0){
2276        var $dropdownMenu = jQuery(this).next('.wpestate-beds-baths-popoup-wrapper');
2277    }
2278    if($dropdownMenu.length==0){
2279        var $dropdownMenu = jQuery(this).next('.wpestate-price-popoup-wrapper');
2280    }
2281
2282    var popupOffset = $popupWrapper.offset();
2283    var searchOffset = $searchWrapper.offset();
2284
2285    // Calculate the distances
2286    var distanceToLeft = popupOffset.left - searchOffset.left;
2287    var distanceToRight = (searchOffset.left + $searchWrapper.outerWidth()) - (popupOffset.left + $popupWrapper.outerWidth());
2288
2289    if (distanceToLeft <= 150) {
2290        // Close to the left edge
2291        $dropdownMenu.css('left', 0);
2292        $dropdownMenu.css('right', 'auto');
2293
2294    } else if (distanceToRight <= 150) {
2295        // Close to the right edge
2296        $dropdownMenu.css('left', 'auto');
2297        $dropdownMenu.css('right', 0);
2298
2299    } 
2300
2301        
2302        
2303
2304    });
2305}
2306
2307
2308/**
2309* Initializes Slick Slider for Estate Place Cards
2310* @param {Object} jQuery - Requires jQuery
2311* @requires slick-carousel
2312* @description Sets up responsive sliders for real estate location/place displays with optional autoplay
2313* Data attributes required:
2314* - data-items-per-row: Number of slides to show
2315* - data-auto: Autoplay speed in ms (0 to disable)
2316* Global required:
2317* - control_vars.is_rtl: RTL language setting ('1' or '0')
2318*/
2319
2320function wpestate_enable_slick_places() {
2321    jQuery('.estate_places_slider').not('.slick-initialized').each(function() {
2322        let items = jQuery(this).attr('data-items-per-row'),
2323            auto = parseInt(jQuery(this).attr('data-auto')),
2324            isRTL = control_vars.is_rtl === '1';
2325 
2326        const config = {
2327            infinite: true,
2328            slidesToShow: items,
2329            slidesToScroll: 1,
2330            dots: false,
2331            rtl: isRTL,
2332            responsive: [
2333                {
2334                    breakpoint: 1025,
2335                    settings: {
2336                        slidesToShow: 2,
2337                        slidesToScroll: 1
2338                    }
2339                },
2340                {
2341                    breakpoint: 525, 
2342                    settings: {
2343                        slidesToShow: 1,
2344                        slidesToScroll: 1
2345                    }
2346                }
2347            ]
2348        };
2349 
2350        if (auto) {
2351            config.autoplay = true;
2352            config.autoplaySpeed = auto;
2353        }
2354 
2355        jQuery(this).slick(config);
2356    });
2357 }
2358
2359
2360/*
2361*
2362*
2363*/
2364
2365function wpestate_enble_slick_slider_list(){
2366    jQuery('.shortcode_slider_list').each(function() {
2367        const $slider = jQuery(this);
2368        const items = $slider.attr('data-items-per-row');
2369        const auto = parseInt($slider.attr('data-auto'));
2370        const isRTL = control_vars.is_rtl === '1';
2371        
2372        const slickConfig = {
2373            infinite: true,
2374            slidesToShow: items,
2375            slidesToScroll: 1,
2376            dots: true,
2377            rtl: isRTL,
2378            autoplay: auto !== 0,
2379            autoplaySpeed: auto,
2380            responsive: [
2381                {
2382                    breakpoint: 1025,
2383                    settings: {
2384                        slidesToShow: 2,
2385                        slidesToScroll: 1
2386                    }
2387                },
2388                {
2389                    breakpoint: 550,
2390                    settings: {
2391                        slidesToShow: 1,
2392                        slidesToScroll: 1
2393                    }
2394                }
2395            ]
2396        };
2397        
2398        // Initialize slick with settings
2399        $slider.not('.slick-initialized').slick(slickConfig);
2400    });
2401}
2402
2403/**
2404 * Initialize and configure Slick slider for theme and property image sliders
2405 * Handles both RTL and LTR layouts with responsive design and mobile optimization
2406 * 
2407 * @param {number|string} items_received - Number of slides to show on desktop view (defaults to 3 if invalid)
2408 * 
2409 * Configuration:
2410 * - Supports auto-play and manual navigation modes
2411 * - Responsive breakpoints at 1025px (2 slides) and 576px (1 slide)
2412 * - RTL support with mobile positioning fixes
2413 * - Custom navigation arrows with Bootstrap carousel styling
2414 * - Adaptive height on mobile devices
2415 * 
2416 * HTML Requirements:
2417 * - Target elements: .theme_slider_2 or .property_multi_image_slider
2418 * - data-auto attribute for autoplay speed (0 for manual navigation)
2419 * 
2420 * Dependencies:
2421 * - jQuery
2422 * - Slick Slider
2423 * - control_vars.is_rtl global variable ('1' for RTL, '0' for LTR)
2424 * 
2425 * @return {void}
2426 */
2427function wpestate_enable_slick_theme_slider(items_received) {
2428    var items = 3;
2429    if (parseInt(items_received) !== '') {
2430        items = parseInt(items_received);
2431    }
2432
2433    jQuery('.theme_slider_2,.property_multi_image_slider').each(function() {
2434        var auto = parseInt(jQuery(this).attr('data-auto'));
2435        var isRTL = control_vars.is_rtl === '1';
2436        
2437        // Common settings for both auto and non-auto
2438        var commonSettings = {
2439            infinite: true,
2440            slidesToShow: items,
2441            slidesToScroll: 1,
2442            dots: auto === 0 ? false : true,
2443            rtl: isRTL,
2444            prevArrow: '<button class="carousel-control-prev wpresidence-carousel-control" type="button" data-bs-target="#wpresidence-blog-post-carousel-bootstrap" data-bs-slide="prev"><i class="demo-icon icon-left-open-big"></i><span class="visually-hidden">Previous</span></button>',
2445            nextArrow: '<button class="carousel-control-next wpresidence-carousel-control" type="button" data-bs-target="#wpresidence-blog-post-carousel-bootstrap" data-bs-slide="next"><i class="demo-icon icon-right-open-big"></i><span class="visually-hidden">Next</span></button>',
2446            responsive: [
2447                {
2448                    breakpoint: 1025,
2449                    settings: {
2450                        slidesToShow: 2,
2451                        slidesToScroll: 1
2452                    }
2453                },
2454                {
2455                    breakpoint: 576,
2456                    settings: {
2457                        slidesToShow: 1,
2458                        slidesToScroll: 1,
2459                        adaptiveHeight: true
2460                    }
2461                }
2462            ],
2463            init: function(slick) {
2464                if (isRTL) {
2465                    // Fix for initial RTL positioning
2466                    setTimeout(function() {
2467                        var $track = jQuery(slick.$slideTrack);
2468                        var width = $track.width();
2469                        var slideWidth = jQuery(window).width();
2470                        
2471                        if (window.innerWidth <= 576) {
2472                            $track.css({
2473                                'transform': 'translate3d(0, 0, 0)',
2474                                'width': 'auto'
2475                            });
2476                        }
2477                    }, 100);
2478                }
2479            }
2480        };
2481
2482        // Add auto-specific settings
2483        if (auto !== 0) {
2484            commonSettings.autoplay = true;
2485            commonSettings.autoplaySpeed = auto;
2486        }
2487
2488        // Initialize slick if not already initialized
2489        if (!jQuery(this).hasClass('slick-initialized')) {
2490            jQuery(this).slick(commonSettings);
2491        }
2492
2493        // Handle window resize
2494        jQuery(window).on('resize', function() {
2495            if (isRTL && window.innerWidth <= 576) {
2496                jQuery('.slick-track').css({
2497                    'transform': 'translate3d(0, 0, 0)',
2498                    'width': 'auto'
2499                });
2500            }
2501        });
2502    });
2503}
2504
2505
2506/*
2507*
2508*
2509*/
2510function wpestate_enable_slick_testimonial(){
2511    jQuery('.testimonial-slider-container').each(function(){
2512
2513
2514        var items   = parseInt( jQuery(this).attr('data-visible-items'));
2515        var auto    = parseInt( jQuery(this).attr('data-auto') );
2516
2517        if (auto === 0 ){
2518
2519            jQuery(this).not('.slick-initialized').slick({
2520                infinite: true,
2521                slidesToShow: items,
2522                slidesToScroll: 1,
2523                dots: true,
2524
2525                responsive: [
2526                    {
2527                        breakpoint:1025,
2528                        settings: {
2529                          slidesToShow: 1,
2530                          slidesToScroll: 1
2531                        }
2532                    },
2533                    {
2534                      breakpoint: 480,
2535                      settings: {
2536                        slidesToShow: 1,
2537                        slidesToScroll: 1
2538                      }
2539                    }
2540                ]
2541            });
2542            if(control_vars.is_rtl==='1'){
2543                  jQuery(this).slick('slickSetOption','rtl',true,true);
2544            }
2545        }else{
2546
2547            jQuery(this).not('.slick-initialized').slick({
2548                infinite: true,
2549                slidesToShow: items,
2550                slidesToScroll: 1,
2551                dots: true,
2552                autoplay: true,
2553                autoplaySpeed: auto,
2554
2555                 responsive: [
2556                    {
2557                     breakpoint:1025,
2558                     settings: {
2559                       slidesToShow: 1,
2560                       slidesToScroll: 1
2561                     }
2562                   },
2563                    {
2564                      breakpoint: 480,
2565                      settings: {
2566                        slidesToShow: 1,
2567                        slidesToScroll: 1
2568                      }
2569                    }
2570                ]
2571            });
2572            if(control_vars.is_rtl==='1'){
2573                jQuery(this).slick('slickSetOption','rtl',true,true);
2574            }
2575        }
2576    });
2577}
2578
2579/*
2580*
2581*
2582*/
2583function wpestate_grid_list_controls(){
2584
2585    jQuery('#list_view').unbind('click');
2586    jQuery('#list_view').on( 'click', function(event) {
2587        jQuery(this).toggleClass('icon_selected');
2588        jQuery('#listing_ajax_container').addClass('ajax12');
2589        jQuery('#grid_view').toggleClass('icon_selected');
2590
2591
2592        jQuery('#listing_ajax_container .listing_wrapper,.wpestate_filter_list_properties_wrapper .listing_wrapper').hide().removeClass('col-md-4').removeClass('col-md-6').removeClass('col-md-3').addClass('col-md-12 col-lg-12').fadeIn(400) ;
2593
2594        jQuery('.the_grid_view').fadeOut(10,function() {
2595            jQuery('.the_list_view:not(.half_map_list_view)').fadeIn(300);
2596        });
2597
2598        // custom unit code
2599        jQuery('#listing_ajax_container .col-md-12.listing_wrapper .property_unit_custom_element.image').each(function(){
2600            jQuery(this).parent().addClass('wrap_custom_image');
2601        });
2602
2603        jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function(){
2604            jQuery(this).parent().addClass('wrap_custom_image');
2605        });
2606
2607        wpresidence_list_view_arrange();
2608     });
2609
2610
2611
2612    jQuery('#grid_view').unbind('click');
2613    jQuery('#grid_view').on( 'click', function(event) {
2614        var class_type;
2615
2616        class_type = jQuery('#listing_ajax_container .listing_wrapper').first().attr('data-org');
2617        if( jQuery('.wpestate_filter_list_properties_wrapper').length >0 ){
2618            class_type = jQuery('.wpestate_filter_list_properties_wrapper .listing_wrapper').first().attr('data-org');
2619        }
2620
2621        jQuery(this).toggleClass('icon_selected');
2622        jQuery('#listing_ajax_container').removeClass('ajax12');
2623        jQuery('#list_view').toggleClass('icon_selected');
2624        jQuery('#listing_ajax_container .listing_wrapper,.wpestate_filter_list_properties_wrapper .listing_wrapper ').hide().removeClass('col-lg-12').removeClass('col-md-12').addClass('col-lg-'+class_type).fadeIn(400);
2625        jQuery('#listing_ajax_container .the_list_view,.wpestate_filter_list_properties_wrapper .the_list_view').fadeOut(10,function(){
2626             jQuery('.the_grid_view').fadeIn(300);
2627        });
2628
2629        jQuery('#listing_ajax_container .wrap_custom_image').each(function(){
2630            jQuery(this).removeClass('wrap_custom_image');
2631            jQuery('.property_listing_custom_design').css('padding-left','0px');
2632        });
2633
2634     });
2635
2636
2637
2638}
2639
2640
2641/*
2642*
2643*
2644*/
2645function  wpresidence_list_view_arrange(){
2646        var wrap_image = parseInt( jQuery('.wrap_custom_image').width());
2647
2648        if(wrap_image!=0){
2649           jQuery('.col-md-12>.property_listing_custom_design').css('padding-left',wrap_image);
2650        }
2651}
2652
2653
2654
2655/**
2656 * Handles the dynamic filtering between city and area dropdowns in property listings.
2657 * When a city is selected, it filters the available areas to show only those belonging
2658 * to the selected city. The function works with multiple instances of city-area filter
2659 * pairs on the same page.
2660 *
2661 * @param {string} selected_city - ID of the city dropdown button (without '#')
2662 * @param {string} selected_area - ID of the area dropdown button (without '#')
2663 *
2664 * HTML Structure Expected:
2665 * <button id="[selected_city]">
2666 * <ul class="dropdown-menu">
2667 *   <li data-value2="city-value" data-value="city-value">City Name</li>
2668 * </ul>
2669 * <button id="[selected_area]">
2670 * <ul class="dropdown-menu">
2671 *   <li data-parentcity="city-value" data-value="area-value">Area Name</li>
2672 * </ul>
2673 */
2674function wpestate_filter_city_area(selected_city, selected_area) {
2675    // Bind click event to city dropdown items
2676    jQuery('#' + selected_city).siblings('.dropdown-menu').find('li').on('click', function(event) {
2677        event.preventDefault();
2678        
2679        // Get the selected city value and convert to lowercase for comparison
2680        var value_city = String(jQuery(this).attr('data-value2')).toLowerCase();
2681        
2682        // Update city button text and data value
2683        var cityText = jQuery(this).text();
2684        var cityButton = jQuery('#' + selected_city);
2685        cityButton.text(cityText);
2686        cityButton.attr('data-value', value_city);
2687        
2688        // Filter area options based on selected city
2689        jQuery('#' + selected_area).siblings('.dropdown-menu').find('li').each(function() {
2690            var is_city = String(jQuery(this).attr('data-parentcity')).toLowerCase();
2691            is_city = is_city.replace(" ", "-");
2692            var area_value = String(jQuery(this).attr('data-value')).toLowerCase();
2693            
2694            // Show areas matching selected city or all areas if 'all' is selected
2695            if (is_city === value_city || value_city === 'all') {
2696                jQuery(this).show();
2697            } else {
2698                jQuery(this).hide();
2699            }
2700        });
2701        
2702        // Reset area dropdown to default state
2703        var areaButton = jQuery('#' + selected_area);
2704        areaButton.text(control_vars.areas);
2705        areaButton.attr('data-value', 'all');
2706    });
2707    
2708    // Bind click event to area dropdown items
2709    jQuery('#' + selected_area).siblings('.dropdown-menu').find('li').on('click', function(event) {
2710        event.preventDefault();
2711        
2712        // Update area button text and data value when area is selected
2713        var areaText = jQuery(this).text();
2714        var areaValue = jQuery(this).attr('data-value');
2715        var areaButton = jQuery('#' + selected_area);
2716        areaButton.text(areaText);
2717        areaButton.attr('data-value', areaValue);
2718    });
2719}
2720
2721
2722/**
2723 * Handles the dynamic filtering between county and city dropdowns in property listings.
2724 * When a county is selected, it filters the available cities to show only those belonging
2725 * to the selected county. The function works with multiple instances of county-city filter
2726 * pairs on the same page.
2727 *
2728 * @param {string} selected_county - ID of the county dropdown button (without '#')
2729 * @param {string} selected_city - ID of the city dropdown button (without '#')
2730 *
2731 * HTML Structure Expected:
2732 * <button id="[selected_county]">
2733 * <ul class="dropdown-menu">
2734 *   <li data-value2="county-value" data-value="county-value">County Name</li>
2735 * </ul>
2736 * <button id="[selected_city]">
2737 * <ul class="dropdown-menu">
2738 *   <li data-parentcounty="county-value" data-value="city-value">City Name</li>
2739 * </ul>
2740 */
2741function wpestate_filter_county_city(selected_county, selected_city) {
2742    // Bind click event to county dropdown items using correct sibling selector
2743    jQuery('#' + selected_county).siblings('.dropdown-menu').find('li').on('click', function(event) {
2744        event.preventDefault();
2745        
2746        // Get the selected county value and convert to lowercase for comparison
2747        var value_county = String(jQuery(this).attr('data-value2')).toLowerCase();
2748        
2749        // Update county button text and data value
2750        var countyText = jQuery(this).text();
2751        var countyButton = jQuery('#' + selected_county);
2752        countyButton.text(countyText);
2753        countyButton.attr('data-value', value_county);
2754        
2755        // Filter city options based on selected county
2756        jQuery('#' + selected_city).siblings('.dropdown-menu').find('li').each(function() {
2757            var is_county = String(jQuery(this).attr('data-parentcounty')).toLowerCase();
2758            is_county = is_county.replace(" ", "-");
2759            var city_value = String(jQuery(this).attr('data-value')).toLowerCase();
2760            
2761            // Show cities matching selected county or all cities if 'all' is selected
2762            if (is_county === value_county || value_county === 'all') {
2763                jQuery(this).show();
2764            } else {
2765                jQuery(this).hide();
2766            }
2767        });
2768        
2769        // Reset city dropdown to default state
2770        var cityButton = jQuery('#' + selected_city);
2771        cityButton.text(control_vars.cities);
2772        cityButton.attr('data-value', 'all');
2773    });
2774    
2775    // Bind click event to city dropdown items
2776    jQuery('#' + selected_city).siblings('.dropdown-menu').find('li').on('click', function(event) {
2777        event.preventDefault();
2778        
2779        // Update city button text and data value when city is selected
2780        var cityText = jQuery(this).text();
2781        var cityValue = jQuery(this).attr('data-value');
2782        var cityButton = jQuery('#' + selected_city);
2783        cityButton.text(cityText);
2784        cityButton.attr('data-value', cityValue);
2785    });
2786}
2787
2788
2789
2790
2791/*
2792*
2793*
2794*/
2795function wpestate_raisePower(x, y) {
2796    "use strict";
2797    return Math.pow(x, y);
2798}
2799
2800/*
2801*
2802*
2803*/
2804function wpestate_adv_search_click(){
2805    "use strict";    
2806   jQuery('.with_search_form_float .adv-search-header-1,.with_search_form_float #adv-search-header-3').on( 'click', function(event) {
2807        if ( jQuery('#search_wrapper').hasClass('float_search_closed') ){
2808            jQuery('#search_wrapper').removeClass('float_search_closed');
2809        }else{
2810            jQuery('#search_wrapper').addClass('float_search_closed');
2811        }
2812
2813   });
2814
2815}
2816
2817
2818/*
2819*Contact footer
2820*
2821*/
2822function wpestate_contact_footer_starter(){
2823    "use strict";
2824    jQuery('#btn-cont-submit').on( 'click', function(event) {
2825       
2826        var contact_name, contact_email, contact_phone, contact_coment, agent_email, property_id, nonce, ajaxurl;
2827        contact_name    =   jQuery('#foot_contact_name').val();
2828        contact_email   =   jQuery('#foot_contact_email').val();
2829        contact_phone   =   jQuery('#foot_contact_phone').val();
2830        contact_coment  =   jQuery('#foot_contact_content').val();
2831        nonce           =   jQuery('#agent_property_ajax_nonce').val();
2832        ajaxurl         =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
2833        var parent = jQuery(this).parent().parent();
2834
2835       
2836        if(ajaxcalls_vars.use_gdpr==='yes'){
2837            if (!parent.find('.wpestate_agree_gdpr').is(':checked')) {
2838                jQuery('#footer_alert-agent-contact').empty().append(ajaxcalls_vars.gdpr_terms);
2839                return;
2840            }
2841        }
2842     
2843        jQuery('#footer_alert-agent-contact').empty().append(ajaxcalls_vars.sending);
2844
2845
2846
2847        jQuery.ajax({
2848            type: 'POST',
2849            dataType: 'json',
2850            url: ajaxurl,
2851            data: {
2852                'action'    :   'wpestate_ajax_agent_contact_form',
2853                'name'      :   contact_name,
2854                'email'     :   contact_email,
2855                'phone'     :   contact_phone,
2856                'comment'   :   contact_coment,
2857                'is_footer' :   'yes',
2858                'nonce'     :   nonce
2859            },
2860            success: function (data) {
2861       
2862                if (data.sent) {
2863                    jQuery('#foot_contact_name').val('');
2864                    jQuery('#foot_contact_email').val('');
2865                    jQuery('#foot_contact_phone').val('');
2866                    jQuery('#foot_contact_content').val('');
2867                    jQuery('#footer_alert-agent-contact').empty().addClass('wpestate-agent-contact-sent').append(data.response);
2868                }else{
2869                    jQuery('#footer_alert-agent-contact').empty().removeClass('wpestate-agent-contact-sent').append(data.response);
2870                }
2871   
2872              
2873            },
2874            error: function (errorThrown) {
2875
2876            }
2877        });
2878
2879
2880        jQuery.ajax({
2881            type: 'POST',
2882            dataType: 'json',
2883            url: ajaxurl,
2884            data: {
2885                'action'    :   'wpestate_ajax_agent_contact_form_forcrm',
2886                'name'      :   contact_name,
2887                'email'     :   contact_email,
2888                'phone'     :   contact_phone,
2889                'comment'   :   contact_coment,
2890                'nonce'     :   nonce
2891            },
2892            success: function (data) {
2893
2894
2895            },
2896            error: function (errorThrown) {
2897
2898            }
2899        });
2900
2901
2902    });
2903}
2904
2905
2906/*
2907*
2908*
2909*/
2910function estate_splash_slider(){
2911    if(jQuery("#splash_slider_wrapper").length>0){
2912
2913    }
2914}
2915
2916
2917/*
2918*
2919*
2920*/
2921function wpestat_resize_wpestate_property_slider_v2(){
2922    if(control_vars.is_rtl==='1'){
2923    
2924    }
2925    var width   = 1090;
2926    var window  = jQuery( document ).width();
2927    
2928    var toadd=width+(window-width)/2;
2929
2930    if(toadd>1090){
2931        jQuery('.property_slider_carousel_elementor_v2').css('width',toadd+'px');
2932    }else{
2933        jQuery('.property_slider_carousel_elementor_v2').css('width','100%');
2934    }
2935}
2936
2937
2938/*
2939*
2940*
2941*/
2942function wpestate_hotspots_click(){
2943    jQuery('.wpestate_hotspot_icon_wrapper').on('click',function(){
2944        jQuery('.wpestate_hotspot_tooltip').hide();
2945        jQuery(this).parent().find('.wpestate_hotspot_tooltip').show();
2946    });
2947   
2948}
2949
2950
2951/*
2952*
2953*
2954*/
2955function wpestate_hotspots_hover(){
2956      jQuery(".wpestate_hotspot_icon_wrapper").on('mouseenter', function () {
2957        jQuery(this).parent().find('.wpestate_hotspot_tooltip').show();
2958    }).on('mouseleave', function () {
2959        jQuery(this).parent().find('.wpestate_hotspot_tooltip').hide();
2960    });
2961            
2962           
2963}
2964
2965/**
2966 * Initialize testimonial slider with RTL support
2967 * @param {string} slider_id - The ID of the slider element
2968 */
2969function wpestate_testimonial_slider(slider_id){
2970
2971    let rtl_value = false;
2972    if(control_vars.is_rtl==='1'){
2973        rtl_value=true;
2974    }
2975    jQuery('#'+slider_id).owlCarousel({
2976        loop:true,
2977        margin:0,
2978        nav:true,
2979        items:1,
2980        dots:true,
2981        mouseDrag:true,
2982        video:true,
2983        autoHeight: true,
2984        stagePadding:0,
2985        URLhashListener:false,
2986        rtl:rtl_value,
2987        navText: [
2988            // Swap arrows for RTL
2989            rtl_value ? 
2990                '<i class="fas fa-arrow-right"></i>' : 
2991                '<i class="fas fa-arrow-left"></i>',
2992            rtl_value ? 
2993                '<i class="fas fa-arrow-left"></i>' : 
2994                '<i class="fas fa-arrow-right"></i>'
2995        ],
2996    });
2997  
2998}
2999
3000/*
3001*
3002*
3003*/
3004function wpestate_property_slider_v2(slider_id, items) {
3005    wpestat_resize_wpestate_property_slider_v2();
3006    
3007    // Initialize RTL value checking both data attribute and control_vars
3008    let rtl_value = false;
3009    const $slider = jQuery('#' + slider_id);
3010    
3011    // Check both data-rtl and control_vars.is_rtl
3012    if ($slider.attr('data-rtl') === 'yes' || control_vars.is_rtl === '1') {
3013        rtl_value = true;
3014        $slider.addClass('owl-rtl');
3015    }
3016
3017    const is_loop = true;
3018
3019    $slider.owlCarousel({
3020        loop: is_loop,
3021        margin: 0,
3022        nav: true,
3023        items: 6,
3024        dots: false,
3025        mouseDrag: true,
3026        video: true,
3027        autoHeight: true,
3028        autoWidth: true,
3029        stagePadding: 0,
3030        URLhashListener: false,
3031        rtl: rtl_value,
3032        navText: [
3033            // Swap arrows for RTL
3034            rtl_value ? 
3035                '<i class="fas fa-arrow-right"></i>' : 
3036                '<i class="fas fa-arrow-left"></i>',
3037            rtl_value ? 
3038                '<i class="fas fa-arrow-left"></i>' : 
3039                '<i class="fas fa-arrow-right"></i>'
3040        ],
3041        onInitialized: function() {
3042            // Force RTL stage direction
3043            if (rtl_value) {
3044                const stage = $slider.find('.owl-stage');
3045                stage.css('transform-origin', 'center center');
3046                // Force correct direction on first load
3047                setTimeout(() => {
3048                    $slider.trigger('refresh.owl.carousel');
3049                }, 10);
3050            }
3051        }
3052    });
3053}
3054
3055 
3056/*
3057*
3058*
3059*/
3060function wpestate_property_slider_v3(slider_id, items) {
3061    // Initialize RTL value checking both data attribute and control_vars
3062    let rtl_value = false;
3063    const $slider = jQuery('#' + slider_id);
3064    
3065    // Check both data-rtl and control_vars.is_rtl
3066    if ($slider.attr('data-rtl') === 'yes' || control_vars.is_rtl === '1') {
3067        rtl_value = true;
3068        $slider.addClass('owl-rtl');
3069    }
3070
3071    $slider.owlCarousel({
3072        loop: true,
3073        margin: 0,
3074        nav: true,
3075        items: 1,
3076        dots: true,
3077        mouseDrag: true,
3078        video: true,
3079        autoHeight: true,
3080        stagePadding: 0,
3081        URLhashListener: false,
3082        rtl: rtl_value,
3083        navText: [
3084            // Swap arrows for RTL
3085            rtl_value ? 
3086                '<i class="fas fa-arrow-right"></i>' : 
3087                '<i class="fas fa-arrow-left"></i>',
3088            rtl_value ? 
3089                '<i class="fas fa-arrow-left"></i>' : 
3090                '<i class="fas fa-arrow-right"></i>'
3091        ],
3092        onInitialized: function() {
3093            if (rtl_value) {
3094                const stage = $slider.find('.owl-stage');
3095                stage.css('transform-origin', 'center center');
3096                // Force correct direction on first load
3097                setTimeout(() => {
3098                    $slider.trigger('refresh.owl.carousel');
3099                }, 10);
3100            }
3101        }
3102    });
3103}
3104
3105
3106jQuery(window).on('hashchange', function(event) {
3107        event.preventDefault();
3108        history.pushState("", document.title, window.location.pathname + window.location.search); // Clear the hash
3109});
3110
3111
3112    
3113/**
3114* Initialize and configure the WpResidence property slider carousel
3115* 
3116* This function sets up the Owl Carousel for property images with navigation controls,
3117* RTL support, and indicator synchronization. It handles both horizontal and vertical
3118* carousel layouts, updates active indicators, and manages indicator sliding.
3119* 
3120* Dependencies:
3121* - jQuery
3122* - Owl Carousel 2
3123* - control_vars.is_rtl global variable
3124* 
3125* @since 4.9.0
3126* @requires jQuery
3127* @requires owl.carousel.js
3128* 
3129* Event handlers:
3130* - Click on indicator slides to specific image
3131* - Carousel translation updates active indicators
3132* - Manages indicator positioning for overflow
3133* 
3134* Related functions:
3135* - wpestate_show_capture_vertical2()
3136* - wpestate_show_capture2()
3137* 
3138* Global variables used:
3139* - control_vars.is_rtl
3140* 
3141* @return {void}
3142*/
3143function wpestate_property_slider() {
3144    let is_rtl = false;
3145    if (control_vars.is_rtl === '1') {
3146        is_rtl = true;
3147    }
3148
3149    var owl_slider_property = jQuery("#property_slider_carousel").owlCarousel({
3150        loop: true,
3151        margin: 0,
3152        nav: true,
3153        items: 1,
3154        dots: false,
3155        mouseDrag: true,
3156        video: true,
3157        autoHeight: true,
3158        rtl: is_rtl,
3159        navText: [
3160            '<button class="carousel-control-prev wpresidence-carousel-control " type="button" data-slide="prev"><i class="demo-icon icon-left-open-big"></i><span class="visually-hidden">Previous</span></button>',
3161            '<button class="carousel-control-next wpresidence-carousel-control " type="button" data-slide="next"><i class="demo-icon icon-right-open-big"></i><span class="visually-hidden">Previous</span></button>'
3162        ],
3163        URLhashListener: false,
3164    });
3165
3166    var hash;
3167    var number;
3168
3169    jQuery('li[data-slide-to]').on('click', function(event) {
3170        event.preventDefault();
3171        var slideTo = parseInt(jQuery(this).data('slide-to'));
3172        owl_slider_property.trigger('to.owl.carousel', [slideTo, 300, true]);
3173    });
3174
3175    owl_slider_property.on('translated.owl.carousel', function(event) {
3176        number = jQuery(".carousel-inner .owl-item.active .item").attr('data-number');
3177        
3178        // Remove active class from all indicators
3179        jQuery('.carousel-round-indicators a').removeClass('active');
3180        jQuery('.carousel-indicators a').removeClass('active');
3181        jQuery('.carousel-indicators-classic li').removeClass('active');
3182        jQuery('.carousel-indicators-vertical li').removeClass('active');
3183        jQuery('.carousel-indicators li').removeClass('active');
3184
3185        // Add active class to current indicator
3186        const activeIndex = parseInt(number) - 1;
3187        
3188        if (jQuery(this).hasClass('carouselvertical')) {
3189            // Handle vertical indicators
3190            const $activeIndicator = jQuery('.carousel-indicators-vertical li[data-slide-to="' + activeIndex + '"]').addClass('active');
3191            const $container = jQuery('.carousel-indicators-vertical');
3192            
3193            if ($activeIndicator.length && $container.length) {
3194                const containerHeight = $container.height();
3195                const indicatorOffset = $activeIndicator.position()?.top || 0;
3196                const scrollAmount = Math.max(0, indicatorOffset - (containerHeight / 2) + 45);
3197                
3198                $container.css('transform', `translateY(-${scrollAmount}px)`);
3199            }
3200        } else {
3201            // Handle horizontal indicators
3202            let  $activeIndicator = jQuery('.carousel-indicators li[data-slide-to="' + activeIndex + '"]').addClass('active');
3203            let  $container = jQuery('.wpestate_property_carousel.carouselhorizontal .carousel-indicators');
3204
3205            if(jQuery('.wpestate_classic_slider_wrapper').length>0){
3206                 $activeIndicator = jQuery('.carousel-indicators li[data-slide-to="' + activeIndex + '"]').addClass('active');
3207                 $container = jQuery('.wpestate_classic_slider_wrapper .carousel-indicators');
3208            }
3209
3210
3211            if ($activeIndicator.length && $container.length) {
3212                const containerWidth = $container.width();   
3213                const indicatorOffset = $activeIndicator.position()?.left || 0; 
3214                const scrollAmount = Math.max(0, indicatorOffset - 100); // 100px buffer from left 
3215                $container.css('transform', `translateX(-${scrollAmount}px)`);
3216            }
3217        }
3218
3219        
3220    });
3221}
3222
3223
3224
3225
3226/*
3227*
3228*
3229*/
3230function wpestate_property_slider_2(){
3231    var autoplayvalue=false;
3232    var autoplayTimeoutvalue= parseInt( jQuery(".theme_slider_3").attr('data-auto'),10);
3233
3234    if(autoplayTimeoutvalue>0){
3235        autoplayvalue=true;
3236    }
3237    let is_rtl=false;
3238    if(control_vars.is_rtl==='1'){
3239         is_rtl=true;
3240    }
3241
3242   var owl = jQuery(".property_slider2_wrapper").owlCarousel({
3243        loop:true,
3244        margin:0,
3245        nav:true,
3246        items:1,
3247        dots:false,
3248        rtl:is_rtl,
3249        autoplay:autoplayvalue,
3250        autoplayTimeout:autoplayTimeoutvalue,
3251        navText : ["<div class='nextright'>
3251<i class='demo-icon icon-right-open-big'></i></div>","<div class='nextleft'><i class='demo-icon icon-left-open-big'></i></div>"],
3252        URLhashListener:true,
3253
3254    });
3255
3256    var hash;
3257    owl.on('translated.owl.carousel', function(event) {
3258
3259        hash = jQuery(".property_slider2_wrapper .owl-item.active .item").attr('data-hash');
3260
3261        jQuery('.property_slider2_wrapper-indicators a').removeClass('active');
3262        jQuery('a[href="#'+hash+'"]').addClass('active');
3263    });
3264
3265
3266}
3267
3268/*
3269*
3270*
3271*/
3272function wpestate_theme_slider_3(){
3273    var autoplayvalue=false;
3274    var autoplayTimeoutvalue= parseInt( jQuery(".theme_slider_3").attr('data-auto'),10);
3275
3276    if(autoplayTimeoutvalue>0){
3277        autoplayvalue=true;
3278    }
3279    let is_rtl=false;
3280    if(control_vars.is_rtl==='1'){
3281         is_rtl=true;
3282    }
3283
3284   var owl = jQuery(".theme_slider_3").owlCarousel({
3285        loop:true,
3286        margin:0,
3287        nav:true,
3288        items:1,
3289        dots:false,
3290        rtl:is_rtl,
3291        autoplay:autoplayvalue,
3292        autoplayTimeout:autoplayTimeoutvalue,
3293        navText : [
3294            '<svg xmlns="http://www.w3.org/2000/svg" width="32.414" height="20.828" viewBox="0 0 32.414 20.828"><g id="Group_30" data-name="Group 30" transform="translate(-1845.086 -1586.086)"><line id="Line_2" data-name="Line 2" x1="30" transform="translate(1846.5 1596.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line><line id="Line_3" data-name="Line 3" x1="9" y2="9" transform="translate(1846.5 1587.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line><line id="Line_4" data-name="Line 4" x1="9" y1="9" transform="translate(1846.5 1596.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line></g></svg>',
3295            '<svg xmlns="http://www.w3.org/2000/svg" width="32.414" height="20.828" viewBox="0 0 32.414 20.828"><g id="Symbol_1_1" data-name="Symbol 1 – 1" transform="translate(-1847.5 -1589.086)"><line id="Line_5" data-name="Line 2" x2="30" transform="translate(1848.5 1599.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line><line id="Line_6" data-name="Line 3" x2="9" y2="9" transform="translate(1869.5 1590.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line><line id="Line_7" data-name="Line 4" y1="9" x2="9" transform="translate(1869.5 1599.5)" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="2"></line></g></svg>',
3296            ],
3297        URLhashListener:true,
3298
3299    });
3300
3301    var hash;
3302    owl.on('translated.owl.carousel', function(event) {
3303
3304        hash = jQuery(".theme_slider_3 .owl-item.active .item").attr('data-hash');
3305
3306        jQuery('.theme_slider_3_carousel-indicators a').removeClass('active');
3307        jQuery('a[href="#'+hash+'"]').addClass('active');
3308    });
3309
3310
3311}
3312
3313
3314/*
3315*
3316*
3317*/
3318function estate_sidebar_slider_carousel(){
3319    "use strict";
3320    let is_rtl=false;
3321    if(control_vars.is_rtl==='1'){
3322         is_rtl=true;
3323    }
3324
3325    // Check if owlCarousel is available
3326    if (typeof jQuery.fn.owlCarousel === 'function') {
3327        jQuery(".owl-featured-slider").owlCarousel({
3328            loop:true,
3329            margin:0,
3330            nav:true,
3331            items:1,
3332            dots:false,
3333            rtl:is_rtl,
3334            navText : [
3335                '<button class="carousel-control-prev wpresidence-carousel-control " type="button" data-slide="prev"><i class="demo-icon icon-left-open-big"></i><span class="visually-hidden">Previous</span></button>',
3336                '<button class="carousel-control-next wpresidence-carousel-control " type="button" data-slide="next"><i class="demo-icon icon-right-open-big"></i><span class="visually-hidden">Previous</span></button>'
3337            ],
3338        });
3339    }else {
3340        console.warn("owlCarousel function not found.");
3341    }
3342
3343}
3344 
3345
3346
3347/*
3348*  
3349*
3350*/
3351function estate_start_lightbox_modal(){
3352    "use strict";
3353    var jump_slide;
3354
3355    var owl = jQuery("#owl-demo-modal");
3356    owl.trigger("destroy.owl.carousel");
3357
3358  owl.owlCarousel({
3359        loop:true,
3360        margin:0,
3361        nav:true,
3362        items:1,
3363        dots:false, 
3364        startPosition:1,
3365        navText : [
3366            '<button class="carousel-control-prev wpresidence-carousel-control " type="button" data-sli
3366de="prev"><i class="demo-icon icon-left-open-big"></i><span class="visually-hidden">Previous</span></button>',
3367            '<button class="carousel-control-next wpresidence-carousel-control " type="button" data-slide="next"><i class="demo-icon icon-right-open-big"></i><span class="visually-hidden">Previous</span></button>'
3368        ],
3369    });
3370
3371
3372    jQuery('.lightbox_trigger').on( 'click', function(event) {
3373
3374
3375
3376        event.preventDefault();
3377        jump_slide=parseInt( jQuery(this).attr('data-slider-no') );
3378        var carousel = jQuery("#owl-demo-modal");
3379        carousel.owlCarousel();
3380          carousel.trigger("refresh.owl.carousel");
3381
3382        carousel.trigger("to.owl.carousel", [jump_slide, 1, true]);
3383        jQuery('.lightbox_property_wrapper').show();
3384
3385    });
3386
3387    jQuery('.lighbox-image-close').on( 'click', function(event) {
3388        event.preventDefault();
3389        jQuery('.lightbox_property_wrapper').hide();
3390    });
3391}
3392
3393
3394
3395
3396/**
3397 * WPResidence Blog List Widget AJAX Handler
3398 *
3399 * Handles AJAX loading of additional blog posts for the blog list widget.
3400 *
3401 * @package WPResidence
3402 * @subpackage Widgets
3403 * @since 1.0.0
3404 */
3405function wpestate_blog_list_widget() {
3406    "use strict";
3407
3408    var ajaxurl = ajaxcalls_vars.wpestate_ajax;
3409
3410    jQuery('.blog_list_loader').on('click', function (event) {
3411        var $button = jQuery(this);
3412        var $container = $button.parent().parent();
3413        var $loader = $container.find('.wpestate_listing_sh_loader');
3414        var $grid = $container.find('.items_shortcode_wrapper_grid');
3415
3416        var page = parseInt($container.attr('data-page'), 10) + 1;
3417        $container.attr('data-page', page);
3418
3419
3420
3421        //$loader.show(); 
3422        if ($container.find('.items_shortcode_wrapper_grid').length>0 ){
3423            wpestate_createSkeletons($container.find('.items_shortcode_wrapper_grid'),true);
3424        }else{
3425            wpestate_createSkeletons($container.find('.blog25_shortcode_wrapper'),true);
3426        }
3427
3428        jQuery.ajax({
3429            type: 'POST',
3430            dataType: 'json',
3431            url: ajaxurl,
3432            data: {
3433                action: 'wpestate_load_blog_list_widget_wrapper',
3434                control_terms_id: $container.attr('data-category_ids'),
3435                number: $container.attr('data-number'),
3436                page: page,
3437                rownumber: $container.attr('data-row-number'),
3438                card_version: $container.attr('data-card-version'),
3439                sort_by: $container.attr('data-sort-by'),
3440                display_grid: $container.attr('data-display-grid')
3441            },
3442            success: function (data) {
3443          
3444               
3445                if (data.success) {
3446                    if ($grid.length) {
3447                        if (data.results === 0) {
3448                         //   $loader.before(data.html).hide();
3449                            $button.hide();
3450                        } else {
3451                            //$grid.append(data.html);
3452                            wpestate_replaceSkeletons($container.find('.items_shortcode_wrapper_grid'), data.html,true)
3453                        }
3454                    } else {
3455                       // $loader.before(data.html).hide();
3456                        wpestate_replaceSkeletons($container.find('.blog25_shortcode_wrapper'), data.html,true)
3457                        if (data.results === 0) {
3458                            $button.hide();
3459                        }
3460                    }
3461                } else {
3462                    $button.hide();
3463                }
3464                $loader.hide();
3465            },
3466            error: function (xhr, status, error) {
3467                console.error('AJAX request failed:', error);
3468                $loader.hide();
3469            }
3470        });
3471    });
3472}
3473
3474
3475
3476/*
3477*
3478*
3479*/
3480function wpestate_property_list_sh(ajax_loader,ajax_filters){
3481    "use strict";
3482    var    ajaxurl         =   ajaxcalls_vars.wpestate_ajax;
3483    jQuery(ajax_loader).click( function(event) {
3484        console.log('wpestate_property_list_sh');
3485
3486        var container               =   jQuery(this).parent().parent();
3487        var type                    =   container.attr('data-type');
3488        var category_ids            =   container.attr('data-category_ids');
3489        var action_ids              =   container.attr('data-action_ids');
3490        var city_ids                =   container.attr('data-city_ids');
3491        var area_ids                =   container.attr('data-area_ids');
3492        var state_ids               =   container.attr('data-state_ids');
3493        var status                  =   container.attr('data-status_ids');
3494        var features                =   container.attr('data-features_ids');
3495        var number                  =   container.attr('data-number');
3496        var align                   =   container.attr('data-align');
3497        var show_featured_only      =   container.attr('data-show_featured_only');
3498        var random_pick             =   container.attr('data-random_pick');
3499        var featured_first          =   container.attr('data-featured_first');
3500        var page                    =   container.attr('data-page');
3501        var align                   =   container.attr('data-align');
3502        var row_number              =   container.attr('data-row-number');
3503        var card_version            =   container.attr('data-card-version');
3504        var sort_by                 =   container.attr('data-sort-by');
3505        var display_grid            =   container.attr('data-display-grid');
3506        var agentid                =   container.attr('data-agent-id');
3507
3508      
3509        page=parseInt(page);
3510        page=page+1;
3511        container.attr('data-page',page);
3512        //container.find('.wpestate_listing_sh_loader').show();
3513
3514       
3515   
3516        // Show skeleton placeholders while loading
3517        //wpestate_createSkeletons(container.find('.items_shortcode_wrapper'),true);
3518
3519        if (container.find('.items_shortcode_wrapper_grid').length>0 ){
3520            wpestate_createSkeletons(container.find('.items_shortcode_wrapper_grid'),true);
3521        }else{
3522            wpestate_createSkeletons(container.find('.items_shortcode_wrapper'),true);
3523        }
3524
3525        page=parseInt(page);
3526
3527        // remove no results message if the we change the tab
3528        if(page===1){
3529          container.find('.no_results').remove();
3530        }
3531
3532
3533
3534        var nonce = jQuery('#wpestate_ajax_filtering').val();
3535        jQuery.ajax({
3536        type: 'POST',
3537        dataType: 'json',
3538        url: ajaxurl,
3539        data: {
3540            'action'                :   'wpestate_load_recent_items_sh',
3541            'type'                  :   type,
3542            'category_ids'          :   category_ids,
3543            'action_ids'            :   action_ids,
3544            'city_ids'              :   city_ids,
3545            'area_ids'              :   area_ids,
3546            'state_ids'             :   state_ids,
3547            'status'                :   status,
3548            'features'              :   features,
3549            'number'                :   number,
3550            'align'                 :   align,
3551            'show_featured_only'    :   show_featured_only,
3552            'random_pick'           :   random_pick,
3553            'featured_first'        :   featured_first,
3554            'page'                  :   page,
3555            'row_number'            :   row_number,
3556            'card_version'          :   card_version,
3557            'sort_by'              :   sort_by,
3558            'display_grid'          :   display_grid,
3559            'agentid'              :   agentid,
3560            'security'              :   nonce
3561        },
3562
3563
3564        success: function (data) {
3565       
3566            if (data.success == true && data.html !== '') {
3567
3568                //container.find('.wpestate_listing_sh_loader').hide();
3569
3570                // Replace skeleton placeholders with real cards sequentially
3571                if (data.no_results === true) {
3572                    // Remove skeletons and show no results message
3573                    container.find('.skeleton-placeholder').remove();
3574                    container.find('.wpresidence_button').after(data.html).hide();
3575                } else {
3576                    // Replace skeletons one by one with smooth animation
3577            
3578                 
3579                    if (container.find('.items_shortcode_wrapper_grid').length>0 ){
3580                       
3581                        wpestate_replaceSkeletons(container.find('.items_shortcode_wrapper_grid'), data.html,true);
3582                    }else{
3583                        wpestate_replaceSkeletons(container.find('.items_shortcode_wrapper'), data.html,true);
3584                    }
3585                }
3586
3587                // Restart JavaScript functionality after AJAX load
3588               // wpestate_restart_js_after_ajax();
3589                
3590                // Handle custom image wrapping
3591                jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function(){
3592                    jQuery(this).parent().addClass('wrap_custom_image');
3593                });
3594                var wrap_image = parseInt( jQuery('.wrap_custom_image').width());
3595
3596                if(wrap_image!=0){
3597                    jQuery('.col-md-12>.property_listing_custom_design').css('padding-left',wrap_image);
3598                }
3599
3600            } else {
3601                // Remove skeletons and hide load more button on failure
3602                container.find('.skeleton-placeholder').remove();
3603                jQuery(ajax_loader).hide();
3604            }
3605        },
3606        error: function (errorThrown) {
3607            // Remove skeletons on error too
3608            container.find('.skeleton-placeholder').remove();
3609        }
3610    });//end ajax
3611
3612
3613    });
3614
3615
3616    jQuery(ajax_filters).on( 'click', function(event) {
3617
3618        var container   =   jQuery(this).parent().parent();
3619        var taxid       =   jQuery(this).attr('data-taxid');
3620        var taxonomy    =   jQuery(this).attr('data-taxonomy');
3621
3622        jQuery(this).parent().parent().find('.wpestate_item_list_sh').show();
3623
3624        switch(taxonomy) {
3625            case 'property_category':
3626
3627                var category_ids            =   container.attr('data-category_ids');
3628                category_ids = wpestate_replace_tax_id(jQuery(this),category_ids,taxid);
3629                container.attr('data-category_ids',category_ids);
3630
3631                break;
3632            case 'property_action_category':
3633
3634                var action_ids            =   container.attr('data-action_ids');
3635                action_ids = wpestate_replace_tax_id(jQuery(this),action_ids,taxid);
3636                container.attr('data-action_ids',action_ids);
3637
3638                break;
3639            case 'property_city':
3640
3641                var city_ids            =   container.attr('data-city_ids');
3642                city_ids = wpestate_replace_tax_id(jQuery(this),city_ids,taxid);
3643                container.attr('data-city_ids',city_ids);
3644
3645                break;
3646            case 'property_area':
3647
3648                var area_ids            =   container.attr('data-area_ids');
3649                area_ids = wpestate_replace_tax_id(jQuery(this),area_ids,taxid);
3650                container.attr('data-area_ids',area_ids);
3651
3652                break;
3653            case 'property_county_state':
3654
3655
3656                var state_ids            =   container.attr('data-state_ids');
3657                state_ids = wpestate_replace_tax_id(jQuery(this),state_ids,taxid);
3658                container.attr('data-state_ids',state_ids);
3659
3660                break;
3661
3662            case 'property_status':
3663                var status_ids            =   container.attr('data-status_ids');
3664                status_ids = wpestate_replace_tax_id(jQuery(this),status_ids,taxid);
3665
3666                container.attr('data-status_ids',status_ids);
3667
3668                break;
3669            case 'property_features':
3670                var status_ids            =   container.attr('data-features_ids');
3671                status_ids = wpestate_replace_tax_id(jQuery(this),status_ids,taxid);
3672
3673                container.attr('data-features_ids',status_ids);
3674
3675                break;
3676    
3677
3678        }
3679        container.attr('data-page',0);
3680        jQuery(this).toggleClass('tax_active');
3681        
3682        //container.find('.items_shortcode_wrapper_grid').empty();
3683        //container.find('.listing_wrapper').remove();
3684
3685        // Poll to check if skeletons exist, then remove original cards
3686        var pollCount = 0;
3687        var pollInterval = setInterval(function() {
3688            if (container.find('.skeleton-placeholder').length > 0 || pollCount > 10) {
3689                clearInterval(pollInterval);
3690                // Now safe to remove original cards
3691               // container.find('.items_shortcode_wrapper_grid').empty();
3692            
3693                 
3694                    container.find('.shortcode_wrapper_grid_item').has('.listing_wrapper:not(.skeleton-placeholder)').remove();    
3695                    container.find('.listing_wrapper:not(.skeleton-placeholder)').remove();
3696
3697
3698
3699                    container.find('.shortcode_wrapper_grid_item').each(function(){
3700                    var item = jQuery(this);
3701                  
3702                    
3703                    if(item.children('.listing_wrapper').length > 0){
3704                       // console.log('keep it');
3705                    } else {
3706                        //console.log('should not keep');
3707                    }
3708                    });
3709                container.find('.shortcode_wrapper_grid_item:empty').remove();
3710                container.find('.shortcode_wrapper_grid_item').each(function(){
3711                    if(jQuery(this).is(':empty')){
3712                        jQuery(this).remove();
3713                    }
3714                });
3715            }
3716            pollCount++;
3717        }, 150); // Check every 50ms
3718
3719
3720
3721
3722
3723        container.find('.wpestate_item_list_sh').trigger('click');
3724
3725    });
3726
3727
3728    function wpestate_replace_tax_id(acesta,tax_ids,taxid){
3729
3730
3731        if(!acesta.hasClass('tax_active')){
3732            if ( tax_ids.indexOf(taxid) >= 0){
3733                return taxid+",";
3734            }else{
3735                tax_ids=tax_ids+taxid+",";
3736            }
3737        }else{
3738            var to_replace=taxid+",";
3739            tax_ids=tax_ids.replace(to_replace , "");
3740        }
3741        return tax_ids;
3742
3743    }
3744
3745}
3746
3747
3748/**
3749 * WpEstate Open Menu Function
3750 * 
3751 * This function sets up event listeners for the header phone and user menu elements.
3752 * It handles the toggling of the user menu and shopping cart visibility.
3753 *
3754 * @since 1.0.0
3755 * 
3756 * @requires jQuery
3757 * 
3758 * @return {void}
3759 * 
3760 * @example
3761 * // Call this function after the DOM is ready
3762 * jQuery(document).ready(function($) {
3763 *     wpestate_open_menu();
3764 * });
3765 */
3766function wpestate_open_menu() {
3767    "use strict";
3768
3769    // Prevent click event propagation on header phone
3770    jQuery('.header_phone').on('click', function(event) {
3771        event.stopPropagation();
3772    });
3773
3774    // Handle click event on logged-in user menu
3775    jQuery('#user_menu_u.user_loged').on('click', function(event) {
3776        // Hide shopping cart
3777        jQuery('#wpestate_header_shoping_cart').fadeOut(400);
3778
3779        // Toggle user menu visibility
3780        if (jQuery('#user_menu_open').is(":visible")) {
3781            // If menu is visible, hide it and remove 'opensvg' class
3782            jQuery('#user_menu_open').removeClass('iosfixed').fadeOut(400);
3783            jQuery('.navicon-button').removeClass('opensvg');
3784        } else {
3785            // If menu is hidden, show it and add 'opensvg' class
3786            jQuery('#user_menu_open').fadeIn(400);
3787            jQuery('.navicon-button').addClass('opensvg');
3788        }
3789
3790        // Prevent event from bubbling up to parent elements
3791        event.stopPropagation();
3792    });
3793}
3794
3795/**
3796 * Check if the current device is mobile or tablet
3797 * 
3798 * This function uses Bootstrap 5.3's breakpoint checking to determine
3799 * if the current device is considered mobile or tablet.
3800 * 
3801 * @returns {boolean} True if the device is mobile or tablet, false otherwise
3802 */
3803function wpestate_isMobileOrTablet() {
3804    // Check if the window width is less than the 'xl' breakpoint
3805    return window.innerWidth < 1200; // Bootstrap's 'xl' breakpoint is 1200px
3806}
3807
3808
3809/*
3810*
3811*
3812*/
3813function wpestate_contact_us_shortcode(){
3814    "use strict";
3815    jQuery('#btn-cont-submit_sh').on( 'click', function(event) {
3816        var parent,contact_name, contact_email, contact_phone, contact_coment, agent_email, property_id, nonce, ajaxurl;
3817        contact_name    =   jQuery('#foot_contact_name_sh').val();
3818        contact_email   =   jQuery('#foot_contact_email_sh').val();
3819        contact_phone   =   jQuery('#foot_contact_phone_sh').val();
3820        contact_coment  =   jQuery('#foot_contact_content_sh').val();
3821        nonce           =   jQuery('#agent_property_ajax_nonce').val();
3822        ajaxurl         =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
3823        parent          =   jQuery(this).parent().parent();
3824   
3825        if(ajaxcalls_vars.use_gdpr==='yes'){
3826            if (!parent.find('.wpestate_agree_gdpr').is(':checked')) {
3827                jQuery('#footer_alert-agent-contact_sh').empty().removeClass('wpestate-agent-contact-sent').append(ajaxcalls_vars.gdpr_terms);
3828                return;
3829            }
3830        }
3831     
3832        jQuery('#footer_alert-agent-contact_sh').empty().append(ajaxcalls_vars.sending);
3833
3834        jQuery.ajax({
3835            type: 'POST',
3836            dataType: 'json',
3837            url: ajaxurl,
3838            data: {
3839                'action'    :   'wpestate_ajax_agent_contact_form',
3840                'name'      :   contact_name,
3841                'email'     :   contact_email,
3842                'phone'     :   contact_phone,
3843                'comment'   :   contact_coment,
3844                'nonce'     :   nonce
3845            },
3846            success: function (data) {
3847
3848                if (data.sent) {
3849                    jQuery('#foot_contact_name_sh').val('');
3850                    jQuery('#foot_contact_email_sh').val('');
3851                    jQuery('#foot_contact_phone_sh').val('');
3852                    jQuery('#foot_contact_content_sh').val('');
3853                    jQuery('#footer_alert-agent-contact_sh').empty().addClass('wpestate-agent-contact-sent').append(data.response);
3854                }else{
3855                    jQuery('#footer_alert-agent-contact_sh').empty().removeClass('wpestate-agent-contact-sent').append(data.response);
3856                }
3857
3858            },
3859            error: function (errorThrown) {
3860
3861            }
3862        });
3863    });
3864
3865}
3866
3867
3868
3869
3870
3871
3872
3873/*
3874*
3875*
3876*/
3877function wpestate_enable_property_modal(listing_id,main_img_url,main_title,link){
3878    "use strict";
3879
3880    if (Modernizr.mq('only all and (max-width: 1024px)')) {
3881        return;
3882    }
3883
3884
3885
3886    jQuery('.website-wrapper').css('position','fixed');
3887    jQuery('#property_modal_images').empty();
3888    var ajaxurl     =   ajaxcalls_vars.wpestate_ajax;
3889    var window_height =jQuery( window ).height();
3890
3891    jQuery("#property_modal_images") .css('height', window_height+'px');
3892    window_height=window_height-183;
3893    jQuery("#property_modal_content").css('height', window_height+'px');
3894
3895    jQuery('#modal_property_agent').empty();
3896    jQuery('.modal_content_block').empty();
3897    jQuery('#property_modal_content .modal_property_description').empty();
3898    jQuery('#property_modal_content .modal_property_adress').empty();
3899    jQuery('#property_modal_content .modal_property_details').empty();
3900    jQuery('#property_modal_content .modal_property_features').empty();
3901    jQuery('#property_modal_content .modal_property_video').empty();
3902    jQuery('#property_modal_content .modal_property_video_tour').empty();
3903    jQuery('#property_modal_content .modal_property_walkscore').empty();
3904    jQuery('#property_modal_content .modal_property_floor_plans').empty();
3905    jQuery('#modal_property_mortgage').empty();
3906    jQuery('#modal_property_maps').empty();
3907    jQuery('#property_details_modal_wrapper').show();
3908
3909    //prepopoluate
3910    var to_apped    ='<img src="'+main_img_url+'" data-slider-no="1" class="img-responsive lightbox_trigger" alt="image">';
3911
3912    jQuery('#property_modal_images').append(to_apped);
3913    jQuery('#property_modal_header .modal_property_title').html(main_title);
3914    jQuery('#owl-demo-modal').empty();
3915
3916
3917    wpestate_propery_preview_prepopulate();
3918
3919
3920    jQuery.ajax({
3921        type: 'POST',
3922        url: ajaxurl,
3923        dataType: 'json',
3924        data: {
3925            'action'            :   'wpestate_property_modal_listing_details',
3926            'postid'            :   listing_id,
3927
3928         //   'security'          :   nonce,
3929        },
3930        success: function (data) {
3931
3932            if(data.response===true){
3933
3934
3935                data.images.forEach(wpestate_populate_modal_images);
3936                jQuery('.property_placeholder').remove();
3937                data.full_images.forEach(wpestate_populate_modal_images_full);
3938                wpestate_populate_content(data);
3939
3940            }
3941        },
3942        error: function (errorThrown) {
3943
3944        }
3945    });//end ajax
3946
3947    ///
3948    /// aysn request no 2
3949    ////////////////////////////////////////////////////////////////////////////
3950     jQuery.ajax({
3951        type: 'POST',
3952        url: ajaxurl,
3953        dataType: 'json',
3954        data: {
3955            'action'            :   'wpestate_property_modal_listing_details_second',
3956            'postid'            :   listing_id,
3957
3958         //   'security'          :   nonce,
3959        },
3960        success: function (data) {
3961
3962            if(data.response===true){
3963
3964                jQuery('#property_modal_content .modal_property_yelp').empty().append(data.yelp);
3965               // jQuery('#property_modal_content .modal_property_walkscore').empty().append(data.walkscore);
3966                jQuery('#property_modal_content .modal_property_floor_plans').empty().append(data.floor_plans);
3967                jQuery('#modal_property_mortgage').empty().append(data.mortgage);
3968                jQuery('#modal_property_maps').empty().append(data.map);
3969
3970
3971                //floor plans
3972                wpestate_enable_floor_plans();
3973                estate_start_lightbox_floorplans();
3974
3975                //mortgage
3976                wpestate_show_morg_pie();
3977
3978                // map
3979      
3980                wpestate_map_shortcode_function();
3981
3982            }
3983        },
3984        error: function (errorThrown) {
3985
3986        }
3987    });//end ajax
3988}
3989
3990
3991/*
3992*
3993*
3994*/
3995
3996function wpestate_populate_content(data){
3997    jQuery('#property_modal_top_bar').empty();
3998    jQuery('#property_modal_top_bar').append(data.favorite);
3999    jQuery('#property_modal_top_bar').append(data.share);
4000
4001
4002    jQuery('#property_modal_header .modal_property_title').html('<a href="'+data.link+'" target="_blank">'+data.title+'</a>');
4003    jQuery('#property_modal_header .modal_property_price').html(data.price);
4004    jQuery('#property_modal_header .modal_property_bed').html(data.beds_section);
4005    jQuery('#property_modal_header .modal_property_addr').html(data.addr_section);
4006
4007    
4008    jQuery('#modal_property_agent').empty().append(data.agent_section);
4009    jQuery('#property_modal_content .modal_property_description').empty().append(data.content);
4010    jQuery('#property_modal_content .modal_property_adress').empty().append(data.address);
4011    jQuery('#property_modal_content .modal_property_details').empty().append(data.details);
4012    jQuery('#property_modal_content .modal_property_features').empty().append(data.features);
4013    jQuery('#property_modal_content .modal_property_video').empty().append(data.video);
4014    jQuery('#property_modal_content .modal_property_video_tour').empty().append(data.video_tour);
4015
4016    //contact
4017     wpestate_agent_contact_modals();
4018    //img
4019    estate_start_lightbox_modal();
4020
4021    // video
4022    if (jQuery(".venobox").length > 0){
4023        jQuery('.venobox').venobox();
4024    }
4025
4026    //favorite
4027    wpestate_add_to_favorites();
4028
4029    //print
4030     wpestate_print_property_page();
4031
4032}
4033
4034/*
4035*
4036*
4037*/
4038function wpestate_populate_modal_images(value,index){
4039
4040    if(  jQuery('.property_placeholder').length>0 ){
4041        var placeholder= jQuery('.property_placeholder:first');
4042        placeholder.attr('src',value).removeClass('property_placeholder');
4043    }else{
4044        var to_apped='<img src="'+value+'" data-slider-no="'+index+'" class="img-responsive lightbox_trigger" alt="image">';
4045
4046        jQuery('#property_modal_images').append(to_apped);
4047    }
4048
4049
4050}
4051
4052/*
4053*
4054*
4055*/
4056function wpestate_populate_modal_images_full(value,index){
4057   // var to_append2='<div class="item"><img src="'+value+'"></div>';
4058     var  to_append2='<div class="owl_holder" style="background-image:url('+value+')"></div>';
4059    jQuery('#owl-demo-modal').append(to_append2);
4060}
4061
4062
4063/*
4064*
4065*
4066*/
4067function wpestate_propery_preview_prepopulate(){
4068
4069    path_image=control_vars.path+'/img/placeholder1.png';
4070    for (i = 0; i <14; i++) {
4071        var to_apped='<img src="'+path_image+'" class="img-responsive  lightbox_trigger property_placeholder" data-slider-no="'+(i+1)+'" alt="image">';
4072        jQuery('#property_modal_images').append(to_apped);
4073    }
4074}
4075
4076/*
4077*
4078*
4079*/
4080
4081function wpestate_agent_contact_modals(){
4082    wpestate_agent_submit_email();
4083
4084    wpestate_enable_schedule_contact();
4085
4086    jQuery( "#modal_contact_agent").unbind( "click" );
4087    jQuery('#modal_contact_agent').on('click',function(event){
4088        jQuery('.schedule_wrapper').hide();
4089        jQuery('#property_modal_content .agent_contanct_form').slideDown();
4090
4091        jQuery('#property_modal_content').animate({
4092                scrollTop: 0
4093            },
4094            "slow"
4095        );
4096    });
4097
4098
4099
4100}
4101
4102/*
4103*
4104*
4105*/
4106
4107function wpestate_get_location(){
4108
4109    if(control_vars.location_animation==='no'){
4110      return;
4111    }
4112    if(  jQuery('.heading_over_image').length===0){
4113        return;
4114    }
4115
4116    jQuery.get("https://ipapi.co/json", function(place) {
4117        var city = place.city;
4118
4119        if(city == null ||  parseInt( jQuery('.home').length)===0 ){
4120             //do nothing
4121            }else{
4122                var heading = control_vars.location_animation_text;
4123
4124                heading = heading.replace("%city%", city);
4125
4126                jQuery('.home .heading_over_image,.home .heading_over_video').slideUp("300",function(){
4127                    jQuery('.home .heading_over_image,.home .heading_over_video').text(heading);
4128                    jQuery('.home .heading_over_image,.home .heading_over_video').slideDown();
4129                });
4130
4131            }
4132        }, "json");
4133}
4134
4135/**
4136 * WpEstate Sliding Box Interaction
4137 *
4138 * This function sets up the interactive behavior for the sliding box elements
4139 * in the WpResidence theme. It handles the mouseover event to activate and
4140 * deactivate sliding boxes.
4141 *
4142 * @since 1.0.0
4143 * 
4144 * @requires jQuery
4145 */
4146function wpestate_slider_box() {
4147    
4148    // Attach a mouseover event handler to all elements with class 'wpestate_sliding_box'
4149    jQuery(".wpestate_sliding_box").mouseover(function() {
4150        // 'this' refers to the current element being hovered over
4151        var selected_item = jQuery(this);
4152        
4153        // Find the parent container of the current sliding box
4154        var item_parent = selected_item.parent();
4155        
4156        // Remove 'active-element' class from all sliding boxes within the same parent
4157        item_parent.find('.wpestate_sliding_box').removeClass('active-element');
4158        
4159        // Add 'active-element' class to the currently hovered sliding box
4160        selected_item.addClass('active-element');
4161    });
4162}
4163
4164
4165
4166/*
4167*Mobile Menu Slide out
4168*
4169*/
4170function wpestate_mobile_menu_slideout(){
4171    var vc_size;
4172    var var_parents=new Array();
4173    var var_parents_back=new Array();
4174
4175  
4176
4177
4178    if(jQuery('.mobile-trigger-user').length>0){
4179        var slideout_user_menu = new Slideout({
4180            'panel': document.getElementById('all_wrapper'),
4181            'menu': document.getElementById('mobilewrapperuser'),
4182            'padding': -256,
4183            'tolerance': 70
4184        });
4185
4186        slideout_user_menu.disableTouch();
4187
4188        // Toggle button
4189        document.querySelector('.mobile-trigger-user').addEventListener('click', function() {
4190            slideout_user_menu.toggle();
4191           // jQuery('#mobilewrapperuser').show();
4192            if(jQuery('#mobilewrapperuser').is(':visible') ){
4193                jQuery('#mobilewrapperuser').hide();
4194            }else{
4195                jQuery('#mobilewrapperuser').show();
4196            }
4197        
4198        });
4199       
4200        jQuery('.mobilemenu-close-user').on( 'click', function(event) {
4201            slideout_user_menu.toggle();
4202            setTimeout(function() { 
4203                jQuery('#mobilewrapperuser').hide(); 
4204            }, 200);
4205    
4206        });
4207
4208    }
4209
4210
4211
4212    
4213    if(jQuery('.mobile-trigger').length>0){
4214
4215        var slideout_link_menu = new Slideout({
4216            'panel': document.getElementById('all_wrapper'),
4217            'menu': document.getElementById('mobilewrapper_links'),
4218            'padding': 256,
4219            'tolerance': 70,
4220            'side': 'left',
4221            'easing': 'cubic-bezier(.32,2,.55,.27)'
4222        });
4223        slideout_link_menu.disableTouch();
4224        document.querySelector('.mobile-trigger').addEventListener('click', function() {
4225            slideout_link_menu.toggle();
4226          
4227            if(jQuery('#mobilewrapper_links').is(':visible') ){
4228                jQuery('#mobilewrapper_links').hide();
4229            }else{
4230                jQuery('#mobilewrapper_links').show();
4231            }
4232        });
4233
4234        jQuery('.mobilemenu-close').on( 'click', function(event) {
4235            slideout_link_menu.toggle();
4236            setTimeout(function() { 
4237                jQuery('#mobilewrapper_links').hide();
4238            }, 200);
4239        });
4240    }
4241    
4242}
4243
4244/*
4245* Mobile Menu open submenu
4246*/
4247
4248function wpestate_mobile_menu_open_submenu(){
4249    jQuery('.mobilex-menu li').on( 'click', function(event) {
4250        event.stopPropagation();
4251        var selected;
4252        selected = jQuery(this).find('.sub-menu:first');
4253        selected.slideToggle();
4254    });
4255
4256}
4257
4258
4259
4260/*
4261* Mobile Menu Elementor open/close 
4262*/
4263
4264function wpestate_elementor_mobile_menu_trigger_open(){
4265    jQuery('.wpestate_mobile_menu_trigger').on('click', function(event) {
4266            jQuery(this).hide();
4267            const parent = jQuery(this).parent();
4268            const openButton=parent.find('.wpestate_mobile_menu_trigger_close');
4269            var menu = parent.find('.mobilex-menu');
4270
4271
4272            jQuery('.wpestate_mobile_menu_trigger_close').show();
4273            // Show the menu first to measure it correctly
4274            menu.css('display', 'block');
4275
4276            var containerRect = openButton[0].getBoundingClientRect();
4277
4278            var margin = 0; // Margin from the viewport edges
4279
4280            // Calculate the left position of the child
4281            var childLeft = -containerRect.left +margin;
4282
4283            // Apply the calculated positions
4284           // menu.css('left', childLeft + 'px');
4285            menu.css('width', 'calc(100vw - ' + (margin * 2) + 'px)');
4286
4287   
4288    });
4289
4290    jQuery('.wpestate_mobile_menu_trigger_close').on('click',function(event){
4291        jQuery(this).hide();
4292        const parent=jQuery(this).parent();    
4293        var menu = parent.find('.mobilex-menu');
4294        menu.css('transform', '');
4295        jQuery('.wpestate_mobile_menu_trigger').show();
4296        parent.find('.mobilex-menu').hide();
4297    });
4298
4299}
4300
4301
4302/*
4303* Control media buttons
4304*/
4305
4306function wpestate_control_media_buttons(){
4307    var curentID;
4308
4309    jQuery('.wpestate_control_media_button').on('click',function(){
4310        jQuery('.wpestate_control_media_button').removeClass('slideron');
4311        jQuery(this).addClass('slideron');
4312        jQuery('.wpestate_property_media_section_wrapper .status-wrapper').hide();
4313
4314        jQuery('.wpestate_property_slider_thing').hide();
4315        var div_to_show=jQuery(this).attr('data-show');
4316
4317        jQuery('.'+div_to_show).show();
4318        if(div_to_show=='wpestate_property_carousel'){
4319            jQuery('.wpestate_property_media_section_wrapper .status-wrapper').show();
4320        }
4321
4322        if(div_to_show=='google_map_slider_wrapper'){
4323            wpestate_control_media_emable_map();
4324        } 
4325        
4326        if(jQuery(this).attr('id')=='slider_enable_street'){
4327            wpestate_control_media_emable_street_view();
4328        }
4329
4330        
4331    });
4332}
4333
4334
4335
4336/*
4337*
4338* Enable Street Map
4339*
4340*/
4341
4342
4343function wpestate_control_media_emable_street_view(){
4344    var cur_lat, cur_long, myLatLng;
4345
4346    cur_lat     =   jQuery('#googleMapSlider').attr('data-cur_lat');
4347    cur_long    =   jQuery('#googleMapSlider').attr('data-cur_long');
4348    myLatLng    =   new google.maps.LatLng(cur_lat,cur_long);
4349
4350    jQuery('#gmapzoomplus.smallslidecontrol,#gmapzoomminus.smallslidecontrol,.google_map_poi_marker ').hide();
4351
4352    panorama.setPosition(myLatLng);
4353    panorama.setVisible(true);
4354}
4355
4356/*
4357*
4358* Enable Map for Slider
4359*
4360*/
4361
4362function wpestate_control_media_emable_map(){
4363    jQuery('#googleMapSlider').show();
4364    jQuery('#gmapzoomplus.smallslidecontrol,#gmapzoomminus.smallslidecontrol,.google_map_poi_marker ').show();
4365
4366    if(wp_estate_kind_of_map===1){
4367        google.maps.event.trigger(map, "resize");
4368    }else{
4369        setTimeout(function(){ map.invalidateSize(); }, 600);
4370    }
4371
4372    cur_lat     =   jQuery('#googleMapSlider').attr('data-cur_lat');
4373    cur_long    =   jQuery('#googleMapSlider').attr('data-cur_long');
4374
4375    if(wp_estate_kind_of_map===1){
4376        map.setOptions({draggable: true});
4377        myLatLng    =   new google.maps.LatLng(cur_lat,cur_long);
4378        map.setCenter(myLatLng);
4379        map.panBy(10,-100);
4380        panorama.setVisible(false);
4381    }
4382   
4383}
4384/*
4385*
4386* Get Cookie
4387*
4388*/
4389function wpestate_getCookie(cname) {
4390    var name = cname + "=";
4391    var ca = document.cookie.split(';');
4392    for(var i=0; i<ca.length; i++) {
4393        var c = ca[i];
4394        while (c.charAt(0)==' ') c = c.substring(1);
4395        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
4396    }
4397    return "";
4398 }
4399
4400
4401 /*
4402*
4403* eanble advanced tab functions
4404*
4405*/
4406
4407function wpestate_advtabs_function(item){
4408
4409    var all_sliders = ['mainform','sidebar','shortcode','mobile','half'];
4410    var min_tab_slider=    control_vars.adv6_min_price[slider_counter];
4411    var max_tab_slider=    control_vars.adv6_max_price[slider_counter];
4412
4413    slider_counter++;
4414    for (var i = 0, length = all_sliders.length; i < length; i++) {
4415        wpestate_enable_slider_tab_for_all(all_sliders[i],item,min_tab_slider,max_tab_slider);
4416    }
4417}
4418
4419
4420/*
4421*
4422* eanble advanced tab functions
4423*
4424*/
4425
4426
4427function wpestate_enable_slider_tab_for_all(position,item,min_tab_slider,max_tab_slider){
4428
4429    var slider_id = 'slider_price_'+item+'_'+position ;
4430    var price_min = 'price_low_'+item;
4431    var price_max = 'price_max_'+item;
4432    var ammount   = 'amount_'+item+'_'+position;
4433
4434
4435    var my_custom_curr_symbol  =   decodeURI ( wpestate_getCookie('my_custom_curr_symbol') );
4436    var my_custom_curr_coef    =   parseFloat( wpestate_getCookie('my_custom_curr_coef'));
4437    var my_custom_curr_pos     =   parseFloat( wpestate_getCookie('my_custom_curr_pos'));
4438    var my_custom_curr_cur_post=   wpestate_getCookie('my_custom_curr_cur_post');
4439
4440//    wpestate_enable_slider(slider_id, price_min, price_max, ammount, my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post, my_custom_curr_coef) ;
4441    wpestate_enable_slider_tab(min_tab_slider,max_tab_slider,'slider_price_'+item+'_'+position, 'price_low_'+item, 'price_max_'+item, 'amount_'+item+'_'+position, my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef,control_vars.adv6_min_price[slider_counter],control_vars.adv6_max_price[slider_counter]);
4442
4443    jQuery( '#slider_price_'+item +'_'+position).slider({
4444        stop: function( event, ui ) {
4445            if (typeof (wpestate_show_pins) !== "undefined") {
4446                first_time_wpestate_show_inpage_ajax_half=1;
4447
4448                wpestate_show_pins();
4449            }
4450        }
4451    });
4452}
4453
4454
4455/*
4456*
4457* eanble slider tab
4458*/
4459function wpestate_enable_slider_tab(slider_min,slider_max,slider_name, price_low, price_max, amount, my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post, my_custom_curr_coef) {
4460 
4461    "use strict";
4462    var price_low_val, price_max_val, temp_min, temp_max;
4463    price_low_val = parseInt(jQuery('#'+price_low).val(), 10);
4464    price_max_val = parseInt(jQuery('#'+price_max).val(), 10);
4465
4466
4467    slider_min = parseInt(slider_min,10);
4468    slider_max = parseInt(slider_max,10);
4469
4470    if (!isNaN(my_custom_curr_pos) && my_custom_curr_pos !== -1) {
4471        slider_min =slider_min *my_custom_curr_coef;
4472        slider_max =slider_max *my_custom_curr_coef;
4473    }
4474
4475    var slider_parent =  jQuery("#" + slider_name).parent();
4476
4477    var parent =  jQuery("#" + slider_name).parent().parent();
4478    var component_price_min;
4479    var component_price_max;
4480    var dropdown_parent;
4481    var dropdown_label;
4482    var component_label_value;
4483
4484    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4485        component_price_min=parent.find('#component_'+price_low);
4486        component_price_max=parent.find('#component_'+price_max);
4487        var dropdown_parent=parent.parent().find('.dropdown-toggle');
4488        dropdown_label = parent.find('.price_label_component');
4489    
4490    }
4491
4492
4493
4494    jQuery("#" + slider_name).slider({
4495        range: true,
4496        min: parseFloat(slider_min),
4497        max: parseFloat(slider_max),
4498        values: [price_low_val, price_max_val ],
4499        slide: function (event, ui) {
4500            temp_min= ui.values[0].format() ;
4501            temp_max= ui.values[1].format();
4502            if(control_vars.indian_format==="yes"){
4503              temp_min=wpstrea_js_indian_format(ui.values[0]);
4504              temp_max=wpstrea_js_indian_format(ui.values[1]);
4505            }
4506
4507
4508
4509            if (!isNaN(my_custom_curr_pos) && my_custom_curr_pos !== -1) {
4510                slider_parent.find("#" + price_low).val(ui.values[0]);
4511                slider_parent.find("#" + price_max).val(ui.values[1]);
4512
4513                jQuery("#price_low").val(ui.values[0]);
4514                jQuery("#price_max").val(ui.values[1]);
4515
4516
4517
4518
4519                if (my_custom_curr_cur_post === 'before') {
4520                    jQuery("#" + amount).text( wpestate_replace_plus( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + temp_min + " " + control_vars.to + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) )+ " " + temp_max);
4521                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4522                        component_price_min.val( wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + temp_min );
4523                        component_price_max.val( wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol) ) + " " + temp_max );
4524                        component_label_value = ""+ wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + wpestate_formatNumber_short(ui.values[0])+ " - " +  wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + wpestate_formatNumber_short(ui.values[1]) ;
4525                    
4526                        dropdown_parent.text(component_label_value);
4527                        dropdown_label.val(component_label_value);
4528                    }
4529               
4530                } else {
4531                    jQuery("#" + amount).text(temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) )+ " " + control_vars.to + " " + temp_max+ " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) );
4532                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4533                        component_price_min.val( temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) );
4534                        component_price_max.val( temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol)  ) );
4535                        component_label_value= wpestate_formatNumber_short(ui.values[0]) + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " - " + wpestate_formatNumber_short(ui.values[1]) + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) ;
4536                   
4537                        dropdown_parent.text(component_label_value);
4538                        dropdown_label.val(component_label_value);
4539                    }
4540                }
4541            } else {
4542                slider_parent.find("#" + price_low).val(ui.values[0]);
4543                slider_parent.find("#" + price_max).val(ui.values[1]);
4544
4545
4546                jQuery("#price_low").val(ui.values[0]);
4547                jQuery("#price_max").val(ui.values[1]);
4548
4549                if (control_vars.where_curency === 'before') {
4550                    jQuery("#" + amount).text( wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_min + " " + control_vars.to + " " +  wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_max );
4551                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4552                        component_price_min.val( wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_min );
4553                        component_price_max.val( wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_max );
4554                        component_label_value = ""+ wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + wpestate_formatNumber_short(ui.values[0])+ " - " +  wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + wpestate_formatNumber_short(ui.values[1])  ;
4555                  
4556                        dropdown_parent.text(component_label_value);
4557                        dropdown_label.val(component_label_value);
4558                  
4559                    }
4560                } else {
4561                    jQuery("#" + amount).text(temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + control_vars.to + " " + temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) );
4562                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4563                        component_price_min.val( temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) );
4564                        component_price_max.val( temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) )  );
4565                        component_label_value = wpestate_formatNumber_short(ui.values[0]) + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " - " + wpestate_formatNumber_short(ui.values[1]) + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) ;
4566                   
4567                        dropdown_parent.text(component_label_value);
4568                        dropdown_label.val(component_label_value);
4569                    }
4570                }
4571            }
4572        }
4573    });
4574}
4575
4576
4577
4578
4579
4580/*
4581*
4582* replace string
4583*
4584*/
4585function wpestate_replace_plus(string){
4586    return string.replace("+"," ");
4587}
4588
4589/*
4590*
4591* js indiam format
4592*
4593*/
4594
4595function wpstrea_js_indian_format(value){
4596    value=value.toString();
4597    var afterPoint = '';
4598    if(value.indexOf('.') > 0)
4599       afterPoint = value.substring(value.indexOf('.'),value.length);
4600    value = Math.floor(value);
4601    value=value.toString();
4602    var lastThree = value.substring(value.length-3);
4603    var otherNumbers = value.substring(0,value.length-3);
4604    if(otherNumbers != '')
4605        lastThree = ',' + lastThree;
4606    var res = otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + lastThree + afterPoint;
4607    return res;
4608}
4609
4610
4611/*
4612*
4613* Eanble Slider
4614*
4615*/
4616function wpestate_enable_slider(slider_name, price_low, price_max, amount, my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post, my_custom_curr_coef) {
4617
4618    var price_low_val, price_max_val, temp_min, temp_max, slider_min, slider_max;
4619    price_low_val = parseInt(jQuery('#'+price_low).val(), 10);
4620    price_max_val = parseInt(jQuery('#'+price_max).val(), 10);
4621
4622
4623    slider_min = control_vars.slider_min;
4624    slider_max = control_vars.slider_max;
4625    
4626
4627    if( jQuery('#'+price_max).hasClass('adv_search_elementor_price_max') ){
4628        slider_max = jQuery('#'+price_max).attr('data-value');
4629        slider_min = jQuery('#'+price_low).attr('data-value');       
4630    }
4631
4632    if( jQuery('#'+price_max).hasClass('wpestate_slider_in_tab') ){
4633        slider_max = jQuery('#'+price_max).attr('data-value');
4634        slider_min = jQuery('#'+price_low).attr('data-value');
4635       
4636    }
4637
4638
4639
4640    if (!isNaN(my_custom_curr_pos) && my_custom_curr_pos !== -1) {
4641        slider_min =slider_min *my_custom_curr_coef;
4642        slider_max =slider_max *my_custom_curr_coef;
4643    }
4644    
4645    var parent =  jQuery("#" + slider_name).parent().parent();
4646    var component_price_min;
4647    var component_price_max;
4648    var dropdown_parent;
4649    var dropdown_label;
4650    var component_label_value;
4651    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4652        component_price_min=parent.find('#component_'+price_low);
4653        component_price_max=parent.find('#component_'+price_max);
4654        var dropdown_parent=parent.parent().find('.dropdown-toggle');
4655        dropdown_label = parent.find('.price_label_component');
4656    
4657    }
4658
4659
4660    jQuery("#" + slider_name).slider({
4661        range: true,
4662        min: parseFloat(slider_min),
4663        max: parseFloat(slider_max),
4664        values: [price_low_val, price_max_val ],
4665        slide: function (event, ui) {
4666
4667            jQuery("#" + price_low).val(ui.values[0]);
4668            jQuery("#" + price_max).val(ui.values[1]);
4669            temp_min= ui.values[0].format() ;
4670            temp_max= ui.values[1].format();
4671            if(control_vars.indian_format==="yes"){
4672              temp_min=wpstrea_js_indian_format(ui.values[0]);
4673              temp_max=wpstrea_js_indian_format(ui.values[1]);
4674            }
4675
4676            if (!isNaN(my_custom_curr_pos) && my_custom_curr_pos !== -1) {
4677                if (my_custom_curr_cur_post === 'before') {
4678                    jQuery("#" + amount).text( wpestate_replace_plus( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + temp_min + " " + control_vars.to + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) )+ " " + temp_max);
4679                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4680                        component_price_min.val( wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + temp_min );
4681                        component_price_max.val( wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol) ) + " " + temp_max );
4682                        component_label_value = ""+ wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + wpestate_formatNumber_short(ui.values[0])+ " - " +  wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " " + wpestate_formatNumber_short(ui.values[1]) ;
4683                    
4684                        dropdown_parent.text(component_label_value);
4685                        dropdown_label.val(component_label_value);
4686                    }
4687                } else {
4688                    jQuery("#" + amount).text(temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) )+ " " + control_vars.to + " " + temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) );
4689                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4690                        component_price_min.val( temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) );
4691                        component_price_max.val( temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol)  ) );
4692                        component_label_value= wpestate_formatNumber_short(ui.values[0]) + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) + " - " + wpestate_formatNumber_short(ui.values[1]) + " " + wpestate_replace_plus ( decodeURIComponent ( my_custom_curr_symbol ) ) ;
4693                   
4694                        dropdown_parent.text(component_label_value);
4695                        dropdown_label.val(component_label_value);
4696                    }
4697                }
4698            } else {
4699
4700                if (control_vars.where_curency === 'before') {
4701                    jQuery("#" + amount).text(""+ wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_min+ " " + control_vars.to + " " +  wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_max);
4702                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4703                        component_price_min.val( wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_min );
4704                        component_price_max.val( wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + temp_max );
4705                        component_label_value = ""+ wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + wpestate_formatNumber_short(ui.values[0])+ " - " +  wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + wpestate_formatNumber_short(ui.values[1])  ;
4706                  
4707                        dropdown_parent.text(component_label_value);
4708                        dropdown_label.val(component_label_value);
4709                  
4710                    }
4711                } else {
4712                    jQuery("#" + amount).text(temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " " + control_vars.to + " " + temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) );
4713                    if(parent.hasClass('wpestate-price-popoup-wrapper')){
4714                        component_price_min.val( temp_min + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) );
4715                        component_price_max.val( temp_max + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) )  );
4716                        component_label_value = wpestate_formatNumber_short(ui.values[0]) + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) + " - " + wpestate_formatNumber_short(ui.values[1]) + " " + wpestate_replace_plus ( decodeURIComponent ( control_vars.curency ) ) ;
4717                   
4718                        dropdown_parent.text(component_label_value);
4719                        dropdown_label.val(component_label_value);
4720                    }
4721                }
4722            }
4723        }
4724    });
4725}
4726
4727/*
4728*
4729* enable slider for elementor
4730*
4731*/
4732
4733function wpestate_enable_slider_elementor(){
4734
4735    jQuery('.wpestate_elementor_search_tab_slider_wrapper').each(function(){
4736        var slider_id = jQuery(this).find('.wpestate_elementor_search_tab_slider').attr('id');
4737        var price_min = jQuery(this).find('.adv_search_elementor_price_low').attr('id');
4738        var price_max = jQuery(this).find('.adv_search_elementor_price_max').attr('id');
4739        var ammount   = jQuery(this).find('.wpresidence_slider_price').attr('id');
4740        var my_custom_curr_symbol  =   decodeURI ( wpestate_getCookie('my_custom_curr_symbol') );
4741        var my_custom_curr_coef    =   parseFloat( wpestate_getCookie('my_custom_curr_coef'));
4742        var my_custom_curr_pos     =   parseFloat( wpestate_getCookie('my_custom_curr_pos'));
4743        var my_custom_curr_cur_post=   wpestate_getCookie('my_custom_curr_cur_post');
4744        wpestate_enable_slider(slider_id, price_min, price_max, ammount, my_custom_curr_pos, my_custom_curr_symbol, my_custom_curr_cur_post,my_custom_curr_coef);
4745
4746    });
4747    
4748}
4749
4750/*
4751*
4752* 
4753*
4754*/
4755function wpestate_formatNumber_short(num) {
4756    num=parseFloat(num);
4757 
4758    if (num >= 1000000000) {
4759        return (num / 1000000000).toFixed(1).replace(/\.0$/, '') + 'B';
4760    }
4761    if (num >= 1000000) {
4762        return (num / 1000000).toFixed(1).replace(/\.0$/, '') + 'M';
4763    }
4764    if (num >= 1000) {
4765        return (num / 1000).toFixed(1).replace(/\.0$/, '') + 'K';
4766    }
4767    return num.toString();
4768}
4769
4770/*
4771*
4772* 
4773*
4774*/
4775
4776
4777function wpestate_done_typing(){
4778    if (typeof (wpestate_show_pins) !== "undefined") {
4779        first_time_wpestate_show_inpage_ajax_half=1;
4780
4781        wpestate_show_pins();
4782    }
4783}
4784
4785
4786/*
4787*
4788* 
4789*
4790*/
4791function isFunction(possibleFunction) {
4792     return typeof(possibleFunction) === typeof(Function);
4793}
4794
4795
4796
4797/*
4798*
4799* calculate morgage widget action
4800*/
4801
4802function wpestate_zillow_widget_action(){
4803    
4804    jQuery('#zill_submit_estimate').on( 'click', function(event) {
4805        var button = jQuery(this);
4806        var container = button.parent();
4807        var zillow_adress = jQuery('#zill_estimate_adr1').val();
4808        var zillow_city = jQuery('#zill_estimate_city1').val();
4809        var zillow_state = jQuery('#zill_estimate_state1').val();
4810
4811        var full_address = zillow_adress+', '+zillow_city+', '+zillow_state;
4812
4813        if(zillow_adress==''|| zillow_city=='' || zillow_state==''){
4814            var answer=control_vars.zillow_fields;
4815            container.find('.wpestate_zillow_answer').empty().append(answer);
4816            return;
4817        }
4818
4819
4820
4821        container.find('.wpestate_zillow_answer').empty().append(control_vars.zillow_wait);
4822
4823        ajaxurl     =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
4824        var nonce = jQuery('#wpestate_zillow_nonce').val();
4825        jQuery.ajax({
4826            type: 'POST',
4827            dataType: 'json',
4828            url: ajaxurl,
4829            data: {
4830                'action'    :   'wpestate_zillow_estimation',
4831                'zillow_adress'      :   zillow_adress,
4832                'zillow_city'       :   zillow_city,
4833                'zillow_state'    :   zillow_state,
4834                'full_address'      :   full_address,
4835                'security'  :   nonce
4836            },
4837            success: function (data) {
4838              
4839                
4840                
4841                
4842                if(data.total===0){
4843                    var answer=control_vars.zillow_none+" "+full_address;
4844                }else{
4845
4846                    var zillow_price = data.bundle[0].zestimate;
4847                  
4848                    const formattedPrice = new Intl.NumberFormat('en-US', {
4849                        style: 'currency',
4850                        currency: 'USD',
4851                        useGrouping: true
4852                      }).format(zillow_price);
4853    
4854    
4855                    var answer =control_vars.wpestate_zillow_answer+" <span class='wpestate_zillow_address'>"+full_address+"</span> "+control_vars.zillow_is+" <span class='wpestate_zillow_price'>"+formattedPrice+"</span>";
4856                    
4857                }
4858                
4859            
4860                container.find('.wpestate_zillow_answer').empty().append(answer);
4861            
4862            },
4863            error: function (errorThrown) {}
4864        });//end ajax
4865
4866
4867
4868
4869
4870       
4871    });
4872}
4873
4874/*
4875*
4876* calculate morgage widget action
4877*/
4878
4879function wpestate_morgate_widget_action(){
4880    jQuery('#morg_compute').on( 'click', function(event) {
4881
4882        var intPayPer  = 0;
4883        var intMthPay  = 0;
4884        var intMthInt  = 0;
4885        var intPerFin  = 0;
4886        var intAmtFin  = 0;
4887        var intIntRate = 0;
4888        var intAnnCost = 0;
4889        var intVal     = 0;
4890        var salePrice  = 0;
4891
4892        salePrice = jQuery('#sale_price').val();
4893        intPerFin = jQuery('#percent_down').val() / 100;
4894
4895        intAmtFin = salePrice - salePrice * intPerFin;
4896        intPayPer =  parseInt (jQuery('#term_years').val(),10) * 12;
4897        intIntRate = parseFloat (jQuery('#interest_rate').val(),10);
4898        intMthInt = intIntRate / (12 * 100);
4899        intVal = wpestate_raisePower(1 + intMthInt, -intPayPer);
4900        intMthPay = intAmtFin * (intMthInt / (1 - intVal));
4901        intAnnCost = intMthPay * 12;
4902
4903        jQuery('#am_fin').html("<strong>"+control_vars.morg1+"</strong> " + (Math.round(intAmtFin * 100)) / 100 + " ");
4904        jQuery('#morgage_pay').html("<strong>"+control_vars.morg2+"</strong>" + (Math.round(intMthPay * 100)) / 100 + " ");
4905        jQuery('#anual_pay').html("<strong>"+control_vars.morg3+"</strong>" + (Math.round(intAnnCost * 100)) / 100 + " ");
4906        jQuery('#morg_results').show();
4907        jQuery('.mortgage_calculator_div').css('height',532+'px');
4908    });
4909
4910}
4911
4912/*
4913*
4914* sanitzie string to be used as classname
4915*
4916*/
4917function wpestateSanitizeClassName(str) {
4918    // Remove leading numbers by replacing them with a prefix (e.g., 'class-')
4919    str = str.replace(/^\d+/, 'class-');
4920
4921    // Replace invalid characters with a hyphen
4922    str = str.replace(/[^a-zA-Z0-9-_]/g, '-');
4923
4924    // Remove multiple hyphens
4925    str = str.replace(/-+/g, '-');
4926
4927    // Remove leading and trailing hyphens
4928    str = str.trim().replace(/(^-|-$)/g, '');
4929
4930    return str;
4931}
4932
4933
4934/**
4935* Initialize autocomplete functionality for location search fields.
4936* 
4937* This function sets up jQuery UI autocomplete on location input fields with the following features:
4938* - Filters and displays location suggestions as user types
4939* - Limits results to 12 items
4940* - Adds a reset button after selected text
4941* - Groups results by location category (City, Area, County/State)
4942* - Updates map pins on selection
4943* 
4944* @since 4.9.0
4945* @param {Array} availableTags - Array of location objects with properties:
4946*   @param {string} category - Location category ("City", "Area", "County or State")
4947*   @param {string} labelcategory - Category identifier for CSS ("city", "area", "countystate")
4948*   @param {string} label - Display name of the location
4949*   @param {string} value - Location value to be used
4950* @param {string} inputID - ID of the input field to initialize autocomplete on
4951* 
4952* @requires jQuery
4953* @requires jQuery UI Autocomplete
4954* 
4955* DOM Requirements:
4956* - Input field must be wrapped in .adv_locations_search_component_wrapper
4957* - Input field must have class .adv_locations_search
4958* 
4959* Global variables used:
4960* - first_time_wpestate_show_inpage_ajax_half
4961* 
4962* Related functions:
4963* - wpestate_show_pins() - Updates map pins after selection
4964*/
4965function wpresidenceInitializeAutocomplete(availableTags, inputID) {
4966    jQuery("#" + inputID).autocomplete({
4967        source: function(request, response) {
4968            var results = jQuery.ui.autocomplete.filter(availableTags, request.term);
4969            response(results.slice(0, 12));
4970        },
4971        select: function(event, ui) {
4972            var $input = jQuery(this);
4973            var $wrapper = $input.parent();
4974            var selectedText = ui.item.label; // Get the selected text
4975            
4976            // Create reset button
4977            var $resetBtn = jQuery(`
4978                <button type="button" class="wpresidece-reset-btn">
4979                    <svg width="14px" height="14px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4980                        <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
4981                        <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
4982                        <g id="SVGRepo_iconCarrier">
4983                            <rect width="24" height="24"></rect>
4984                            <path d="M7 17L16.8995 7.10051" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
4985                            <path d="M7 7.00001L16.8995 16.8995" stroke="#000000" stroke-linecap="round" stroke-linejoin="round"></path>
4986                        </g>
4987                    </svg>
4988                </button>`);
4989
4990            // Remove any existing reset button first
4991            $wrapper.find('.wpresidece-reset-btn').remove();
4992            
4993            // Add the reset button after input
4994            $input.after($resetBtn);
4995
4996            // Calculate position based on selected text
4997            var $measure = jQuery('<span>').css({
4998                'font-family': $input.css('font-family'),
4999                'font-size': $input.css('font-size'),
5000                'font-weight': $input.css('font-weight'),
5001                'position': 'absolute',
5002                'visibility': 'hidden',
5003                'white-space': 'pre'
5004            }).text(selectedText);
5005            
5006            $wrapper.append($measure);
5007            
5008            var inputPadding = parseInt($input.css('padding-left'));
5009            var textWidth = $measure.width();
5010            
5011            $resetBtn.css({
5012                'left': (inputPadding + textWidth + 5) + 'px', // 5px buffer 
5013                'right': 'auto'
5014            });
5015            
5016            $measure.remove();
5017
5018            // Event handler for the reset button
5019            $resetBtn.on('click', function() {
5020                $input.val("");
5021                jQuery(this).remove();
5022                setTimeout(function() {
5023                    first_time_wpestate_show_inpage_ajax_half = 1;
5024                    wpestate_show_pins();
5025                }, 1000);
5026            });
5027
5028            setTimeout(function() {
5029                first_time_wpestate_show_inpage_ajax_half = 1;
5030                wpestate_show_pins();
5031            }, 1000);
5032        },
5033        change: function() {
5034        }
5035    }).autocomplete("instance")._renderItem = function(ul, item) {
5036        var item_class = "wpresidence-geolocatiomarker-" + item.labelcategory;
5037        var $li = jQuery("<li>").append("<div class='" + item_class + "'>" + item.label + "</div>");
5038
5039        var lastCategory = jQuery(ul).find(".wpresidece-dropdown-category-label:last").data("category");
5040        if (lastCategory !== item.category) {
5041            var $categoryDiv = jQuery("<div>")
5042                .addClass("wpresidece-dropdown-category-label")
5043                .data("category", item.category)
5044                .text(item.category);
5045            jQuery(ul).append($categoryDiv);
5046        }
5047
5048        return $li.appendTo(ul);
5049    };
5050}
5051
5052
5053
5054/*
5055*
5056* save search actions
5057*
5058*/
5059function wpestate_save_search_actions(){
5060
5061    jQuery('#save_search_button').on( 'click', function(event) {
5062        var nonce, search, search_name, parent, ajaxurl,meta;
5063        search_name     =   jQuery('#search_name').val();
5064        search          =   jQuery('#search_args').val();
5065        meta            =   jQuery('#meta_args').val();
5066        nonce           =   jQuery('#wpestate_save_search_nonce').val();
5067        ajaxurl         =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
5068        jQuery('#save_search_notice').html(control_vars.save_search);
5069
5070        jQuery.ajax({
5071            type: 'POST',
5072            url: ajaxurl,
5073            data: {
5074                'action'        :   'wpestate_save_search_function',
5075                'search_name'   :   search_name,
5076                'search'        :   search,
5077                'meta'          :   meta,
5078                'security'         :   nonce
5079            },
5080            success: function (data) {
5081
5082                jQuery('#save_search_notice').html(data);
5083                jQuery('#search_name').val('');
5084            },
5085            error: function (errorThrown) {
5086            }
5087        });
5088
5089    });
5090}
5091
5092/*
5093*
5094* delete save search actions
5095*
5096*/
5097function wpestate_delete_save_search_actions(){
5098    jQuery('.delete_search').on( 'click', function(event) {
5099        var  search_id, parent, ajaxurl,confirmtext;
5100        confirmtext = control_vars.deleteconfirm;
5101
5102        if (confirm(confirmtext)) {
5103            event.preventDefault();
5104            ajaxurl         =   ajaxcalls_vars.admin_url + 'admin-ajax.php';
5105            search_id       =   jQuery(this).attr('data-searchid');
5106            parent          =   jQuery(this).parent();
5107            jQuery(this).html(control_vars.deleting);
5108            var nonce = jQuery('#wpestate_searches_actions').val();
5109            jQuery.ajax({
5110                type: 'POST',
5111                url: ajaxurl,
5112                data: {
5113                    'action'        :   'wpestate_delete_search',
5114                    'search_id'     :   search_id,
5115                    'security'      :   nonce,
5116                },
5117                success: function (data) {
5118
5119                    if (data==='deleted'){
5120                        parent.remove();
5121                    }
5122
5123                },
5124                error: function (errorThrown) {
5125                }
5126            });
5127
5128
5129        }
5130
5131    });
5132}
5133
5134
5135
5136/*
5137*
5138* 
5139*
5140*/
5141function wpestate_overview_map(){
5142    jQuery('#overview_map').click(function(){
5143        jQuery('#wpestate_overview_map_modal').appendTo("body");
5144        jQuery('body> #wpestate_overview_map_modal').first().modal("show");
5145        
5146    });
5147}
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157////////////////
5158
5159/**
5160 * Creates skeleton cards in container based on existing card count
5161 * @param {jQuery} container - Container element
5162 * @param {boolean} append - If true, append skeletons; if false, empty container first (default: false)
5163 * 
5164 * data-row-number="3" - blg list
5165 */
5166function wpestate_createSkeletons(container, append) {
5167    // Default parameter handling for ES5 compatibility
5168    if (typeof append === 'undefined') {
5169        append = false;
5170    }
5171    
5172     // Detect if this is a grid layout
5173    var isGrid = container.find('.shortcode_wrapper_grid_item').length > 0;
5174    
5175    // Count existing cards BEFORE they get cleared
5176    var existingCards = container.find('.listing_wrapper:not(.skeleton-placeholder)');
5177    var existingCount = existingCards.length;
5178    
5179    // Handle clearing based on append parameter
5180    if (append === false) {
5181        container.empty();
5182    }
5183   
5184    // Calculate items per row from Bootstrap grid classes based on current viewport
5185    var itemsPerRow = parseInt( container.attr('data-row-number')) ;
5186    var gridClasses = 'col-lg-4 col-12 col-sm-6 col-md-6';
5187    var cardClasses = 'property_listing property_card_default';
5188   
5189
5190
5191    if (isGrid) {
5192        // Grid layout logic
5193
5194        // For grid, we don't use Bootstrap classes
5195        gridClasses = '';
5196        
5197        // Extract card classes from existing cards
5198        if (existingCards.length > 0) {
5199            var cardElement = existingCards.first().find('.property_listing');
5200            if (cardElement.length > 0) {
5201                cardClasses = cardElement.attr('class');
5202            }
5203        }
5204        
5205        
5206        
5207    } else {
5208            
5209        if (existingCards.length > 0) {
5210            var firstCard = existingCards.first();
5211            var classList = firstCard.attr('class').split(' ');
5212        
5213            // Extract grid classes
5214            var extractedGridClasses = classList.filter(function(cls) {
5215                return cls.indexOf('col-') === 0;
5216            }).join(' ');
5217            if (extractedGridClasses) {
5218                gridClasses = extractedGridClasses;
5219            }
5220        
5221            // Calculate items per row based on current viewport
5222            var viewportWidth = window.innerWidth;
5223            var cols = 4; // default (col-lg-4 = 12/4 = 3 per row)
5224        
5225            if (viewportWidth >= 1200) {
5226                // xl breakpoint - look for col-xl-* or fallback to col-lg-*
5227                var xlClass = classList.find(function(cls) { return cls.match(/^col-xl-(\d+)$/); });
5228                if (xlClass) {
5229                    cols = parseInt(xlClass.match(/^col-xl-(\d+)$/)[1]);
5230                } else {
5231                    var lgClass = classList.find(function(cls) { return cls.match(/^col-lg-(\d+)$/); });
5232                    if (lgClass) cols = parseInt(lgClass.match(/^col-lg-(\d+)$/)[1]);
5233                }
5234            } else if (viewportWidth >= 992) {
5235                // lg breakpoint
5236                var lgClass = classList.find(function(cls) { return cls.match(/^col-lg-(\d+)$/); });
5237                if (lgClass) cols = parseInt(lgClass.match(/^col-lg-(\d+)$/)[1]);
5238            } else if (viewportWidth >= 768) {
5239                // md breakpoint
5240                var mdClass = classList.find(function(cls) { return cls.match(/^col-md-(\d+)$/); });
5241                if (mdClass) cols = parseInt(mdClass.match(/^col-md-(\d+)$/)[1]);
5242            } else if (viewportWidth >= 576) {
5243                // sm breakpoint
5244                var smClass = classList.find(function(cls) { return cls.match(/^col-sm-(\d+)$/); });
5245                if (smClass) cols = parseInt(smClass.match(/^col-sm-(\d+)$/)[1]);
5246            } else {
5247                // xs breakpoint - look for col-* (no breakpoint)
5248                var xsClass = classList.find(function(cls) { return cls.match(/^col-(\d+)$/); });
5249                if (xsClass) cols = parseInt(xsClass.match(/^col-(\d+)$/)[1]);
5250            }
5251        
5252            itemsPerRow = Math.floor(12 / cols);
5253        
5254            // Extract card classes
5255            var cardElement = firstCard.find('.property_listing');
5256            if (cardElement.length > 0) {
5257                cardClasses = cardElement.attr('class');
5258            }
5259        }
5260    }
5261
5262    var skeletonCount;
5263    
5264    // Simple: skeleton count = existing count (complete rows)
5265    if (append === false) {
5266        skeletonCount = Math.ceil(existingCount / itemsPerRow) * itemsPerRow;
5267    }else{
5268         
5269
5270        if(isGrid){
5271            skeletonCount = parseInt( container.parent().attr('data-row-number'));
5272        }else{
5273            skeletonCount = itemsPerRow;
5274          }
5275    }
5276
5277    // Create skeleton HTML
5278    var skeletonHTML = '';
5279    for (var i = 0; i < skeletonCount; i++) {
5280        skeletonHTML += wpestate_createSkeletonCard(gridClasses, cardClasses, false);
5281    }
5282   
5283    // Clear specific elements if appending (don't clear everything)
5284   
5285   
5286    // Add skeletons to container
5287    container.append(skeletonHTML);
5288}
5289
5290/**
5291 * Replaces skeleton cards with real cards
5292 * @param {jQuery} container - Container element
5293 * @param {string} htmlData - HTML data with real cards
5294 */
5295function wpestate_replaceSkeletons(container, htmlData,append) {
5296
5297
5298    // Detect if this is a grid layout
5299    var isGrid = container.find('.shortcode_wrapper_grid_item').length > 0;
5300
5301    // Default parameter handling for ES5 compatibility
5302    if (typeof append === 'undefined') {
5303        append = false;
5304    }
5305    
5306    // Find skeleton placeholders
5307    var skeletons = container.find('.skeleton-placeholder');
5308    // Parse new HTML data
5309    var tempDiv = jQuery('<div>').html(htmlData);
5310    var newCards = tempDiv.find('.listing_wrapper');
5311    var pagination = tempDiv.find('.pagination_ajax_search');
5312    var pagination2 = tempDiv.find('.pagination_ajax');
5313    var scrollHere = tempDiv.find('#scrollhere');
5314    var no_results = tempDiv.find('.no_results');
5315  
5316    // If no skeletons, just append normally
5317    if (skeletons.length === 0) {
5318        container.append(htmlData);
5319        return;
5320    }
5321    
5322    // Add scrollhere at beginning if exists
5323    if (scrollHere.length > 0) {
5324        container.prepend(scrollHere);
5325    }
5326    
5327    // Replace ALL skeletons one by one - some with real cards, others removed
5328    var delay = 0;
5329    var intervalTime = 100;
5330    
5331    if (append==true){
5332        var maxItems = skeletons.length;
5333    }else{
5334        var maxItems = Math.max(skeletons.length, newCards.length);
5335    }
5336
5337
5338    for (var i = 0; i < maxItems; i++) {
5339        
5340        (function(index) {
5341            setTimeout(function() {
5342                if (index < skeletons.length && index < newCards.length) {
5343                    // Replace skeleton with real card
5344                    
5345                    if(isGrid){
5346                        var wrappedCard = jQuery('<div class="shortcode_wrapper_grid_item"></div>').append(jQuery(newCards[index]));
5347                        jQuery(skeletons[index]).replaceWith(wrappedCard);
5348                    }else{
5349                        jQuery(skeletons[index]).replaceWith(jQuery(newCards[index]));
5350                    }
5351                
5352
5353
5354                } else if (index < skeletons.length) {
5355                    // Remove empty skeleton (right to left)
5356                    var emptySkeletonIndex = skeletons.length - 1 - (index - newCards.length);
5357                    jQuery(skeletons[emptySkeletonIndex]).fadeOut(200, function() {
5358                        jQuery(this).remove();
5359                    });
5360                } else if (index < newCards.length) {
5361                    // Add extra card (more cards than skeletons)
5362                    container.append(jQuery(newCards[index]));
5363                }
5364            }, delay);
5365        })(i);
5366        
5367        delay += intervalTime;
5368
5369    } 
5370
5371    
5372    // Add pagination after all skeletons are processed
5373    if (pagination.length > 0) {
5374        setTimeout(function() {
5375            container.append(pagination);
5376        }, delay + 200);
5377    }
5378    
5379
5380  // Add pagination2 after all skeletons are processed
5381    if (pagination2.length > 0) {
5382        setTimeout(function() {
5383            container.append(pagination2);
5384        }, delay + 200);
5385    }
5386   
5387     // Add pagination2 after all skeletons are processed
5388    if (no_results.length > 0) {
5389        setTimeout(function() {
5390            container.append(no_results);
5391        }, delay + 200);
5392    }
5393
5394
5395     // Call restart JS after all real cards are displayed
5396    setTimeout(function() {
5397        if (typeof wpestate_restart_js_after_ajax === 'function') {
5398            wpestate_restart_js_after_ajax();
5399        }
5400    }, delay + 300);
5401
5402}
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412/**
5413 * Creates a skeleton placeholder card
5414 */
5415function wpestate_createSkeletonCard(gridClasses, cardClasses, is_grid) {
5416    var skeletonCard = `
5417    <div class="${gridClasses} listing_wrapper skeleton-placeholder">
5418        <div class="${cardClasses} skeleton-card">
5419            <div class="listing-unit-img-wrapper">
5420                <div class="skeleton-image skeleton-shimmer"></div>
5421            </div>
5422            <div class="property-unit-information-wrapper">
5423                <div class="skeleton-text title skeleton-shimmer"></div>
5424                <div class="skeleton-text category skeleton-shimmer"></div>
5425                <div class="skeleton-text details skeleton-shimmer"></div>
5426            </div>
5427        </div>
5428    </div>`;
5429    
5430    if (is_grid) {
5431        return `<div class="shortcode_wrapper_grid_item">${skeletonCard}</div>`;
5432    }
5433    
5434    return skeletonCard;
5435}

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.