PageSourceSearch

https://eviagreece.gr/wp-content/themes/listeo/js/custom.js?ver=20220821

js eviagreece.gr collected 2026-09-25 09:50:15 UTC 113,471 bytes, 3,391 lines download raw bytes

1/* ----------------- Start Document ----------------- */
2(function ($) {
3  "use strict";
4
5  /*----------------------------------------------------*/
6  /*  Elementor Smooth Loading
7    /*----------------------------------------------------*/
8  $(document).ready(function () {
9    $(".main-search-container").after(
10      '<div class="search-banner-placeholder"><div class="search-banner-placeholder-loader"></div></div>'
11    );
12    setTimeout(function () {
13      $("body").addClass("theme-loaded");
14      $(".search-banner-placeholder").fadeOut();
15    }, 1100);
16  });
17
18  $(window).on("load", function () {
19    $("body").addClass("theme-loaded");
20    $(".search-banner-placeholder").fadeOut();
21  });
22
23  function starsOutput(
24    firstStar,
25    secondStar,
26    thirdStar,
27    fourthStar,
28    fifthStar
29  ) {
30    return (
31      "" +
32      '<span class="' +
33      firstStar +
34      '"></span>' +
35      '<span class="' +
36      secondStar +
37      '"></span>' +
38      '<span class="' +
39      thirdStar +
40      '"></span>' +
41      '<span class="' +
42      fourthStar +
43      '"></span>' +
44      '<span class="' +
45      fifthStar +
46      '"></span>'
47    );
48  }
49
50  $.fn.numericalRating = function () {
51    this.each(function () {
52      var dataRating = $(this).attr("data-rating");
53
54      // Rules
55      if (dataRating >= 4.0) {
56        $(this).addClass("high");
57      } else if (dataRating >= 3.0) {
58        $(this).addClass("mid");
59      } else if (dataRating < 3.0) {
60        $(this).addClass("low");
61      }
62    });
63  };
64
65  /*  Star Rating
66/*--------------------------*/
67  $.fn.starRating = function () {
68    this.each(function () {
69      var dataRating = $(this).attr("data-rating");
70      if (dataRating > 0) {
71        // Rating Stars Output
72
73        var fiveStars = starsOutput("star", "star", "star", "star", "star");
74
75        var fourHalfStars = starsOutput(
76          "star",
77          "star",
78          "star",
79          "star",
80          "star half"
81        );
82        var fourStars = starsOutput(
83          "star",
84          "star",
85          "star",
86          "star",
87          "star empty"
88        );
89
90        var threeHalfStars = starsOutput(
91          "star",
92          "star",
93          "star",
94          "star half",
95          "star empty"
96        );
97        var threeStars = starsOutput(
98          "star",
99          "star",
100          "star",
101          "star empty",
102          "star empty"
103        );
104
105        var twoHalfStars = starsOutput(
106          "star",
107          "star",
108          "star half",
109          "star empty",
110          "star empty"
111        );
112        var twoStars = starsOutput(
113          "star",
114          "star",
115          "star empty",
116          "star empty",
117          "star empty"
118        );
119
120        var oneHalfStar = starsOutput(
121          "star",
122          "star half",
123          "star empty",
124          "star empty",
125          "star empty"
126        );
127        var oneStar = starsOutput(
128          "star",
129          "star empty",
130          "star empty",
131          "star empty",
132          "star empty"
133        );
134
135        // Rules
136        if (dataRating >= 4.75) {
137          $(this).append(fiveStars);
138        } else if (dataRating >= 4.25) {
139          $(this).append(fourHalfStars);
140        } else if (dataRating >= 3.75) {
141          $(this).append(fourStars);
142        } else if (dataRating >= 3.25) {
143          $(this).append(threeHalfStars);
144        } else if (dataRating >= 2.75) {
145          $(this).append(threeStars);
146        } else if (dataRating >= 2.25) {
147          $(this).append(twoHalfStars);
148        } else if (dataRating >= 1.75) {
149          $(this).append(twoStars);
150        } else if (dataRating >= 1.25) {
151          $(this).append(oneHalfStar);
152        } else if (dataRating < 1.25) {
153          $(this).append(oneStar);
154        }
155      }
156    });
157  };
158})(jQuery);
159
160/* ----------------- Start Document ----------------- */
161(function ($) {
162  "use strict";
163
164  $(document).ready(function () {
165    /*--------------------------------------------------*/
166    /*  Mobile Menu
167	/*--------------------------------------------------*/
168    $(".mmenu-trigger, .menu-icon-toggle, .desktop-mmenu-trigger").on(
169      "click",
170      function (e) {
171        $("body").toggleClass("mobile-nav-open");
172        e.preventDefault();
173      }
174    );
175
176    $("#mobile-nav .sub-menu").prepend(
177      '<div class="sub-menu-back-btn">' + listeo.menu_back + "</div>"
178    );
179    $(function () {
180      $("#mobile-nav .menu-item-has-children > a").on("click", function (ea) {
181        ea.preventDefault();
182      });
183
184      var rwdMenu = $("#mobile-nav"),
185        topMenu = $("#mobile-nav > li > a"),
186        subMenu = $("#mobile-nav > li li > a"),
187        parentLi = $("#mobile-nav > li"),
188        parentSubLi = $("#mobile-nav > li li"),
189        backBtn = $(".sub-menu-back-btn");
190
191      topMenu.on("click", function (e) {
192        var thisTopMenu = $(this).parent(); // current $this
193
194        rwdMenu.addClass("rwd-menu-view");
195        thisTopMenu.addClass("open-submenu");
196      });
197
198      subMenu.on("click", function (e) {
199        var thisSubMenu = $(this).parent(); // current $this
200        thisSubMenu.addClass("open-submenu");
201      });
202
203      backBtn.click(function () {
204        var thisBackBtn = $(this);
205        $(this).parent().closest(".open-submenu").removeClass("open-submenu");
206        rwdMenu.removeClass("rwd-menu-view");
207      });
208
209      $(".menu-item-has-children a").on("click", function () {
210        var newHeight = $(this).parent().find(".sub-menu").height();
211        $(".mobile-navigation-list").animate({ height: newHeight }, 400);
212      });
213      $(".sub-menu-back-btn").on("click", function () {
214        var newHeighta = $(this).closest("li").parent().height();
215
216        $(".mobile-navigation-list").animate({ height: newHeighta }, 400);
217      });
218    });
219
220    $(".stars a")
221      .on("click", function () {
222        $(".stars a").removeClass("prevactive");
223        $(this).prevAll().addClass("prevactive");
224      })
225      .hover(
226        function () {
227          $(".stars a").removeClass("prevactive");
228          $(this).addClass("prevactive").prevAll().addClass("prevactive");
229        },
230        function () {
231          $(".stars a").removeClass("prevactive");
232          $(".stars a.active").prevAll().addClass("prevactive");
233        }
234      );
235
236    /*  User Menu */
237    // $("body").on("click", ".user-menu", function () {
238    //   $(this).toggleClass("active");
239    // });
240
241    // var user_mouse_is_inside = false;
242
243    // $("body").on("mouseenter", ".user-menu", function () {
244    //   user_mouse_is_inside = true;
245    // });
246    // $("body").on("mouseleave", ".user-menu", function () {
247    //   user_mouse_is_inside = false;
248    // });
249
250    // $("body").mouseup(function () {
251    //   if (!user_mouse_is_inside) $(".user-menu").removeClass("active");
252    // });
253
254    /*----------------------------------------------------*/
255    /*  Sticky Header
256	/*----------------------------------------------------*/
257    if ($("#header-container").hasClass("sticky-header")) {
258      $("#header")
259        .not("#header.not-sticky")
260        .clone(true)
261        .addClass("cloned unsticky")
262        .insertAfter("#header");
263      var reg_logo = $("#header.cloned #logo").data("logo-sticky");
264
265      $("#header.cloned #logo img").attr("src", reg_logo);
266
267      // sticky header script
268      var headerOffset = 100; // height on which the sticky header will shows
269
270      $(window).scroll(function () {
271        if ($(window).scrollTop() > headerOffset) {
272          $("#header.cloned").addClass("sticky").removeClass("unsticky");
273          $("#navigation.style-2.cloned")
274            .addClass("sticky")
275            .removeClass("unsticky");
276        } else {
277          $("#header.cloned").addClass("unsticky").removeClass("sticky");
278          $("#navigation.style-2.cloned")
279            .addClass("unsticky")
280            .removeClass("sticky");
281        }
282      });
283    }
284
285    $(document.body).on("added_to_cart", function () {
286      $("body").addClass("listeo_adding_to_cart");
287      setTimeout(function () {
288        $("body").removeClass("listeo_adding_to_cart");
289      }, 2000);
290    });
291
292    $(document).ready(function () {
293      // Function to update margin-top for .hws-container and padding-top for #wrapper
294      function updateMarginsAndPadding() {
295        var hwsWrapperHeight = $(".hws-wrapper").outerHeight();
296        var adminBarHeight = $("#wpadminbar").outerHeight() || 0; // Consider admin bar height or default to 0
297
298        // Add adminBarHeight as margin-top to .hws-container
299        $(".hws-wrapper").css("margin-top", adminBarHeight + "px");
300
301        // Update padding-top for #wrapper
302        $("#wrapper").css("padding-top", hwsWrapperHeight + "px");
303      }
304
305      // Run the function on document ready
306      updateMarginsAndPadding();
307
308      // Run the function when the window is resized
309      $(window).resize(function () {
310        updateMarginsAndPadding();
311      });
312    });
313    $(document).ready(function () {
314      // Function to check window width and remove class
315      function checkWindowWidth() {
316        var windowWidth = $(window).width();
317
318        if (windowWidth < 1024) {
319          $(".hws-wrapper .main-search-form").removeClass("gray-style");
320        } else {
321          $(".hws-wrapper .main-search-form").addClass("gray-style");
322        }
323      }
324
325      // Initial check on page load
326      checkWindowWidth();
327
328      // Listen for window resize events
329      $(window).resize(function () {
330        // Recheck window width on resize
331        checkWindowWidth();
332      });
333    });
334
335    $(document).ready(function () {
336      // Function to log current padding on #header
337      function logHeaderPadding() {
338        var currentPadding = $("#header").css("padding-top");
339        return parseInt(currentPadding, 10) || 0;
340      }
341
342      // Initial log on page load
343      logHeaderPadding();
344
345      // Listen for window resize events
346      $(window).resize(function () {
347        logHeaderPadding();
348      });
349
350      // Function to set top attribute based on header height below 1200px
351      function setTopAttribute() {
352        var windowWidth = $(window).width();
353
354        if (windowWidth < 1200) {
355          var headerHeight =
356            $("#header-container.hws-wrapper #header").outerHeight() -
357            logHeaderPadding();
358          $(".header-search-container").css("top", headerHeight + "px");
359        } else {
360          // Reset top attribute if window width is 1200px or above
361          $(".header-search-container").css("top", "");
362        }
363      }
364
365      // Initial set on page load
366      setTopAttribute();
367
368      // Listen for window resize events
369      $(window).resize(function () {
370        // Re-set top attribute on resize
371        setTopAttribute();
372      });
373    });
374
375    $(document).ready(function () {
376      // Add click event listener to .mobile-search-trigger
377      $(".mobile-search-trigger").on("click", function () {
378        // Toggle the visibility by adding/removing the .visible class
379        $(".header-search-container").toggleClass("visible");
380        $(this).toggleClass("visible");
381      });
382    });
383
384    /*----------------------------------------------------*/
385    /*  Back to Top
386	/*----------------------------------------------------*/
387    var pxShow = 600; // height on which the button will show
388    var scrollSpeed = 500; // how slow / fast you want the button to scroll to top.
389
390    $(window).scroll(function () {
391      if ($(window).scrollTop() >= pxShow) {
392        $("#backtotop").addClass("visible");
393      } else {
394        $("#backtotop").removeClass("visible");
395      }
396    });
397
398    $("#backtotop a").on("click", function () {
399      $("html, body").animate({ scrollTop: 0 }, scrollSpeed);
400      return false;
401    });
402
403    /*----------------------------------------------------*/
404    /*  Inline CSS replacement for backgrounds etc.
405	/*----------------------------------------------------*/
406    function inlineCSS() {
407      // Common Inline CSS
408      $(
409        ".main-search-container, section.fullwidth, .listing-slider .item, .listing-slider-small .item, .address-container, .img-box-background, .image-edge, .edge-bg"
410      ).each(function () {
411        var attrImageBG = $(this).attr("data-background-image");
412        var attrColorBG = $(this).attr("data-background-color");
413
414        if (attrImageBG !== undefined) {
415          $(this).css("background-image", "url(" + attrImageBG + ")");
416        }
417
418        if (attrColorBG !== undefined) {
419          $(this).css("background", "" + attrColorBG + "");
420        }
421      });
422    }
423
424    // Init
425    inlineCSS();
426
427    function parallaxBG() {
428      $(".parallax,.vc_parallax").prepend(
429        '<div class="parallax-overlay"></div>'
430      );
431
432      $(".parallax,.vc_parallax").each(function () {
433        var attrImage = $(this).attr("data-background");
434        var attrColor = $(this).attr("data-color");
435        var attrOpacity = $(this).attr("data-color-opacity");
436
437        if (attrImage !== undefined) {
438          $(this).css("background-image", "url(" + attrImage + ")");
439        }
440
441        if (attrColor !== undefined) {
442          $(this)
443            .find(".parallax-overlay")
444            .css("background-color", "" + attrColor + "");
445        }
446
447        if (attrOpacity !== undefined) {
448          $(this)
449            .find(".parallax-overlay")
450            .css("opacity", "" + attrOpacity + "");
451        }
452      });
453    }
454
455    parallaxBG();
456
457    /*----------------------------------------------------*/
458    /*  Image Box
459    /*----------------------------------------------------*/
460    $(".category-box").each(function () {
461      // add a photo container
462      $(this).append('<div class="category-box-background"></div>');
463
464      // set up a background image for each tile based on data-background-image attribute
465      $(this)
466        .children(".category-box-background")
467        .css({
468          "background-image":
469            "url(" + $(this).attr("data-background-image") + ")",
470        });
471    });
472    window.initializeSliders = function () {
473      $(".listing-card-nl").each(function () {
474        const $card = $(this);
475
476        // Skip if already initialized
477        if ($card.data("slider-initialized")) return;
478
479        const $sliderWrapper = $card.find(".slider-wrapper-nl");
480        const $slides = $card.find(".slider-image-nl");
481        let currentIndex = 0;
482
483        // Hide arrows if there's only one image
484        if ($slides.length <= 1) {
485          $card.find(".slider-arrow-nl").hide();
486        } else {
487          $card.find(".slider-arrow-nl").show();
488        }
489
490        function updateSlider() {
491          if ($slides.length === 0) return;
492          const slideWidth = $slides.first().width();
493          $sliderWrapper.css(
494            "transform",
495            `translateX(${-currentIndex * slideWidth}px)`
496          );
497        }
498
499        // Next button click
500        $card
501          .find("#nextBtn")
502          .off("click")
503          .on("click", function () {
504            currentIndex = (currentIndex + 1) % $slides.length;
505            updateSlider();
506          });
507
508        // Previous button click
509        $card
510          .find("#prevBtn")
511          .off("click")
512          .on("click", function () {
513            currentIndex = (currentIndex - 1 + $slides.length) % $slides.length;
514            updateSlider();
515          });
516
517        // Mark as initialized
518        $card.data("slider-initialized", true);
519$card.data("updateSlider", updateSlider);
520$card.data("currentIndex", currentIndex);
521$card.data("slidesLength", $slides.length);
522        // Initialize slider
523        updateSlider();
524      });
525    };
526
527    $(document).ready(function () {
528      initializeSliders();
529    });
530
531    // Listen for custom event from AJAX calls
532    $(document).on("ajaxContentLoaded", function () {
533      initializeSliders();
534    });
535
536    // Function to reset all sliders to first slide
537    window.resetSlidersToFirst = function () {
538      $(".listing-card-nl").each(function () {
539        const $card = $(this);
540        const updateSlider = $card.data("updateSlider");
541
542        if (updateSlider) {
543          // Reset to first slide
544          $card.data("currentIndex", 0);
545          updateSlider();
546        }
547      });
548    };
549    /*----------------------------------------------------*/
550    /*  Image Box
551    /*----------------------------------------------------*/
552    $(".img-box").each(function () {
553      $(this).append('<div class="img-box-background"></div>');
554      $(this)
555        .children(".img-box-background")
556        .css({
557          "background-image":
558            "url(" + $(this).attr("data-background-image") + ")",
559        });
560    });
561
562    /*----------------------------------------------------*/
563    /*  Parallax
564	/*----------------------------------------------------*/
565
566    /* detect touch */
567    if ("ontouchstart" in window) {
568      document.documentElement.className =
569        document.documentElement.className + " touch";
570    }
571    if (!$("html").hasClass("touch")) {
572      /* background fix */
573      $(".parallax").css("background-attachment", "fixed");
574    }
575
576    /* fix vertical when not overflow
577	call fullscreenFix() if .fullscreen content changes */
578    function fullscreenFix() {
579      var h = $("body").height();
580      // set .fullscreen height
581      $(".content-b").each(function (i) {
582        if ($(this).innerHeight() > h) {
583          $(this).closest(".fullscreen").addClass("overflow");
584        }
585      });
586    }
587    $(window).resize(fullscreenFix);
588    fullscreenFix();
589
590    /* resize background images */
591    function backgroundResize() {
592      var windowH = $(window).height();
593      $(".parallax").each(function (i) {
594        var path = $(this);
595        // variables
596        var contW = path.width();
597        var contH = path.height();
598        var imgW = path.attr("data-img-width");
599        var imgH = path.attr("data-img-height");
600        var ratio = imgW / imgH;
601        // overflowing difference
602        var diff = 100;
603        diff = diff ? diff : 0;
604        // remaining height to have fullscreen image only on parallax
605        var remainingH = 0;
606        if (path.hasClass("parallax") && !$("html").hasClass("touch")) {
607          //var maxH = contH > windowH ? contH : windowH;
608          remainingH = windowH - contH;
609        }
610        // set img values depending on cont
611        imgH = contH + remainingH + diff;
612        imgW = imgH * ratio;
613        // fix when too large
614        if (contW > imgW) {
615          imgW = contW;
616          imgH = imgW / ratio;
617        }
618        //
619        path.data("resized-imgW", imgW);
620        path.data("resized-imgH", imgH);
621        path.css("background-size", imgW + "px " + imgH + "px");
622      });
623    }
624
625    $(window).resize(backgroundResize);
626    $(window).focus(backgroundResize);
627    backgroundResize();
628
629    /* set parallax background-position */
630    function parallaxPosition(e) {
631      var heightWindow = $(window).height();
632      var topWindow = $(window).scrollTop();
633      var bottomWindow = topWindow + heightWindow;
634      var currentWindow = (topWindow + bottomWindow) / 2;
635      $(".parallax").each(function (i) {
636        var path = $(this);
637        var height = path.height();
638        var top = path.offset().top;
639        var bottom = top + height;
640        // only when in range
641        if (bottomWindow > top && topWindow < bottom) {
642          //var imgW = path.data("resized-imgW");
643          var imgH = path.data("resized-imgH");
644          // min when image touch top of window
645          var min = 0;
646          // max when image touch bottom of window
647          var max = -imgH + heightWindow;
648          // overflow changes parallax
649          var overflowH =
650            height < heightWindow ? imgH - height : imgH - heightWindow; // fix height on overflow
651          top = top - overflowH;
652          bottom = bottom + overflowH;
653
654          // value with linear interpolation
655          var value = 0;
656          if ($(".parallax").is(".titlebar")) {
657            value =
658              min +
659              (((max - min) * (currentWindow - top)) / (bottom - top)) * 2;
660          } else {
661            value =
662              min + ((max - min) * (currentWindow - top)) / (bottom - top);
663          }
664
665          // set background-position
666          var orizontalPosition = path.attr("data-oriz-pos");
667          orizontalPosition = orizontalPosition ? orizontalPosition : "50%";
668          $(this).css(
669            "background-position",
670            orizontalPosition + " " + value + "px"
671          );
672        }
673      });
674    }
675    if (!$("html").hasClass("touch")) {
676      $(window).resize(parallaxPosition);
677      $(window).scroll(parallaxPosition);
678      parallaxPosition();
679    }
680
681    // Jumping background fix for IE
682    if (navigator.userAgent.match(/Trident\/7\./)) {
683      // if IE
684      $("body").on("mousewheel", function () {
685        event.preventDefault();
686
687        var wheelDelta = event.wheelDelta;
688        var currentScrollPosition = window.pageYOffset;
689        window.scrollTo(0, currentScrollPosition - wheelDelta);
690      });
691    }
692
693    // Single Select
694    $(".dokan-store-products-filter-area select").select2({
695      dropdownPosition: "below",
696      dropdownParent: $(".dokan-store-products-ordeby-select"),
697      minimumResultsForSearch: 20,
698      width: "100%",
699      placeholder: $(this).data("placeholder"),
700      language: {
701        noResults: function (term) {
702          return listeo_core.no_results_text;
703        },
704      },
705    });
706    $(
707      ".select2-single,.woocommerce-ordering select,.dokan-form-group select,#stores_orderby"
708    ).select2({
709      dropdownPosition: "below",
710
711      minimumResultsForSearch: 20,
712      width: "100%",
713      placeholder: $(this).data("placeholder"),
714      language: {
715        noResults: function (term) {
716          return listeo_core.no_results_text;
717        },
718      },
719    });
720
721    // Multiple Select
722 function initializeSelect2($context = $(document)) {
723   $context.find(".select2-multiple").each(function () {
724     // Prevent double init
725     if (!$(this).hasClass("select2-hidden-accessible")) {
726       $(this).select2({
727         dropdownPosition: "below",
728         width: "100%",
729         placeholder: $(this).data("placeholder"),
730         language: {
731           noResults: function () {
732             return listeo_core.no_results_text;
733           },
734         },
735       });
736     }
737   });
738 }
739 initializeSelect2();
740
741    $(".main-search-inner .select2-single").select2({
742      minimumResultsForSearch: 20,
743      dropdownPosition: "below",
744
745      width: "100%",
746      //placeholder: $(this).data('placeholder'),
747      dropdownParent: $(".main-search-input"),
748      language: {
749        noResults: function (term) {
750          return listeo_core.no_results_text;
751        },
752      },
753    });
754
755    // Multiple Select
756    $(".main-search-inner .select2-multiple").each(function () {
757      $(this).select2({
758        width: "100%",
759        dropdownPosition: "below",
760        placeholder: $(this).data("placeholder"),
761        dropdownParent: $(".main-search-input"),
762        language: {
763          noResults: function (term) {
764            return listeo_core.no_results_text;
765          },
766        },
767      });
768    });
769
770    // Select on Home Search Bar
771    $(".select2-sortby").select2({
772      dropdownParent: $(".sort-by"),
773      minimumResultsForSearch: 20,
774      width: "100%",
775      dropdownPosition: "below",
776      placeholder: $(this).data("placeholder"),
777      language: {
778        noResults: function (term) {
779          return listeo_core.no_results_text;
780        },
781      },
782    });
783    // Select on Home Search Bar
784    $(".select2-bookings").select2({
785      dropdownParent: $(".sort-by"),
786      minimumResultsForSearch: 20,
787      width: "100%",
788      dropdownPosition: "below",
789      placeholder: $(this).data("placeholder"),
790      language: {
791        noResults: function (term) {
792          return listeo_core.no_results_text;
793        },
794      },
795    });
796    $(".select2-bookings-status").select2({
797      dropdownParent: $(".sort-by-status"),
798      minimumResultsForSearch: 20,
799      width: "100%",
800      dropdownPosition: "below",
801      placeholder: $(this).data("placeholder"),
802      language: {
803        noResults: function (term) {
804          return listeo_core.no_results_text;
805        },
806      },
807    });
808    $(".select2-bookings-author").select2({
809      dropdownParent: $(".sort-by-booking-author"),
810      minimumResultsForSearch: 20,
811      //   dropdownAutoWidth: true,
812      dropdownPosition: "below",
813      placeholder: $(this).data("placeholder"),
814      language: {
815        noResults: function (term) {
816          return listeo_core.no_results_text;
817        },
818      },
819    });
820
821    $("selectpicker-bts").selectpicker();
822
823    /*----------------------------------------------------*/
824    /*  Magnific Popup
825    /*----------------------------------------------------*/
826
827    $(".mfp-gallery-container").each(function () {
828      // the containers for all your galleries
829
830      $(this).magnificPopup({
831        type: "image",
832        delegate: "a.mfp-gallery",
833
834        fixedContentPos: true,
835        fixedBgPos: true,
836
837        overflowY: "auto",
838
839        closeBtnInside: false,
840        preloader: true,
841
842        removalDelay: 0,
843        mainClass: "mfp-fade",
844
845        gallery: { enabled: true, tCounter: "" },
846      });
847    });
848
849    var listing_gallery_grid_popup;
850    $("#single-listing-grid-gallery-popup").on("click", function (e) {
851      e.preventDefault();
852
853      // Get the JSON-encoded data from the data attribute
854      var imageData = $(this).data("gallery");
855
856      // Create an array to hold the gallery items
857      var items = [];
858
859      // Loop through the JSON data and create Magnific Popup items
860      $.each(imageData, function (index, image) {
861        console.log(image);
862        items.push({
863          src: image,
864          //title: image.title,
865        });
866      });
867
868      // Open Magnific Popup with the gallery items
869      $.magnificPopup.open({
870        items: items,
871        type: "image", // Specify the type of content (image, iframe, inline, etc.)
872        fixedContentPos: true,
873        fixedBgPos: true,
874
875        overflowY: "auto",
876
877        closeBtnInside: false,
878        preloader: true,
879
880        removalDelay: 0,
881        mainClass: "mfp-fade",
882
883        gallery: { enabled: true, tCounter: "" },
884      });
885      listing_gallery_grid_popup = $.magnificPopup.instance;
886    });
887
888    $("a.slg-gallery-img").on("click", function (e) {
889      e.preventDefault();
890      $("#single-listing-grid-gallery-popup").trigger("click");
891      var index = $(this).data("grid-start-index");
892      listing_gallery_grid_popup.goTo(index);
893    });
894    // $("#single-listing-grid-gallery").magnificPopup({
895    //   type: "image",
896    //   delegate: "a.slg-gallery-img",
897    //   fixedContentPos: true,
898    // });
899    $(".popup-with-zoom-anim").magnificPopup({
900      type: "inline",
901
902      fixedContentPos: false,
903      fixedBgPos: true,
904
905      overflowY: "auto",
906
907      closeBtnInside: true,
908      preloader: false,
909
910      midClick: true,
911      removalDelay: 300,
912      mainClass: "my-mfp-zoom-in",
913      
914      callbacks: {
915        open: function() {
916          // Handle Turnstile widgets when popup opens
917          if (typeof turnstile !== 'undefined') {
918            // Find Turnstile widgets in the opened popup
919            $($.magnificPopup.instance.content).find('.cf-turnstile').each(function() {
920              var element = this;
921              var sitekey = $(element).data('sitekey');
922              
923              if (sitekey) {
924                // Clear any existing content first
925                $(element).empty().removeClass('turnstile-rendered');
926                
927                // Render the widget
928                turnstile.render(element, {
929                  sitekey: sitekey
930                });
931                $(element).addClass('turnstile-rendered');
932              }
933            });
934          }
935        }
936      }
937    });
938
939    $(".mfp-image").magnificPopup({
940      type: "image",
941      closeOnContentClick: true,
942      mainClass: "mfp-fade",
943      image: {
944        verticalFit: true,
945      },
946      zoom: {
947        enabled: true, // By default it's false, so don't forget to enable it
948
949        duration: 300, // duration of the effect, in milliseconds
950        easing: "ease-in-out", // CSS transition easing function
951
952        // The "opener" function should return the element from which popup will be zoomed in
953        // and to which popup will be scaled down
954        // By defailt it looks for an image tag:
955        opener: function (openerElement) {
956          // openerElement is the element on which popup was initialized, in this case its <a> tag
957          // you don't need to add "opener" option if this code matches your needs, it's defailt one.
958          return openerElement.is("img")
959            ? openerElement
960            : openerElement.find("img");
961        },
962      },
963    });
964
965    $(".popup-youtube, .popup-vimeo, .popup-gmaps").magnificPopup({
966      disableOn: 700,
967      type: "iframe",
968      mainClass: "mfp-fade",
969      removalDelay: 160,
970      preloader: false,
971
972      fixedContentPos: false,
973    });
974
975    /*----------------------------------------------------*/
976    /*  Slick Carousel
977    /*----------------------------------------------------*/
978
979    // New Carousel Nav With Arrows
980    $(
981      ".home-search-carousel, .simple-slick-carousel, .simple-fw-slick-carousel, .testimonial-carousel, .fullwidth-slick-carousel, .fullgrid-slick-carousel,.reviews-slick-carousel"
982    ).append(
983      "" +
984        "<div class='slider-controls-container'>" +
985        "<div class='slider-controls'>" +
986        "<button type='button' class='slide-m-prev'></button>" +
987        "<div class='slide-m-dots'></div>" +
988        "<button type='button' class='slide-m-next'></button>" +
989        "</div>" +
990        "</div>"
991    );
992
993    // New Homepage Carousel
994    $(".home-search-carousel").each(function () {
995      $(this).slick({
996        slide: ".home-search-slide",
997        centerMode: true,
998        //   autoplay: true,
999        // autoplaySpeed: 2000,
1000        centerPadding: "15%",
1001        slidesToShow: 1,
1002        dots: true,
1003        arrows: true,
1004        appendDots: $(this).find(".slide-m-dots"),
1005        prevArrow: $(this).find(".slide-m-prev"),
1006        nextArrow: $(this).find(".slide-m-next"),
1007
1008        responsive: [
1009          {
1010            breakpoint: 1940,
1011            settings: {
1012              centerPadding: "13%",
1013              slidesToShow: 1,
1014            },
1015          },
1016          {
1017            breakpoint: 1640,
1018            settings: {
1019              centerPadding: "8%",
1020              slidesToShow: 1,
1021            },
1022          },
1023          {
1024            breakpoint: 1430,
1025            settings: {
1026              centerPadding: "50px",
1027              slidesToShow: 1,
1028            },
1029          },
1030          {
1031            breakpoint: 1370,
1032            settings: {
1033              centerPadding: "20px",
1034              slidesToShow: 1,
1035            },
1036          },
1037          {
1038            breakpoint: 767,
1039            settings: {
1040              centerPadding: "20px",
1041              slidesToShow: 1,
1042            },
1043          },
1044        ],
1045      });
1046    });
1047    // New Homepage Carousel Positioning
1048    if (document.readyState == "complete") {
1049      init7Slider();
1050    }
1051
1052    function init7Slider() {
1053      $(".home-search-slider-headlines").each(function () {
1054        var carouselHeadlineHeight = $(this).height();
1055        $(this).css("padding-bottom", carouselHeadlineHeight + 30);
1056      });
1057      $(".home-search-carousel").removeClass("carousel-not-ready");
1058      $(".home-search-carousel-placeholder").addClass("carousel-ready");
1059
1060      if ($(window).width() < 992) {
1061        $(".home-search-slider-headlines").each(function () {
1062          $(this).css("bottom", $(".main-search-input").height() + 65);
1063        });
1064      }
1065    }
1066    $(window).on("load", function () {
1067      init7Slider();
1068    });
1069    $(window).on("load resize", function () {
1070      if ($(window).width() < 992) {
1071        $(".home-search-slider-headlines").each(function () {
1072          $(this).css("bottom", $(".main-search-input").height() + 65);
1073        });
1074      }
1075    });
1076
1077    $(".fullwidth-slick-carousel").each(function () {
1078      $(this).slick({
1079        centerMode: true,
1080        centerPadding: "20%",
1081        slidesToShow: 3,
1082        dots: true,
1083        arrows: true,
1084        slide: ".fw-carousel-item",
1085        appendDots: $(this).find(".slide-m-dots"),
1086        prevArrow: $(this).find(".slide-m-prev"),
1087        nextArrow: $(this).find(".slide-m-next"),
1088        responsive: [
1089          {
1090            breakpoint: 1920,
1091            settings: {
1092              centerPadding: "15%",
1093              slidesToShow: 3,
1094            },
1095          },
1096          {
1097            breakpoint: 1441,
1098            settings: {
1099              centerPadding: "10%",
1100              slidesToShow: 3,
1101            },
1102          },
1103          {
1104            breakpoint: 1025,
1105            settings: {
1106              centerPadding: "10px",
1107              slidesToShow: 2,
1108            },
1109          },
1110          {
1111            breakpoint: 767,
1112            settings: {
1113              centerPadding: "10px",
1114              slidesToShow: 1,
1115            },
1116          },
1117        ],
1118      });
1119    });
1120    $(".fullgrid-slick-carousel").each(function () {
1121      $(this).slick({
1122        centerMode: true,
1123        centerPadding: "20%",
1124        slidesToShow: 2,
1125        dots: true,
1126        arrows: true,
1127        slide: ".fw-carousel-item",
1128        appendDots: $(this).find(".slide-m-dots"),
1129        prevArrow: $(this).find(".slide-m-prev"),
1130        nextArrow: $(this).find(".slide-m-next"),
1131        responsive: [
1132          {
1133            breakpoint: 1920,
1134            settings: {
1135              centerPadding: "15%",
1136              slidesToShow: 2,
1137            },
1138          },
1139          {
1140            breakpoint: 1441,
1141            settings: {
1142              centerPadding: "10%",
1143              slidesToShow: 2,
1144            },
1145          },
1146          {
1147            breakpoint: 1025,
1148            settings: {
1149              centerPadding: "10px",
1150              slidesToShow: 2,
1151            },
1152          },
1153          {
1154            breakpoint: 767,
1155            settings: {
1156              centerPadding: "10px",
1157              slidesToShow: 1,
1158            },
1159          },
1160        ],
1161      });
1162    });
1163    $(".reviews-slick-carousel").each(function () {
1164      $(this).slick({
1165        centerMode: true,
1166        centerPadding: "0%",
1167        slidesToShow: 5,
1168        dots: true,
1169        arrows: true,
1170        slide: ".fw-carousel-item",
1171        appendDots: $(this).find(".slide-m-dots"),
1172        prevArrow: $(this).find(".slide-m-prev"),
1173        nextArrow: $(this).find(".slide-m-next"),
1174        responsive: [
1175          {
1176            breakpoint: 1920,
1177            settings: {
1178              centerPadding: "0%",
1179              slidesToShow: 4,
1180            },
1181          },
1182          {
1183            breakpoint: 1441,
1184            settings: {
1185              centerPadding: "0%",
1186              slidesToShow: 3,
1187            },
1188          },
1189          {
1190            breakpoint: 1025,
1191            settings: {
1192              centerPadding: "0px",
1193              slidesToShow: 2,
1194            },
1195          },
1196          {
1197            breakpoint: 767,
1198            settings: {
1199              centerPadding: "0px",
1200              slidesToShow: 1,
1201            },
1202          },
1203        ],
1204      });
1205    });
1206
1207    $(".general-carousel").each(function () {
1208      var slides = $(this).data("slides");
1209
1210      if (!slides) {
1211        slides = 3;
1212      }
1213      $(this).slick({
1214        //  centerMode: true,
1215
1216        slidesToShow: slides,
1217        dots: false,
1218        arrows: true,
1219
1220        appendDots: $(this).find(".slide-m-dots"),
1221        prevArrow: $(this).find(".slide-m-prev"),
1222        nextArrow: $(this).find(".slide-m-next"),
1223      });
1224    });
1225
1226    $(".testimonial-carousel").each(function () {
1227      $(this).slick({
1228        centerMode: true,
1229        centerPadding: "34%",
1230        slidesToShow: 1,
1231        dots: true,
1232        arrows: true,
1233        slide: ".fw-carousel-review",
1234        appendDots: $(this).find(".slide-m-dots"),
1235        prevArrow: $(this).find(".slide-m-prev"),
1236        nextArrow: $(this).find(".slide-m-next"),
1237        responsive: [
1238          {
1239            breakpoint: 1025,
1240            settings: {
1241              centerPadding: "10px",
1242              slidesToShow: 2,
1243            },
1244          },
1245          {
1246            breakpoint: 767,
1247            settings: {
1248              centerPadding: "10px",
1249              slidesToShow: 1,
1250            },
1251          },
1252        ],
1253      });
1254    });
1255
1256    $(".listing-slider").slick({
1257      centerMode: true,
1258      centerPadding: "20%",
1259      slidesToShow: 2,
1260      responsive: [
1261        {
1262          breakpoint: 1367,
1263          settings: {
1264            centerPadding: "15%",
1265          },
1266        },
1267        {
1268          breakpoint: 1025,
1269          settings: {
1270            centerPadding: "0",
1271          },
1272        },
1273        {
1274          breakpoint: 767,
1275          settings: {
1276            centerPadding: "0",
1277            slidesToShow: 1,
1278          },
1279        },
1280      ],
1281    });
1282    $(".widget-listing-slider").slick({
1283      dots: true,
1284      infinite: true,
1285      arrows: false,
1286      slidesToShow: 1,
1287    });
1288
1289    $(".listing-slider-small").slick({
1290      centerMode: true,
1291      centerPadding: "0",
1292      slidesToShow: 3,
1293      responsive: [
1294        {
1295          breakpoint: 767,
1296          settings: {
1297            slidesToShow: 1,
1298          },
1299        },
1300      ],
1301    });
1302
1303    $(".simple-slick-carousel").each(function () {
1304      var slides = $(this).data("slides");
1305
1306      if (!slides) {
1307        slides = 3;
1308      }
1309      if ($("body").hasClass("page-template-template-dashboard")) {
1310        slides = 4;
1311      }
1312      $(this)
1313        .slick({
1314          infinite: true,
1315          slidesToShow: slides,
1316          slidesToScroll: 3,
1317          slide: ".fw-carousel-item",
1318          dots: true,
1319          arrows: true,
1320          appendDots: $(this).find(".slide-m-dots"),
1321          prevArrow: $(this).find(".slide-m-prev"),
1322          nextArrow: $(this).find(".slide-m-next"),
1323          responsive: [
1324            {
1325              breakpoint: 1220,
1326              settings: {
1327                slidesToShow: 2,
1328                slidesToScroll: 2,
1329              },
1330            },
1331            {
1332              breakpoint: 769,
1333              settings: {
1334                slidesToShow: 1,
1335                slidesToScroll: 1,
1336              },
1337            },
1338          ],
1339        })
1340        .on("init", function (e, slick) {});
1341      // 		console.log(slick);
1342      //slideautplay = $('div[data-slick-index="'+ slick.currentSlide + '"]').data("time");
1343      //$s.slick("setOption", "autoplaySpeed", slideTime);
1344    });
1345
1346    $(".simple-fw-slick-carousel").each(function () {
1347      var slides = $(this).data("slides");
1348
1349      if (!slides) {
1350        slides = 5;
1351      }
1352      $(this)
1353        .slick({
1354          infinite: true,
1355          slidesToShow: slides,
1356          slidesToScroll: 1,
1357          dots: true,
1358          arrows: true,
1359          slide: ".fw-carousel-item",
1360          appendDots: $(this).find(".slide-m-dots"),
1361          prevArrow: $(this).find(".slide-m-prev"),
1362          nextArrow: $(this).find(".slide-m-next"),
1363          responsive: [
1364            {
1365              breakpoint: 1610,
1366              settings: {
1367                slidesToShow: 4,
1368              },
1369            },
1370            {
1371              breakpoint: 1365,
1372              settings: {
1373                slidesToShow: 3,
1374              },
1375            },
1376            {
1377              breakpoint: 1024,
1378              settings: {
1379                slidesToShow: 2,
1380              },
1381            },
1382            {
1383              breakpoint: 767,
1384              settings: {
1385                slidesToShow: 1,
1386              },
1387            },
1388          ],
1389        })
1390        .on("init", function (e, slick) {
1391          //slideautplay = $('div[data-slick-index="'+ slick.currentSlide + '"]').data("time");
1392          //$s.slick("setOption", "autoplaySpeed", slideTime);
1393        });
1394    });
1395
1396    $(".logo-slick-carousel").slick({
1397      infinite: true,
1398      slidesToShow: 5,
1399      slidesToScroll: 4,
1400      dots: true,
1401      arrows: true,
1402      responsive: [
1403        {
1404          breakpoint: 992,
1405          settings: {
1406            slidesToShow: 3,
1407            slidesToScroll: 3,
1408          },
1409        },
1410        {
1411          breakpoint: 769,
1412          settings: {
1413            slidesToShow: 1,
1414            slidesToScroll: 1,
1415          },
1416        },
1417      ],
1418    });
1419
1420    // Fix for carousel if there are less than 4 categories
1421    $(window).on("load resize", function (e) {
1422      var carouselListItems = $(
1423        ".fullwidth-slick-carousel .fw-carousel-item"
1424      ).length;
1425      if (carouselListItems < 4) {
1426        $(".fullwidth-slick-carousel .slick-slide").css({
1427          "pointer-events": "all",
1428          opacity: "1",
1429        });
1430      }
1431    });
1432
1433    // Mobile fix for small listing slider
1434    $(window).on("load resize", function (e) {
1435      var carouselListItems = $(".listing-slider-small .slick-track").children()
1436        .length;
1437      if (carouselListItems < 2) {
1438        $(".listing-slider-small .slick-track").css({
1439          transform: "none",
1440        });
1441      }
1442    });
1443    if (navigator.userAgent.indexOf("Firefox") != -1) {
1444      $(document).ready(function () {
1445        $(
1446          ".home-search-carousel,.logo-slick-carousel,.simple-fw-slick-carousel,.listing-slider-small,.listing-slider,.testimonial-carousel,.fullwidth-slick-carousel,.fullgrid-slick-carousel,.reviews-slick-carousel"
1447        ).slick("refresh");
1448      });
1449    }
1450
1451    // Number Picker - TobyJ
1452    (function ($) {
1453      $.fn.numberPicker = function () {
1454        var dis = "disabled";
1455        return this.each(function () {
1456          var picker = $(this),
1457            p = picker.find("button:last-child"),
1458            m = picker.find("button:first-child"),
1459            input = picker.find("input"),
1460            min = parseInt(input.attr("min"), 10),
1461            max = parseInt(input.attr("max"), 10),
1462            inputFunc = function (picker) {
1463              var i = parseInt(input.val(), 10);
1464              if (i <= min || !i) {
1465                input.val(min);
1466                p.prop(dis, false);
1467                m.prop(dis, true);
1468              } else if (i >= max) {
1469                input.val(max);
1470                p.prop(dis, true);
1471                m.prop(dis, false);
1472              } else {
1473                p.prop(dis, false);
1474                m.prop(dis, false);
1475              }
1476            },
1477            changeFunc = function (picker, qty) {
1478              var q = parseInt(qty, 10),
1479                i = parseInt(input.val(), 10);
1480              if ((i < max && q > 0) || (i > min && !(q > 0))) {
1481                input.val(i + q);
1482                inputFunc(picker);
1483              }
1484            };
1485          m.on("click", function (e) {
1486            e.preventDefault();
1487            changeFunc(picker, -1);
1488          });
1489          p.on("click", function (e) {
1490            e.preventDefault();
1491            changeFunc(picker, 1);
1492          });
1493          input.on("change", function () {
1494            inputFunc(picker);
1495          });
1496          inputFunc(picker); //init
1497        });
1498      };
1499    })(jQuery);
1500
1501    // Init
1502    $(".plusminus").numberPicker();
1503
1504    /*----------------------------------------------------*/
1505    /*  Tabs
1506	/*----------------------------------------------------*/
1507
1508    var $tabsNav = $(".tabs-nav"),
1509      $tabsNavLis = $tabsNav.children("li");
1510
1511    $tabsNav.each(function () {
1512      var $this = $(this);
1513
1514      $this
1515        .next()
1516        .children(".tab-content")
1517        .stop(true, true)
1518        .hide()
1519        .first()
1520        .show();
1521
1522      $this.children("li").first().addClass("active").stop(true, true).show();
1523    });
1524
1525    $tabsNavLis.on("click", function (e) {
1526      var $this = $(this);
1527
1528      $this.siblings().removeClass("active").end().addClass("active");
1529
1530      $this
1531        .parent()
1532        .next()
1533        .children(".tab-content")
1534        .stop(true, true)
1535        .hide()
1536        .siblings($this.find("a").attr("href"))
1537        .fadeIn();
1538
1539      e.preventDefault();
1540    });
1541    var hash = window.location.hash;
1542    var anchor = $('.tabs-nav a[href="' + hash + '"]');
1543    if (anchor.length === 0) {
1544      $(".tabs-nav li:first").addClass("active").show(); //Activate first tab
1545      $(".tab-content:first").show(); //Show first tab content
1546    } else {
1547      anchor.parent("li").click();
1548    }
1549
1550    /*----------------------------------------------------*/
1551    /*  Accordions
1552	/*----------------------------------------------------*/
1553    var $accor = $(".accordion");
1554
1555    $accor.each(function () {
1556      $(this).toggleClass("ui-accordion ui-widget ui-helper-reset");
1557      $(this)
1558        .find("h3")
1559        .addClass(
1560          "ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-corner-all"
1561        );
1562      $(this)
1563        .find("div")
1564        .addClass(
1565          "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"
1566        );
1567      $(this).find("div").hide();
1568    });
1569
1570    var $trigger = $accor.find("h3");
1571
1572    $trigger.on("click", function (e) {
1573      var location = $(this).parent();
1574
1575      if ($(this).next().is(":hidden")) {
1576        var $triggerloc = $("h3", location);
1577        $triggerloc
1578          .removeClass(
1579            "ui-accordion-header-active ui-state-active ui-corner-top"
1580          )
1581          .next()
1582          .slideUp(300);
1583        $triggerloc.find("span").removeClass("ui-accordion-icon-active");
1584        $(this).find("span").addClass("ui-accordion-icon-active");
1585        $(this)
1586          .addClass("ui-accordion-header-active ui-state-active ui-corner-top")
1587          .next()
1588          .slideDown(300);
1589      }
1590      e.preventDefault();
1591    });
1592
1593    /*----------------------------------------------------*/
1594    /*	Toggle
1595	/*----------------------------------------------------*/
1596
1597    $(".toggle-container").hide();
1598
1599    $(".trigger, .trigger.opened").on("click", function (a) {
1600      $(this).toggleClass("active");
1601      a.preventDefault();
1602    });
1603
1604    $(".trigger").on("click", function () {
1605      $(this).next(".toggle-container").slideToggle(300);
1606    });
1607
1608    $(".trigger.opened").addClass("active").next(".toggle-container").show();
1609
1610    /*----------------------------------------------------*/
1611    /*  Tooltips
1612	/*----------------------------------------------------*/
1613
1614    $(".tooltip.top").tipTip({
1615      defaultPosition: "top",
1616    });
1617
1618    $(".tooltip.bottom").tipTip({
1619      defaultPosition: "bottom",
1620    });
1621
1622    $(".tooltip.left").tipTip({
1623      defaultPosition: "left",
1624    });
1625
1626    $(".tooltip.right").tipTip({
1627      defaultPosition: "right",
1628    });
1629
1630    /*----------------------------------------------------*/
1631    /*  Searh Form More Options
1632    /*----------------------------------------------------*/
1633    $(".more-search-options-trigger").on("click", function (e) {
1634      e.preventDefault();
1635      $(".more-search-options, .more-search-options-trigger").toggleClass(
1636        "active"
1637      );
1638      $(".more-search-options.relative").animate(
1639        { height: "toggle", opacity: "toggle" },
1640        300
1641      );
1642    });
1643
1644    /*----------------------------------------------------*/
1645    /*  Half Screen Map Adjustments
1646    /*----------------------------------------------------*/
1647    $(window).on("load resize", function () {
1648      var winWidth = $(window).width();
1649      var headerHeight = $("#header-container").height(); // height on which the sticky header will shows
1650      // if body doesn't have class hws-coontainer:
1651      if (!$("body").hasClass("hws-header")) {
1652        $(
1653          ".fs-inner-container, .fs-inner-container.map-fixed, #dashboard, .page-template-template-split-map-sidebar .full-page-jobs"
1654        ).css("padding-top", headerHeight);
1655      }
1656
1657      // if(winWidth<992) {
1658      // 	$('.fs-inner-container.map-fixed').insertBefore('.fs-inner-container.content');
1659      // } else {
1660      // 	$('.fs-inner-container.content').insertBefore('.fs-inner-container.map-fixed');
1661      // }
1662    });
1663
1664    /*----------------------------------------------------*/
1665    /*  Counters
1666    /*----------------------------------------------------*/
1667    $(window).on("load", function () {
1668      $(".listeo-dashoard-widgets .dashboard-stat-content h4").counterUp({
1669        delay: 100,
1670        time: 800,
1671        formatter: function (n) {
1672          if ($("#waller-row").data("numberFormat") == "euro") {
1673            return n.replace(".", ",");
1674          } else {
1675            return n;
1676          }
1677        },
1678      });
1679    });
1680
1681    /*----------------------------------------------------*/
1682    /*  Rating Script Init
1683    /*----------------------------------------------------*/
1684
1685    // Leave Rating
1686    $(".leave-rating input").change(function () {
1687      var $radio = $(this);
1688      $(".leave-rating .selected").removeClass("selected");
1689      $radio.closest("label").addClass("selected");
1690    });
1691
1692    /*----------------------------------------------------*/
1693    /* Dashboard Scripts
1694	/*----------------------------------------------------*/
1695    $(".dashboard-nav ul li a").on("click", function () {
1696      if ($(this).closest("li").has("ul").length) {
1697        $(this).parent("li").toggleClass("active");
1698      }
1699    });
1700
1701    // Dashbaord Nav Scrolling
1702    $(window).on("load resize", function () {
1703      var wrapperHeight = window.innerHeight;
1704      var headerHeight = $("#header-container").height();
1705      var winWidth = $(window).width();
1706
1707      if (winWidth > 992) {
1708        $(".dashboard-nav-inner").css(
1709          "max-height",
1710          wrapperHeight - headerHeight
1711        );
1712      } else {
1713        $(".dashboard-nav-inner").css("max-height", "");
1714      }
1715    });
1716
1717    // Tooltip
1718    $(".tip").each(function () {
1719      var tipContent = $(this).attr("data-tip-content");
1720      $(this).append('<div class="tip-content">' + tipContent + "</div>");
1721    });
1722
1723    $(".verified-badge.with-tip").each(function () {
1724      var tipContent = $(this).attr("data-tip-content");
1725      $(this).append('<div class="tip-content">' + tipContent + "</div>");
1726    });
1727
1728    $(window).on("load resize", function () {
1729      var verifiedBadge = $(".verified-badge.with-tip");
1730      verifiedBadge.find(".tip-content").css({
1731        width: verifiedBadge.outerWidth(),
1732        "max-width": verifiedBadge.outerWidth(),
1733      });
1734    });
1735
1736    // Responsive Nav Trigger
1737    $(".dashboard-responsive-nav-trigger").on("click", function (e) {
1738      e.preventDefault();
1739      $(this).toggleClass("active");
1740
1741      var dashboardNavContainer = $("body").find(".dashboard-nav");
1742
1743      if ($(this).hasClass("active")) {
1744        $(dashboardNavContainer).addClass("active");
1745      } else {
1746        $(dashboardNavContainer).removeClass("active");
1747      }
1748    });
1749
1750    // Dashbaord Messages Alignment
1751    $(window).on("load resize", function () {
1752      var msgContentHeight = $(".message-content").outerHeight();
1753      var msgInboxHeight = $(".messages-inbox ul").height();
1754
1755      if (msgContentHeight > msgInboxHeight) {
1756        $(".messages-container-inner .messages-inbox ul").css(
1757          "max-height",
1758          msgContentHeight
1759        );
1760      }
1761    });
1762
1763    /*----------------------------------------------------*/
1764    /*  Notifications
1765	/*----------------------------------------------------*/
1766    $("a.close")
1767      .removeAttr("href")
1768      .on("click", function () {
1769        function slideFade(elem) {
1770          var fadeOut = { opacity: 0, transition: "opacity 0.5s" };
1771          elem.css(fadeOut).slideUp();
1772        }
1773        slideFade($(this).parent());
1774      });
1775
1776    /*----------------------------------------------------*/
1777    /* Panel Dropdown
1778	/*----------------------------------------------------*/
1779    function close_panel_dropdown() {
1780      $(".panel-dropdown").removeClass("active");
1781      $(".fs-inner-container.content").removeClass("faded-out");
1782    }
1783
1784    // Use event delegation for dynamically added panels
1785    $(document).on("click", ".panel-dropdown a", function (e) {
1786      if ($(this).parent().is(".active")) {
1787        close_panel_dropdown();
1788      } else {
1789        close_panel_dropdown();
1790        $(this).parent().addClass("active");
1791        $(".fs-inner-container.content").addClass("faded-out");
1792      }
1793
1794      e.preventDefault();
1795    });
1796
1797    // Apply / Close buttons - use event delegation
1798    $(document).on("click", ".panel-buttons button,.panel-buttons span.panel-cancel", function (e) {
1799        $(".panel-dropdown").removeClass("active");
1800        $(".fs-inner-container.content").removeClass("faded-out");
1801    });
1802
1803    var $inputRange = $('input[type="range"].distance-radius');
1804
1805    $inputRange.rangeslider({
1806      polyfill: false,
1807      onInit: function () {
1808        var radiustext = $(".distance-radius").attr("data-title");
1809        this.output = $('<div class="range-output" />')
1810          .insertBefore(this.$range)
1811          .html(this.$element.val())
1812          .after('<i class="data-radius-title">' + radiustext + "</i>");
1813
1814        // $('.range-output')
1815      },
1816      onSlide: function (position, value) {
1817        this.output.html(value);
1818      },
1819    });
1820
1821    var $inputBudgetRange = $('input[type="range"].budget-radius');
1822
1823    $inputBudgetRange.rangeslider({
1824      polyfill: false,
1825      onInit: function () {
1826        var radiustext = $(".budget-radius").attr("data-title");
1827        this.output = $('<div class="budget-range-output" />')
1828          .insertBefore(this.$range)
1829          .html(this.$element.val());
1830
1831        // $('.range-output')
1832      },
1833      onSlide: function (position, value) {
1834        this.output.html(value);
1835      },
1836    });
1837
1838    $(".sidebar .panel-disable").on("click", function (e) {
1839      var to = $(".sidebar .range-slider");
1840      var enable = $(this).data("enable");
1841      var disable = $(this).data("disable");
1842      to.toggleClass("disabled");
1843      if (to.hasClass("disabled")) {
1844        $(to).find("input").prop("disabled", true);
1845        $(this).html(enable);
1846      } else {
1847        $(to).find("input").prop("disabled", false);
1848        $(this).html(disable);
1849      }
1850      $inputRange.rangeslider("update");
1851    });
1852
1853    //disable radius in panels
1854
1855    //disable radius in sidebar
1856    if (listeo_core.radius_state == "disabled") {
1857      $(".sidebar .panel-disable").each(function (index) {
1858        var enable = $(this).data("enable");
1859        $(".sidebar .range-slider")
1860          .toggleClass("disabled")
1861          .find("input")
1862          .prop("disabled", true);
1863        $inputRange.rangeslider("update");
1864        $(this).html(enable);
1865      });
1866      $(".panel-buttons span.panel-disable").each(function (index) {
1867        var to = $(this).parent().parent();
1868        var enable = $(this).data("enable");
1869        var disable = $(this).data("disable");
1870        to.toggleClass("disabled");
1871        if (to.hasClass("disabled")) {
1872          $(to).find("input").prop("disabled", true);
1873          $(this).html(enable);
1874        } else {
1875          $(to).find("input").prop("disabled", false);
1876          $(this).html(disable);
1877        }
1878        $inputRange.rangeslider("update");
1879      });
1880    }
1881
1882    $(document).on("click", ".panel-buttons span.panel-disable", function (e) {
1883      var to = $(this).parent().parent();
1884      var enable = $(this).data("enable");
1885      var disable = $(this).data("disable");
1886      to.toggleClass("disabled");
1887      if (to.hasClass("disabled")) {
1888        $(to).find("input").prop("disabled", true);
1889        $(this).html(enable);
1890      } else {
1891        $(to).find("input").prop("disabled", false);
1892        $(this).html(disable);
1893      }
1894      $inputRange.rangeslider("update");
1895    });
1896
1897    // Track if we're currently interacting with a Bootstrap Select
1898    var bootstrapSelectActive = false;
1899    
1900    // Mark when Bootstrap Select interaction starts
1901    $(document).on("click", ".panel-dropdown .bootstrap-select", function(e) {
1902      bootstrapSelectActive = true;
1903      setTimeout(function() {
1904        bootstrapSelectActive = false;
1905      }, 500); // Reset after 500ms
1906    });
1907
1908    // Closes dropdown on click outside the container
1909    $(document).on("click", function (e) {
1910      // Don't close if we're currently interacting with Bootstrap Select
1911      if (bootstrapSelectActive) {
1912        return;
1913      }
1914      
1915      // Don't close if clicking on Bootstrap Select dropdown menu or related elements
1916      if ($(e.target).closest(".bootstrap-select .dropdown-menu, .bootstrap-select .btn-group, .dropdown-menu").length) {
1917        return;
1918      }
1919      
1920      // Also check for Bootstrap Select specific classes
1921      if ($(e.target).hasClass("dropdown-item") || $(e.target).closest(".dropdown-item").length) {
1922        return;
1923      }
1924      
1925      // Check if clicked element is part of any select element within a panel
1926      if ($(e.target).closest(".panel-dropdown select").length || $(e.target).closest(".panel-dropdown .bootstrap-select").length) {
1927        return;
1928      }
1929      
1930      // Check if the clicked element is outside all panel-dropdown elements
1931      if (!$(e.target).closest(".panel-dropdown").length) {
1932        close_panel_dropdown();
1933      }
1934    });
1935
1936    // More comprehensive approach - prevent any clicks within panel-dropdown from bubbling
1937    $(document).on("click", ".panel-dropdown", function (e) {
1938      // Only allow the toggle link (direct child 'a' element) to trigger panel actions
1939      if ($(e.target).is(".panel-dropdown > a") || $(e.target).closest(".panel-dropdown > a").length) {
1940        return; // Allow normal panel toggle behavior
1941      }
1942      
1943      // Allow Bootstrap Select to function normally - don't interfere with its dropdown button
1944      if ($(e.target).closest(".bootstrap-select .dropdown-toggle").length) {
1945        return; // Allow Bootstrap Select dropdown to open/close normally
1946      }
1947      
1948      // For all other clicks within the panel, stop propagation
1949      e.stopPropagation();
1950    });
1951
1952    // Prevent panel dropdown content clicks from closing the panel
1953    $(document).on("click", ".panel-dropdown .panel-dropdown-content", function (e) {
1954      e.stopPropagation();
1955    });
1956
1957    // Prevent dropdown-menu clicks from closing the panel
1958    $(document).on("click", ".panel-dropdown .dropdown-menu", function (e) {
1959      e.stopPropagation();
1960    });
1961
1962    // Prevent dropdown-menu items clicks from closing the panel
1963    $(document).on("click", ".panel-dropdown .dropdown-menu a, .panel-dropdown .dropdown-menu li, .panel-dropdown .dropdown-item", function (e) {
1964      e.stopPropagation();
1965    });
1966
1967    // Specific handler for Bootstrap Select dropdowns
1968    $(document).on("click", ".panel-dropdown .bootstrap-select .dropdown-menu li a", function (e) {
1969      e.stopPropagation();
1970    });
1971
1972
1973    // Function to initialize dynamic panel elements
1974    function initializePanelElements($panel) {
1975      // Initialize range sliders for dynamically added panels
1976      $panel.find('input[type="range"].distance-radius').rangeslider({
1977        polyfill: false,
1978        onInit: function () {
1979          var radiustext = this.$element.attr("data-title");
1980          this.output = $('<div class="range-output" />')
1981            .insertBefore(this.$range)
1982            .html(this.$element.val())
1983            .after('<i class="data-radius-title">' + radiustext + "</i>");
1984        },
1985        onSlide: function (position, value) {
1986          this.output.html(value);
1987        },
1988      });
1989
1990      $panel.find('input[type="range"].budget-radius').rangeslider({
1991        polyfill: false,
1992        onInit: function () {
1993          var radiustext = this.$element.attr("data-title");
1994          this.output = $('<div class="budget-range-output" />')
1995            .insertBefore(this.$range)
1996            .html(this.$element.val());
1997        },
1998        onSlide: function (position, value) {
1999          this.output.html(value);
2000        },
2001      });
2002
2003      // // Check initial state of checkboxes within the new panel
2004      // var checkboxes = $panel.find('input[type="checkbox"]');
2005      // var isAnyCheckboxChecked = checkboxes.is(":checked");
2006      
2007      // if (isAnyCheckboxChecked) {
2008      //   $panel.addClass("preselected");
2009      // }
2010
2011      // Check select options
2012      // var select = $panel.find("select option");
2013      // var isAnySelectSelected = false;
2014      // select.each(function () {
2015      //   var option = $(this);
2016      //   if (option.is(":selected") && option.val() != "0") {
2017      //     isAnySelectSelected = true;
2018      //   }
2019      // });
2020
2021      // if (isAnySelectSelected) {
2022      //   $panel.addClass("preselected");
2023      // }
2024    }
2025
2026    // Call this function when adding new panels dynamically
2027    // Example: initializePanelElements($('.newly-added-panel'));
2028    window.initializePanelElements = initializePanelElements;
2029
2030    // "All" checkbox - use event delegation
2031    $(document).on("change", ".checkboxes.categories input", function () {
2032      if ($(this).hasClass("all")) {
2033        $(this).parents(".checkboxes").find("input").prop("checked", false);
2034        $(this).prop("checked", true);
2035      } else {
2036        $(this).parents(".checkboxes").find("input.all").prop("checked", false);
2037      }
2038    });
2039
2040    var panelDropdowns = $(".panel-dropdown");
2041
2042
2043    // $(document).on(
2044    //   "change",
2045    //   ".panel-dropdown input,.panel-dropdown select",
2046    //   function (e) {
2047    //     var panelDropdowns = $(".panel-dropdown");
2048
2049        
2050    //   }
2051    // );
2052
2053
2054
2055
2056
2057  // Track active custom field requests
2058  var activeCustomFieldRequests = {};
2059
2060  // Initialize dynamic custom search fields
2061  initDynamicCustomSearchFields();
2062
2063  function initDynamicCustomSearchFields() {
2064    // Listen for changes on taxonomy selects
2065    $(document).on(
2066      "change",
2067      'select[name^="tax-"], input[name^="tax-"]',
2068      function () {
2069        var $element = $(this);
2070        
2071        var taxonomyName = getTaxonomyNameFromElement($element);
2072
2073        if (taxonomyName) {
2074          handleTaxonomyChange(taxonomyName);
2075        }
2076      }
2077    );
2078
2079    // Listen for checkbox changes
2080    $(document).on(
2081      "change",
2082      'input[type="checkbox"][name^="tax-"]',
2083      function () {
2084        var $element = $(this);
2085        var taxonomyName = getTaxonomyNameFromElement($element);
2086
2087        if (taxonomyName) {
2088          // Debounce checkbox changes
2089          clearTimeout(activeCustomFieldRequests[taxonomyName + "_timeout"]);
2090          activeCustomFieldRequests[taxonomyName + "_timeout"] = setTimeout(
2091            function () {
2092              handleTaxonomyChange(taxonomyName);
2093            },
2094            300
2095          );
2096        }
2097      }
2098    );
2099
2100    // same function but for .on("drilldown-updated", ".drilldown-menu", function () {
2101    $(document).on("drilldown-updated", ".drilldown-menu", function () {
2102      var $element = $(this);
2103      var taxonomyName = getTaxonomyNameFromElement($element);
2104
2105      if (!taxonomyName) {
2106        // Try to get taxonomy name from the drilldown menu's data-name attribute
2107        taxonomyName = $element.attr("data-name");
2108        if (taxonomyName) {
2109          // Remove 'tax-' prefix if present
2110          taxonomyName = taxonomyName.replace(/^tax-/, "");
2111        }
2112      }
2113
2114      if (taxonomyName) {
2115        console.log("Drilldown updated for taxonomy:", taxonomyName);
2116        handleTaxonomyChange(taxonomyName);
2117      }
2118    });
2119  }
2120
2121  // // Monitor for changes in drilldown-generated inputs
2122  // $(document).on(
2123  //   "DOMNodeInserted DOMNodeRemoved",
2124  //   ".drilldown-generated",
2125  //   function (e) {
2126  //     var $element = $(e.target);
2127  //     if ($element.hasClass("drilldown-generated")) {
2128  //       var taxonomyName = getTaxonomyNameFromElement($element);
2129  //       if (taxonomyName) {
2130  //         // Debounce to avoid too many calls
2131  //         clearTimeout(window.drilldownUpdateTimeout);
2132  //         window.drilldownUpdateTimeout = setTimeout(function () {
2133  //           handleTaxonomyChange(taxonomyName);
2134  //         }, 100);
2135  //       }
2136  //     }
2137  //   }
2138  // );
2139
2140  function getTaxonomyNameFromElement($element) {
2141    var name = $element.attr("name");
2142
2143    // If empty name, try data-name (for drilldown menus)
2144    if (!name) {
2145      name = $element.data("name");
2146    }
2147
2148    // For drilldown containers, check if they have data-name attribute
2149    if (!name && $element.hasClass("drilldown-menu")) {
2150      name = $element.attr("data-name");
2151    }
2152
2153    if (!name) return null;
2154
2155    // Extract taxonomy name from input name
2156    // Examples: tax-listing_category, tax-listing_feature[], etc.
2157    var match = name.match(/^tax-([^[\]]+)/);
2158    return match ? match[1] : null;
2159  }
2160
2161  function handleTaxonomyChange(taxonomyName) {
2162    console.log("Handling taxonomy change for:", taxonomyName);
2163
2164    var selectedValues = getSelectedTaxonomyValues(taxonomyName);
2165
2166    if (selectedValues.length === 0) {
2167      // Check if there are any OTHER category fields with selected values before hiding
2168      var hasOtherSelectedCategories = false;
2169      
2170      // Check all possible category taxonomies
2171      var categoryTaxonomies = ['listing_category', 'event_category', 'service_category', 'rental_category', 'classifieds_category'];
2172      
2173      for (var i = 0; i < categoryTaxonomies.length; i++) {
2174        var taxonomy = categoryTaxonomies[i];
2175        if (taxonomy !== taxonomyName) {
2176          var otherValues = getSelectedTaxonomyValues(taxonomy);
2177          if (otherValues.length > 0) {
2178            hasOtherSelectedCategories = true;
2179            break;
2180          }
2181        }
2182      }
2183      
2184      // Only hide custom fields if NO categories are selected anywhere
2185      if (!hasOtherSelectedCategories) {
2186        hideCustomSearchFields(taxonomyName);
2187      }
2188      return;
2189    }
2190
2191    // Fetch custom search fields for selected terms
2192    fetchCustomSearchFields(taxonomyName, selectedValues);
2193  }
2194
2195  function getSelectedTaxonomyValues(taxonomyName) {
2196    var values = [];
2197    var selector = '[name^="tax-' + taxonomyName + '"]';
2198
2199    $(selector).each(function () {
2200      var $element = $(this);
2201      var tagName = $element.prop("tagName").toLowerCase();
2202      var type = $element.attr("type");
2203
2204      if (tagName === "select") {
2205        var selectedValue = $element.val();
2206        if (
2207          selectedValue &&
2208          selectedValue !== "" &&
2209          selectedValue !== "0" &&
2210          selectedValue !== "-1"
2211        ) {
2212          if ($.isArray(selectedValue)) {
2213            values = values.concat(
2214              selectedValue.filter(function (v) {
2215                return v && v !== "" && v !== "0" && v !== "-1";
2216              })
2217            );
2218          } else {
2219            values.push(selectedValue);
2220          }
2221        }
2222      } else if (type === "checkbox" && $element.is(":checked")) {
2223        var value = $element.val();
2224        if (value && value !== "" && value !== "0" && value !== "-1") {
2225          values.push(value);
2226        }
2227      } else if (type === "radio" && $element.is(":checked")) {
2228        var value = $element.val();
2229        if (value && value !== "" && value !== "0" && value !== "-1") {
2230          values.push(value);
2231        }
2232      } else if (
2233        type === "hidden" &&
2234        $element.hasClass("drilldown-generated")
2235      ) {
2236        // Handle drilldown generated hidden inputs
2237        var value = $element.val();
2238        if (value && value !== "" && value !== "0" && value !== "-1") {
2239          values.push(value);
2240        }
2241      }
2242    });
2243
2244    return values.filter(function (value, index, self) {
2245      return self.indexOf(value) === index; // Remove duplicates
2246    });
2247  }
2248
2249  // --- Detect search context (sidebar vs split/full width panel)
2250  function detectSearchContext() {
2251    var $form = $("#listeo_core-search-form");
2252    var isPanel =
2253      // split/full-width templates commonly used by Listeo
2254      $("body").hasClass("page-template-template-split-map") ||
2255      $("body").hasClass("page-template-template-home-search") ||
2256      $("body").hasClass("page-template-template-home-search-splash") ||
2257      // or: form explicitly contains panel dropdowns
2258      $form.find(".panel-dropdown").length > 0 ||
2259      // or: homepage search form with panel layout
2260      $form.hasClass("listeo-form-search_on_home_page");
2261
2262    return isPanel ? "panel" : "sidebar";
2263  }
2264
2265
2266  function fetchCustomSearchFields(taxonomyName, termIds) {
2267    var requestKey = taxonomyName + "-" + termIds.join("-");
2268
2269    // Cancel any existing request for this taxonomy
2270    if (activeCustomFieldRequests[taxonomyName]) {
2271      activeCustomFieldRequests[taxonomyName].abort();
2272    }
2273    var context = detectSearchContext(); // <-- new
2274    console.log("Fetching custom search fields for:", taxonomyName, termIds);
2275
2276    activeCustomFieldRequests[taxonomyName] = $.ajax({
2277      type: "POST",
2278      url: listeo.ajaxurl,
2279      dataType: "json",
2280      data: {
2281        action: "listeo_get_custom_search_fields_from_term",
2282        cat_ids: termIds,
2283        term: taxonomyName,
2284        context: context,
2285        nonce: listeo.nonce_get_custom_fields || "",
2286      },
2287      success: function (data) {
2288        if (data.success && data.output) {
2289          showCustomSearchFields(taxonomyName, data.output, context, data.context);
2290        } else {
2291          hideCustomSearchFields(taxonomyName, context);
2292        }
2293      },
2294      error: function (xhr, status, error) {
2295        if (status !== "abort") {
2296          console.error("Error fetching custom search fields:", error);
2297          hideCustomSearchFields(taxonomyName, context);
2298        }
2299      },
2300      complete: function () {
2301        delete activeCustomFieldRequests[taxonomyName];
2302      },
2303    });
2304  }
2305
2306  function showCustomSearchFields(taxonomyName, html, context, actualContext) {
2307    var containerId = "custom-search-fields-" + taxonomyName;
2308    
2309    if (actualContext === 'panel') {
2310      // Check if this is a fullwidth form (homepage search form case)
2311      var $form = $("#listeo_core-search-form");
2312      var isFullwidthForm = $form.hasClass("listeo-form-search_on_home_page");
2313      
2314      if (isFullwidthForm) {
2315        // Fullwidth form: Insert panels into main-search-input wrapper
2316        var $mainSearchInput = $('.main-search-input');
2317        
2318        if ($mainSearchInput.length > 0) {
2319          // Remove existing custom field panels for this taxonomy
2320          $mainSearchInput.find('.main-search-input-item.custom-fields-panel').remove();
2321          
2322          // Wrap the custom fields HTML in main-search-input-item divs
2323          var $tempContainer = $('<div>').html(html);
2324          var wrappedHTML = '';
2325          
2326          $tempContainer.find('.custom-fields-panel').each(function() {
2327            var $panel = $(this);
2328            var panelClass = 'main-search-input-item';
2329            
2330            // Determine the appropriate class based on field type
2331            if ($panel.find('.range-slider, .bootstrap-range-slider').length > 0) {
2332              panelClass += ' slider_type';
2333            } else if ($panel.find('.checkboxes').length > 0) {
2334              panelClass += ' checkboxes_type';
2335            } else {
2336              panelClass += ' dropdown_type';
2337            }
2338            
2339            // Wrap the panel in main-search-input-item
2340            wrappedHTML += '<div class="' + panelClass + '">' + $panel[0].outerHTML + '</div>';
2341          });
2342          
2343          // Insert wrapped panels before the search button
2344          var $searchButton = $mainSearchInput.find('button.button');
2345          if ($searchButton.length > 0) {
2346            $searchButton.before(wrappedHTML);
2347          } else {
2348            $mainSearchInput.append(wrappedHTML);
2349          }
2350          
2351          // Initialize form elements in the new panels
2352          $mainSearchInput.find('.main-search-input-item .custom-fields-panel').each(function() {
2353            initializeNewFormElements($(this));
2354            // Initialize panel dropdown functionality
2355            initializePanelElements($(this));
2356          });
2357          
2358          console.log("Custom search field panels added to fullwidth form for:", taxonomyName);
2359        }
2360      } else {
2361        // Regular panel context: Insert panels into panel wrapper
2362        var $panelWrapper = $('.panel-wrapper');
2363        
2364        if ($panelWrapper.length > 0) {
2365          // Remove existing custom field panels for this taxonomy
2366          $panelWrapper.find('.custom-fields-panel').remove();
2367          
2368          // Find the best position to insert the panels
2369          var $categoryPanel = $panelWrapper.find('.panel-dropdown').filter(function() {
2370            // Look for category-related panels by checking the ID or content
2371            var panelId = $(this).attr('id') || '';
2372            var panelText = $(this).find('a').text().toLowerCase();
2373            return panelId.indexOf('tax') !== -1 || 
2374                   panelId.indexOf('listing_category') !== -1 ||
2375                   panelText.indexOf('categor') !== -1;
2376          }).last(); // Get the last category panel if multiple exist
2377          
2378          // Insert panels after category panel if found, otherwise at the end
2379          if ($categoryPanel.length > 0) {
2380            $categoryPanel.after(html);
2381          } else {
2382            $panelWrapper.append(html);
2383          }
2384          
2385          // Initialize form elements in the new panels
2386          $panelWrapper.find('.custom-fields-panel').each(function() {
2387            initializeNewFormElements($(this));
2388            // Initialize panel dropdown functionality
2389            initializePanelElements($(this));
2390          });
2391          
2392          console.log("Custom search field panels added for:", taxonomyName);
2393        }
2394      }
2395    } else {
2396      // Sidebar context: Use container approach
2397      var $container = $("#" + containerId);
2398
2399      if ($container.length === 0) {
2400        // Create container if it doesn't exist
2401        var $searchForm = $("#listeo_core-search-form");
2402        var $taxonomyField = $searchForm
2403          .find('[name^="tax-' + taxonomyName + '"]')
2404          .closest(".row, .main-search-input-item, .panel-dropdown, .col-md-12")
2405          .first();
2406
2407        if ($taxonomyField.length === 0) {
2408          $taxonomyField = $searchForm
2409            .find('[name^="tax-' + taxonomyName + '"]')
2410            .parent();
2411        }
2412
2413        $container = $(
2414          '<div id="' +
2415            containerId +
2416            '" class="custom-search-fields-container dynamic-fields" style="display: none;"></div>'
2417        );
2418        $taxonomyField.after($container);
2419      }
2420
2421      $container.html(html).slideDown(300);
2422
2423      // Initialize any new form elements
2424      initializeNewFormElements($container);
2425
2426      console.log("Custom search fields shown for:", taxonomyName);
2427    }
2428  }
2429
2430  function hideCustomSearchFields(taxonomyName, context) {
2431    var containerId = "custom-search-fields-" + taxonomyName;
2432    
2433    // Check if this is a fullwidth form first
2434    var $form = $("#listeo_core-search-form");
2435    var isFullwidthForm = $form.hasClass("listeo-form-search_on_home_page");
2436    
2437    if (isFullwidthForm) {
2438      // Fullwidth form: Remove wrapped panels from main-search-input
2439      var $mainSearchInput = $('.main-search-input');
2440      var $customPanelWrappers = $mainSearchInput.find('.main-search-input-item').filter(function() {
2441        return $(this).find('.custom-fields-panel').length > 0;
2442      });
2443      
2444      if ($customPanelWrappers.length > 0) {
2445        $customPanelWrappers.fadeOut(300, function() {
2446          $(this).remove();
2447        });
2448        console.log("Custom search field panels removed from fullwidth form for:", taxonomyName);
2449        return;
2450      }
2451    }
2452    
2453    // Check for panel context by looking for existing panels in panel wrapper
2454    var $panelWrapper = $('.panel-wrapper');
2455    var $customPanels = $panelWrapper.find('.custom-fields-panel');
2456    
2457    if ($customPanels.length > 0) {
2458      // Panel context: Remove custom field panels
2459      $customPanels.fadeOut(300, function() {
2460        $(this).remove();
2461      });
2462      console.log("Custom search field panels removed for:", taxonomyName);
2463    } else {
2464      // Sidebar context: Remove container
2465      var $container = $("#" + containerId);
2466      if ($container.length > 0) {
2467        $container.slideUp(300, function () {
2468          $(this).remove();
2469        });
2470      }
2471      console.log("Custom search fields hidden for:", taxonomyName);
2472    }
2473  }
2474
2475  function initializeNewFormElements($container) {
2476    // Initialize select2 for new select elements
2477    // if (typeof $.fn.select2 !== "undefined") {
2478    //   $container.find("select").select2();
2479    // }
2480    // we need to refresh Refresh Bootstrap Select instead of select2
2481    if (typeof $.fn.selectpicker !== "undefined") {
2482      $container.find("select").selectpicker("refresh");
2483    }
2484
2485    // Initialize sliders
2486    if (typeof $.fn.slider !== "undefined") {
2487      $container.find(".slider-range").each(function () {
2488        var $slider = $(this);
2489        var min = parseInt($slider.data("min")) || 0;
2490        var max = parseInt($slider.data("max")) || 100;
2491        var step = parseInt($slider.data("step")) || 1;
2492
2493        $slider.slider({
2494          range: true,
2495          min: min,
2496          max: max,
2497          step: step,
2498          values: [min, max],
2499          slide: function (event, ui) {
2500            var $output = $slider.siblings(".slider-output");
2501            $output.text(ui.values[0] + " - " + ui.values[1]);
2502          },
2503        });
2504      });
2505    }
2506
2507    // Initialize any custom elements
2508    $(document).trigger("listeo_custom_fields_loaded", [$container]);
2509  }
2510
2511  // Global function for toggling custom search groups
2512  window.toggleCustomSearchGroup = function(header) {
2513    var $header = $(header);
2514    var $content = $header.siblings('.custom-search-group-content');
2515    var $icon = $header.find('.toggle-icon');
2516    
2517    // Toggle collapsed class
2518    $content.toggleClass('collapsed');
2519    
2520    if ($content.hasClass('collapsed')) {
2521      // Content is now collapsed
2522      $content.slideUp(300);
2523      $icon.removeClass('fa-angle-down').addClass('fa-angle-up');
2524    } else {
2525      // Content is now expanded
2526      $content.slideDown(300);
2527      $icon.removeClass('fa-angle-up').addClass('fa-angle-down');
2528    }
2529    
2530  };
2531
2532  // // Event delegation for dynamically added custom field panels
2533  // $(document).on('click', '.custom-fields-panel > a', function(e) {
2534  //   e.preventDefault();
2535  //   var $panel = $(this).parent();
2536    
2537  //   if ($panel.is(".active")) {
2538  //     $panel.removeClass("active");
2539  //   } else {
2540  //     // Close other panels first
2541  //     $('.panel-dropdown').removeClass("active");
2542  //     // Open this panel
2543  //     $panel.addClass("active");
2544  //   }
2545  // });
2546
2547  // Clean up on form reset
2548  $(document).on("reset", "#listeo_core-search-form", function () {
2549    $(".custom-search-fields-container.dynamic-fields").remove();
2550  });
2551
2552  // Handle drilldown reset button with smart custom field management
2553  $(document).on("click", ".drilldown-menu .reset-button", function (e) {
2554    var $menu = $(this).closest('.drilldown-menu');
2555    var taxonomyName = extractTaxonomyFromName($menu.find('.drilldown-values').attr('name') || '');
2556    
2557    if (taxonomyName) {
2558      // Store the current menu state before reset
2559      var wasMenuOpen = $menu.hasClass('dd-active') || $menu.find('.menu-panel').is(':visible');
2560      
2561      // Use setTimeout to let the drilldown reset complete first
2562      setTimeout(function() {
2563        // Re-run our smart taxonomy change handler after drilldown reset
2564        handleTaxonomyChange(taxonomyName);
2565        
2566        // If the menu was open before reset and should stay open, reopen it
2567        if (wasMenuOpen && !$menu.hasClass('dd-active')) {
2568          // Check if there are any other categories selected that would keep custom fields visible
2569          var hasOtherSelectedCategories = false;
2570          var categoryTaxonomies = ['listing_category', 'event_category', 'service_category', 'rental_category', 'classifieds_category'];
2571          
2572          for (var i = 0; i < categoryTaxonomies.length; i++) {
2573            var taxonomy = categoryTaxonomies[i];
2574            if (taxonomy !== taxonomyName) {
2575              var otherValues = getSelectedTaxonomyValues(taxonomy);
2576              if (otherValues.length > 0) {
2577                hasOtherSelectedCategories = true;
2578                break;
2579              }
2580            }
2581          }
2582          
2583          // If there are other categories selected, keep the menu open for user convenience
2584          if (hasOtherSelectedCategories) {
2585            $menu.find('.menu-toggle').trigger('click');
2586          }
2587        }
2588      }, 100); // Increased timeout to ensure drilldown operations complete
2589    }
2590  });
2591
2592  // Handle form submission to include custom field values
2593  $(document).on("submit", "#listeo_core-search-form", function () {
2594    // Custom field values will be automatically included as they're part of the form
2595    console.log("Form submitted with custom search fields");
2596  });
2597
2598
2599    /*--------------------------------------------------*/
2600    /*  Bootstrap Range Slider
2601	/*--------------------------------------------------*/
2602
2603    // Thousand Separator for Tooltip
2604    function ThousandSeparator(nStr) {
2605      nStr += "";
2606      var x = nStr.split(".");
2607      var x1 = x[0];
2608      var x2 = x.length > 1 ? "." + x[1] : "";
2609      var rgx = /(\d+)(\d{3})/;
2610      while (rgx.test(x1)) {
2611        x1 = x1.replace(rgx, "$1" + "," + "$2");
2612      }
2613      return x1 + x2;
2614    }
2615
2616    // Bootstrap Range Slider
2617    var currencyAttr = $(".bootstrap-range-slider").attr(
2618      "data-slider-currency"
2619    );
2620
2621    $(".bootstrap-range-slider").slider({
2622      formatter: function (value) {
2623        if (listeo_core.currency_position == "before") {
2624          return (
2625            currencyAttr +
2626            " " +
2627            ThousandSeparator(parseFloat(value[0])) +
2628            " - " +
2629            ThousandSeparator(parseFloat(value[1]))
2630          );
2631        } else {
2632          return (
2633            ThousandSeparator(parseFloat(value[0])) +
2634            " - " +
2635            ThousandSeparator(parseFloat(value[1])) +
2636            " " +
2637            currencyAttr
2638          );
2639        }
2640      },
2641    });
2642
2643    if (!$(".range-slider-container").hasClass("no-to-disable")) {
2644      $(".bootstrap-range-slider")
2645        .slider("disable")
2646        .prop("disabled", true)
2647        .toggleClass("disabled");
2648    } else {
2649      var dis = $(".slider-disable").data("disable");
2650      $(".slider-disable").html(dis);
2651    }
2652
2653    $('.range-slider-container:not(".no-to-disable")').toggleClass("disabled");
2654
2655    $(".slider-disable").click(function () {
2656      var to = $(".range-slider-container");
2657      var enable = $(this).data("enable");
2658      var disable = $(this).data("disable");
2659      to.toggleClass("disabled");
2660      if (to.hasClass("disabled")) {
2661        $(".bootstrap-range-slider").slider("disable");
2662        $(to).find("input").prop("disabled", true);
2663        $(this).html(enable);
2664      } else {
2665        $(".bootstrap-range-slider").slider("enable");
2666        $(to).find("input").prop("disabled", false);
2667        $(this).html(disable);
2668      }
2669    });
2670
2671    /*----------------------------------------------------*/
2672    /*  Show More Button
2673    /*----------------------------------------------------*/
2674    $(".show-more-button").on("click", function (e) {
2675      e.preventDefault();
2676      $(this).toggleClass("active");
2677
2678      $(".show-more").toggleClass("visible");
2679      if ($(".show-more").is(".visible")) {
2680        var el = $(".show-more"),
2681          curHeight = el.height(),
2682          autoHeight = el.css("height", "auto").height();
2683        el.height(curHeight).animate({ height: autoHeight }, 400);
2684      } else {
2685        $(".show-more").animate({ height: "450px" }, 400);
2686      }
2687    });
2688
2689    $(".simple-slider-form-inner .filter-tab").on("click", function (e) {
2690      e.preventDefault();
2691      var type = $(this).data("type");
2692      $("#search-listing-type").remove();
2693      if (type) {
2694        $("#listeo_core-search-form").prepend(
2695          '<input type="hidden" id="search-listing-type" name="_listing_type" value="' +
2696            type +
2697            '">'
2698        );
2699      }
2700    });
2701
2702    /*----------------------------------------------------*/
2703    /* Listing Page Nav
2704	/*----------------------------------------------------*/
2705
2706    //  	$(window).on('resize load', function() {
2707    // 	var winWidth = $(window).width();
2708    // 	if (winWidth<992) {
2709    // 		$('.mobile-sidebar-container').insertBefore('.mobile-content-container');
2710    // 	} else {
2711    // 		$('.mobile-sidebar-container').insertAfter('.mobile-content-container');
2712    // 	}
2713    // });
2714
2715    if (document.getElementById("listing-nav") !== null) {
2716      $(window).scroll(function () {
2717        var window_top = $(window).scrollTop();
2718        var div_top =
2719          $(".listing-nav")
2720            .not(".listing-nav-container.cloned .listing-nav")
2721            .offset().top + 90;
2722        if (window_top > div_top) {
2723          $(".listing-nav-container.cloned").addClass("stick");
2724        } else {
2725          $(".listing-nav-container.cloned").removeClass("stick");
2726        }
2727      });
2728    }
2729    var widgetList = document.querySelectorAll(".elementor-widget");
2730    var navListTop = document.querySelector(".listing-nav-container.cloned");
2731
2732    var navList = document.querySelector(
2733      ".elementor-widget-container #nav-list-dynamic"
2734    );
2735
2736    widgetList.forEach(function (widget, index) {
2737      //check if widget has inside div with class elementor-widget-container
2738      if (widget.querySelector(".listing-gallery")) {
2739      }
2740
2741      var id = widget.getAttribute("data-id");
2742      switch (widget.getAttribute("data-widget_type")) {
2743        //           listeo-listing-pricing-menu.default
2744        //listeo-listing-taxonomy-checkboxes.default
2745        //listeo-listing-video.default<a href="#listing-pricing-list">Pricing</a>
2746        case "listeo-listing-gallery.default":
2747          if (widget.querySelector(".listing-slider-small")) {
2748            var widgetTitle = listeo_core.elementor_single_gallery;
2749            var href = "elementor-element-" + id;
2750            $(".elementor-element-" + id).attr("id", href);
2751            break;
2752          }
2753
2754          break;
2755        case "listeo-listing-custom-fields.default":
2756          var widgetTitle = listeo_core.elementor_single_details;
2757          var href = "elementor-element-" + id;
2758          $(".elementor-element-" + id).attr("id", href);
2759          break;
2760
2761        case "listeo-listing-pricing-menu.default":
2762          var widgetTitle = listeo_core.elementor_single_pricing;
2763          var href = "elementor-element-" + id;
2764          $(".elementor-element-" + id).attr("id", href);
2765          break;
2766
2767        case "listeo-listing-store.default":
2768          var widgetTitle = listeo_core.elementor_single_store;
2769          var href = "elementor-element-" + id;
2770          $(".elementor-element-" + id).attr("id", href);
2771          break;
2772
2773        case "listeo-listing-video.default":
2774          // chec if widget has video
2775          if (widget.querySelector(".responsive-iframe")) {
2776            var widgetTitle = listeo_core.elementor_single_video;
2777            var href = "elementor-element-" + id;
2778            $(".elementor-element-" + id).attr("id", href);
2779          }
2780          break;
2781        case "listeo-listing-location.default":
2782          var widgetTitle = listeo_core.elementor_single_location;
2783          var href = "elementor-element-" + id;
2784          $(".elementor-element-" + id).attr("id", href);
2785          break;
2786        case "listeo-listing-faq.default":
2787          var widgetTitle = listeo_core.elementor_single_faq;
2788          var href = "elementor-element-" + id;
2789          $(".elementor-element-" + id).attr("id", href);
2790          break;
2791        case "listeo-listing-reviews.default":
2792          var widgetTitle = listeo_core.elementor_single_reviews;
2793          var href = "elementor-element-" + id;
2794          $(".elementor-element-" + id).attr("id", href);
2795          break;
2796        case "listeo-listing-map.default":
2797          var widgetTitle = listeo_core.elementor_single_map;
2798          var href = "elementor-element-" + id;
2799          $(".elementor-element-" + id).attr("id", href);
2800          break;
2801
2802        // default:
2803        //   var widgetTitle = "Widget " + (index + 1);
2804        //   break;
2805      }
2806      if (widgetTitle) {
2807        var listItem = document.createElement("li");
2808        var link = document.createElement("a");
2809        link.href = "#" + href;
2810        link.textContent = widgetTitle;
2811        listItem.appendChild(link);
2812        if (
2813          widget.getAttribute("data-widget_type") ==
2814          "theme-post-content.default"
2815        ) {
2816          $(".nav-listing-overview").html(link);
2817        } else {
2818          if (navList) {
2819            navList.appendChild(listItem);
2820          }
2821        }
2822      }
2823    });
2824
2825    $(".listing-nav-container")
2826      .clone(true)
2827      .addClass("cloned")
2828      .prependTo("body");
2829
2830    // Smooth scrolling using scrollto.js
2831    $(document).on(
2832      "click",
2833      ".listing-nav a, a.listing-address, .star-rating a",
2834      function (e) {
2835        if (this.hash !== "") {
2836          try {
2837            // Check if the target element exists
2838            const targetElement = $(this.hash);
2839
2840            if (targetElement.length && targetElement.offset()) {
2841              e.preventDefault();
2842
2843              // Ensure element is visible and has dimensions
2844              const offset = targetElement.offset();
2845              if (offset && typeof offset.top !== "undefined") {
2846                // Scroll to the target element
2847                $("html, body").animate(
2848                  {
2849                    scrollTop: offset.top - 20,
2850                  },
2851                  800
2852                );
2853              }
2854            }
2855          } catch (error) {
2856            console.log("Scroll error:", error);
2857            // Allow default behavior if there's an error
2858          }
2859        }
2860      }
2861    );
2862
2863    $(document).on(
2864      "click",
2865      ".listing-nav li:first-child a, a.add-review-btn, a[href='#add-review']",
2866      function (e) {
2867        e.preventDefault();
2868
2869        $("html,body").scrollTo(this.hash, this.hash, { gap: { y: -100 } });
2870      }
2871    );
2872
2873    // Highlighting functionality.
2874    $(window).on("load resize", function () {
2875      var aChildren = $(".listing-nav li").children();
2876      var aArray = [];
2877      for (var i = 0; i < aChildren.length; i++) {
2878        var aChild = aChildren[i];
2879        var ahref = $(aChild).attr("href");
2880        aArray.push(ahref);
2881      }
2882
2883      $(window).scroll(function () {
2884        var windowPos = $(window).scrollTop();
2885        for (var i = 0; i < aArray.length; i++) {
2886          var theID = aArray[i];
2887          if ($(theID).length > 0) {
2888            var divPos = $(theID).offset().top - 150;
2889            var divHeight = $(theID).height();
2890            if (windowPos >= divPos && windowPos < divPos + divHeight) {
2891              $("a[href='" + theID + "']").addClass("active");
2892            } else {
2893              $("a[href='" + theID + "']").removeClass("active");
2894            }
2895          }
2896        }
2897      });
2898    });
2899
2900    // dynamic listing for Elementor widget
2901
2902    var time24 = false;
2903
2904    if (listeo_core.clockformat) {
2905      time24 = true;
2906    }
2907    $(".listeo-flatpickr").flatpickr({
2908      enableTime: true,
2909      noCalendar: true,
2910      dateFormat: "H:i",
2911      time_24hr: time24,
2912      disableMobile: true,
2913    });
2914
2915    $(".day_hours_reset").on("click", function (e) {
2916      $(this).parent().parent().find("input").val("");
2917    });
2918
2919    /*----------------------------------------------------*/
2920    /*  Payment Accordion
2921	/*----------------------------------------------------*/
2922    var radios = document.querySelectorAll(".payment-tab-trigger > input");
2923
2924    for (var i = 0; i < radios.length; i++) {
2925      radios[i].addEventListener("change", expandAccordion);
2926    }
2927
2928    function expandAccordion(event) {
2929      var allTabs = document.querySelectorAll(".payment-tab");
2930      for (var i = 0; i < allTabs.length; i++) {
2931        allTabs[i].classList.remove("payment-tab-active");
2932      }
2933      event.target.parentNode.parentNode.classList.add("payment-tab-active");
2934    }
2935
2936    //     /*----------------------------------------------------*/
2937    /*  Rating Overview Background Colors
2938    /*----------------------------------------------------*/
2939    function ratingOverview(ratingElem) {
2940      $(ratingElem).each(function () {
2941        var dataRating = $(this).attr("data-rating");
2942
2943        // Rules
2944        if (dataRating >= 4.0) {
2945          $(this).addClass("high");
2946          $(this)
2947            .find(".rating-bars-rating-inner")
2948            .css({ width: (dataRating / 5) * 100 + "%" });
2949        } else if (dataRating >= 3.0) {
2950          $(this).addClass("mid");
2951          $(this)
2952            .find(".rating-bars-rating-inner")
2953            .css({ width: (dataRating / 5) * 80 + "%" });
2954        } else if (dataRating < 3.0) {
2955          $(this).addClass("low");
2956          $(this)
2957            .find(".rating-bars-rating-inner")
2958            .css({ width: (dataRating / 5) * 60 + "%" });
2959        }
2960      });
2961    }
2962    ratingOverview(".rating-bars-rating");
2963
2964    $(window).on("resize", function () {
2965      ratingOverview(".rating-bars-rating");
2966    });
2967
2968    /*----------------------------------------------------*/
2969    /*  Recaptcha Holder
2970    /*----------------------------------------------------*/
2971    $(".message-vendor").on("click", function () {
2972      $(".captcha-holder").addClass("visible");
2973    });
2974
2975    if (listeo_core.map_provider == "google") {
2976      $(".show-map-button").on("click", function (event) {
2977        event.preventDefault();
2978        $(".hide-map-on-mobile").toggleClass("map-active");
2979        var text_enabled = $(this).data("enabled");
2980        var text_disabled = $(this).data("disabled");
2981        if ($(".hide-map-on-mobile").hasClass("map-active")) {
2982          $(this).text(text_disabled);
2983          //$( '#listeo-listings-container' ).triggerHandler('show_map');
2984        } else {
2985          $(this).text(text_enabled);
2986        }
2987      });
2988    }
2989    $(window).on("load resize", function () {
2990      $(".full-page-map-container.map-fixed").addClass("hide-map-on-mobile");
2991      $(".fs-inner-container.map-fixed").addClass("hide-map-on-mobile");
2992      $("#map-container").addClass("hide-map-on-mobile");
2993    });
2994
2995    // Mobile Map Collapsible Functionality
2996    function initMobileMapCollapsible() {
2997      var $mapContainer = $('#map-container');
2998      var $body = $('body');
2999      
3000      // Remove loading class
3001      $body.removeClass('mobile-map-collapsible-loading');
3002      
3003      // Clean up previous initialization
3004      $mapContainer.removeClass('mobile-map-collapsible expanded');
3005      $body.removeClass('mobile-map-collapsible-active');
3006      $('.mobile-map-toggle-btn, .mobile-map-collapse-btn').remove();
3007      $mapContainer.off('click.mobileMap click.mobileMapCollapse click.mobileMapPrevent');
3008      $(document).off('click.mobileMapToggle click.mobileMapCollapse');
3009      
3010      // Check if mobile map collapsible is enabled via customizer
3011      if (typeof listeo !== 'undefined' && listeo.mobile_map_collapsible === 'collapsible') {
3012        // Only apply on mobile devices (768px and below)
3013        if ($(window).width() <= 768) {
3014          if ($mapContainer.length) {
3015            $body.addClass('mobile-map-collapsible-active');
3016            // Set initial collapsed state immediately to prevent flash
3017            $mapContainer.addClass('mobile-map-collapsible');
3018            
3019            // Add toggle button overlay
3020            var showMapText = (typeof listeo !== 'undefined' && listeo.mobile_map_show_text) ? listeo.mobile_map_show_text : 'Show Map ';
3021            var toggleBtn = '<div class="mobile-map-toggle-btn">' + showMapText + '</div>';
3022            $mapContainer.append(toggleBtn);
3023            
3024            // Add collapse button
3025            var collapseBtn = '<div class="mobile-map-collapse-btn"><i class="fas fa-chevron-up"></i></div>';
3026            $mapContainer.append(collapseBtn);
3027            
3028            // Toggle button click handler - use direct element binding to prevent conflicts
3029            $(document).on('click.mobileMapToggle', '#map-container .mobile-map-toggle-btn', function(e) {
3030              e.preventDefault();
3031              e.stopPropagation();
3032              $('#map-container').addClass('expanded');
3033              $(this).fadeOut(200);
3034              
3035              // Simple map reinitialization after 300ms
3036              setTimeout(function() {
3037                if (typeof window.map !== 'undefined' && window.map && window.map.invalidateSize) {
3038                  window.map.invalidateSize();
3039                }
3040              }, 300);
3041            });
3042            
3043            // Collapse button click handler - use direct element binding to prevent conflicts
3044            $(document).on('click.mobileMapCollapse', '#map-container .mobile-map-collapse-btn', function(e) {
3045              e.preventDefault();
3046              e.stopPropagation();
3047              $('#map-container').removeClass('expanded');
3048              $('.mobile-map-toggle-btn').fadeIn(200);
3049            });
3050            
3051            // Prevent map interaction when collapsed - only for map elements, not buttons
3052            $mapContainer.on('click.mobileMapPrevent', function(e) {
3053              // Don't trigger if clicking on button elements or if already expanded
3054              if ($mapContainer.hasClass('expanded') || 
3055                  $(e.target).hasClass('mobile-map-toggle-btn') || 
3056                  $(e.target).hasClass('mobile-map-collapse-btn') ||
3057                  $(e.target).closest('.mobile-map-toggle-btn, .mobile-map-collapse-btn').length > 0) {
3058                return;
3059              }
3060              
3061              e.preventDefault();
3062              e.stopPropagation();
3063              $mapContainer.addClass('expanded');
3064              $('.mobile-map-toggle-btn').fadeOut(200);
3065            });
3066          }
3067        }
3068      }
3069      
3070      // Handle hidden option
3071      if (typeof listeo !== 'undefined' && listeo.mobile_map_collapsible === 'hidden') {
3072        if ($(window).width() <= 768) {
3073          $mapContainer.hide();
3074        } else {
3075          $mapContainer.show();
3076        }
3077      } else if (typeof listeo !== 'undefined' && listeo.mobile_map_collapsible === 'default') {
3078        $mapContainer.show();
3079      }
3080    }
3081
3082    // Initialize on document ready and window resize
3083    $(document).ready(function() {
3084      initMobileMapCollapsible();
3085    });
3086    
3087    // Also initialize as early as possible to prevent flash
3088    $(function() {
3089      initMobileMapCollapsible();
3090    });
3091    
3092    // Debounced resize handler
3093    var resizeTimer;
3094    $(window).on('resize', function() {
3095      clearTimeout(resizeTimer);
3096      resizeTimer = setTimeout(function() {
3097        initMobileMapCollapsible();
3098      }, 250);
3099    });
3100
3101    /*----------------------------------------------------*/
3102    /*  Ratings Script
3103/*----------------------------------------------------*/
3104
3105    /*  Numerical Script
3106/*--------------------------*/
3107    $(".numerical-rating").numericalRating();
3108
3109    $(".star-rating").starRating();
3110    // ------------------ End Document ------------------ //
3111
3112    /**
3113     * Initializes sticky sidebar functionality on single listing pages.
3114     *
3115     * @requires jQuery
3116     * @listens window.resize
3117     * @listens window.load
3118     * @listens window.scroll.stickySidebar
3119     */
3120    function initStickySidebar() {
3121      jQuery(document).ready(function ($) {
3122        var sidebar = $(".listeo-single-listing-sidebar");
3123        var stickyWrapper = $(".sticky-wrapper");
3124        var content = $(".listeo-single-listing-content");
3125
3126        if (!sidebar.length || !stickyWrapper.length || !content.length) return; // Exit if elements don't exist
3127
3128        // Only initialize if the outer height of .sticky-wrapper is greater than the sidebar's height
3129        if (stickyWrapper.outerHeight() <= sidebar.outerHeight()) return;
3130
3131        var sidebarContainer = sidebar.get(0); // Native DOM element for sidebar
3132        var lastScrollTop = $(window).scrollTop(); // Track last scroll position
3133
3134        function updateStickySidebarState() {
3135          if ($(window).width() >= 1020) {
3136            sidebar.addClass("sticky-sidebar-enabled");
3137          } else {
3138            sidebar.removeClass("sticky-sidebar-enabled");
3139          }
3140        }
3141
3142        // Run on load and resize
3143        $(window).on("resize load", updateStickySidebarState);
3144
3145        // After full page load, check distance between #footer and sidebar
3146        $(window).on("load", function () {
3147          var footer = $("#footer");
3148          if (!footer.length) return;
3149          var footerTop = footer.offset().top;
3150          var sidebarBottom = sidebar.offset().top + sidebar.outerHeight();
3151          if (footerTop - sidebarBottom < 300) {
3152            sidebar.addClass("overflow-enabled");
3153            // Scroll the overflow-enabled container to the bottom
3154            sidebar.scrollTop(sidebar.prop("scrollHeight"));
3155          }
3156        });
3157
3158        $(window).on("scroll.stickySidebar", function () {
3159          if (!sidebar.hasClass("sticky-sidebar-enabled")) return; // Run sticky logic only when enabled
3160
3161          var scrollTop = $(window).scrollTop();
3162          var stickyWrapperHeight = stickyWrapper.outerHeight();
3163          var stickyOffset = stickyWrapper.offset().top - scrollTop + 200; // Distance from top
3164          var contentBottom = content.offset().top + content.outerHeight(); // Bottom of content
3165          var windowBottom = scrollTop + $(window).height(); // Bottom of viewport
3166
3167          if (stickyOffset <= 0 && windowBottom < contentBottom) {
3168            // Enable scrolling and add 'overflow-enabled' class
3169            sidebar.addClass("overflow-enabled");
3170            var scrollDiff = scrollTop - lastScrollTop;
3171            sidebarContainer.scrollTop += scrollDiff;
3172          } else if (scrollTop < lastScrollTop && stickyOffset > 0) {
3173            // Remove class when scrolling UP past sticky-wrapper
3174            sidebar.removeClass("overflow-enabled");
3175          }
3176
3177          if (windowBottom >= contentBottom) {
3178            // Stop script when reaching end of content
3179            return;
3180          }
3181
3182          lastScrollTop = scrollTop; // Update last scroll position
3183        });
3184      });
3185    }
3186
3187    function checkAndInitStickySidebar() {
3188      var sidebar = $(".listeo-single-listing-sidebar");
3189      var stickyWrapper = $(".sticky-wrapper");
3190
3191      // Only initialize if sticky-wrapper is at least 500px higher than the sidebar.
3192      if (stickyWrapper.outerHeight() >= sidebar.outerHeight() + 500) {
3193        initStickySidebar();
3194      } else {
3195        sidebar.removeClass("sticky-sidebar-enabled");
3196      }
3197    }
3198
3199    jQuery(document).ready(function ($) {
3200      checkAndInitStickySidebar();
3201    });
3202
3203    /*--------------------------------------------------*/
3204    /*  Full Page Jobs Scripts
3205  /*--------------------------------------------------*/
3206    // Sliding Sidebar
3207    $(".enable-filters-button").on("click", function () {
3208      $(".full-page-sidebar").toggleClass("enabled-sidebar");
3209      $(".enable-filters-button").toggleClass("active");
3210      $(".filter-button-tooltip").removeClass("tooltip-visible");
3211    });
3212
3213    // Sticky Filter
3214    $(".full-page-content-container").scroll(function () {
3215      if ($(this).scrollTop() >= 240) {
3216        $(".sticky-filter-button").addClass("btn-visible");
3217      } else {
3218        $(".sticky-filter-button").removeClass("btn-visible");
3219      }
3220    });
3221
3222    //  Enable Filters Button Tooltip
3223    $(window).on("load", function () {
3224      $(".filter-button-tooltip")
3225        .css({
3226          left: $(".enable-filters-button").outerWidth() + 60,
3227        })
3228        .addClass("tooltip-visible");
3229    });
3230  });
3231})(this.jQuery);
3232
3233/*!
3234 * jQuery UI Touch Punch 0.2.3
3235 *
3236 * Copyright 2011–2014, Dave Furfero
3237 * Dual licensed under the MIT or GPL Version 2 licenses.
3238 *
3239 * Depends:
3240 *  jquery.ui.widget.js
3241 *  jquery.ui.mouse.js
3242 */
3243//!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
3244
3245/*!
3246 * zeynepjs v2.2.0
3247 * A light-weight multi-level jQuery side menu plugin.
3248 * It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer
3249 * MIT License
3250 * by Huseyin ELMAS
3251 */
3252!(function (l, s) {
3253  var n = { htmlClass: !0 };
3254  function i(e, t) {
3255    (this.element = e),
3256      (this.eventController = o),
3257      (this.options = l.extend({}, n, t)),
3258      (this.options.initialized = !1),
3259      this.init();
3260  }
3261  (i.prototype.init = function () {
3262    var s = this.element,
3263      e = this.options,
3264      i = this.eventController.bind(this);
3265    !0 !== e.initialized &&
3266      (i("loading"),
3267      s.find("[data-submenu]").on("click", function (e) {
3268        e.preventDefault();
3269        var t,
3270          n = l(this).attr("data-submenu"),
3271          o = l("#" + n);
3272        o.length &&
3273          (i("opening", (t = { subMenu: !0, menuId: n })),
3274          s.find(".submenu.current").removeClass("current"),
3275          o.addClass("opened current"),
3276          s.hasClass("submenu-opened") || s.addClass("submenu-opened"),
3277          s[0].scrollTo({ top: 0 }),
3278          i("opened", t));
3279      }),
3280      s.find("[data-submenu-close]").on("click", function (e) {
3281        e.preventDefault();
3282        var t,
3283          n = l(this).attr("data-submenu-close"),
3284          o = l("#" + n);
3285        o.length &&
3286          (i("closing", (t = { subMenu: !0, menuId: n })),
3287          o.removeClass("opened current"),
3288          s.find(".submenu.opened").last().addClass("current"),
3289          s.find(".submenu.opened").length || s.removeClass("submenu-opened"),
3290          o[0].scrollTo({ top: 0 }),
3291          i("closed", t));
3292      }),
3293      i("load"),
3294      this.options.htmlClass &&
3295        !l("html").hasClass("zeynep-initialized") &&
3296        l("html").addClass("zeynep-initialized"),
3297      (e.initialized = !0));
3298  }),
3299    (i.prototype.open = function () {
3300      this.eventController("opening", { subMenu: !1 }),
3301        this.element.addClass("opened"),
3302        this.options.htmlClass && l("html").addClass("zeynep-opened"),
3303        this.eventController("opened", { subMenu: !1 });
3304    }),
3305    (i.prototype.close = function (e) {
3306      e || this.eventController("closing", { subMenu: !1 }),
3307        this.element.removeClass("opened"),
3308        this.options.htmlClass && l("html").removeClass("zeynep-opened"),
3309        e || this.eventController("closed", { subMenu: !1 });
3310    }),
3311    (i.prototype.destroy = function () {
3312      this.eventController("destroying"),
3313        this.close(!0),
3314        this.element.find(".submenu.opened").removeClass("opened"),
3315        this.element.removeData(s),
3316        this.eventController("destroyed"),
3317        (this.options = n),
3318        this.options.htmlClass && l("html").removeClass("zeynep-initialized"),
3319        delete this.element,
3320        delete this.options,
3321        delete this.eventController;
3322    }),
3323    (i.prototype.on = function (e, t) {
3324      r.call(this, e, t);
3325    });
3326  var o = function (e, t) {
3327      if (this.options[e]) {
3328        if ("function" != typeof this.options[e])
3329          throw Error("event handler must be a function: " + e);
3330        this.options[e].call(this, this.element, this.options, t);
3331      }
3332    },
3333    r = function (e, t) {
3334      if ("string" != typeof e)
3335        throw Error(
3336          "event name is expected to be a string but got: " + typeof e
3337        );
3338      if ("function" != typeof t)
3339        throw Error("event handler is not a function for: " + e);
3340      this.options[e] = t;
3341    };
3342  l.fn[s] = function (e) {
3343    var t, n, o;
3344    return (
3345      (t = l(this[0])),
3346      (n = e),
3347      (o = null),
3348      t.data(s) ? (o = t.data(s)) : ((o = new i(t, n || {})), t.data(s, o)),
3349      o
3350    );
3351  };
3352})(window.jQuery || window.cash, "zeynep");
3353//# sourceMappingURL=zeynep.min.js.map
3354
3355
3356 document.addEventListener("DOMContentLoaded", function () {
3357   const passwordInputs = document.querySelectorAll('input[type="password"]');
3358
3359   passwordInputs.forEach((passwordInput) => {
3360     // Wrap input in a relative container
3361     const wrapper = document.createElement("div");
3362     passwordInput.parentNode.insertBefore(wrapper, passwordInput);
3363     wrapper.appendChild(passwordInput);
3364
3365     // Style input so it doesn't overlap with icon
3366     passwordInput.style.paddingRight = "35px";
3367
3368     // Create the toggle icon
3369     const toggleIcon = document.createElement("i");
3370     toggleIcon.className = "fa-solid fa-eye";
3371     toggleIcon.style.position = "absolute";
3372     toggleIcon.style.top = "51%";
3373     toggleIcon.style.right = "18px";
3374     toggleIcon.style.left = "initial";
3375     toggleIcon.style.transform = "translateY(-50%)";
3376     toggleIcon.style.cursor = "pointer";
3377     toggleIcon.style.fontSize = "16px";
3378     toggleIcon.setAttribute("aria-hidden", "true");
3379
3380     wrapper.appendChild(toggleIcon);
3381
3382     // Toggle visibility
3383     toggleIcon.addEventListener("click", function () {
3384       const isPassword = passwordInput.type === "password";
3385       passwordInput.type = isPassword ? "text" : "password";
3386       toggleIcon.className = isPassword
3387         ? "fa-solid fa-eye-slash"
3388         : "fa-solid fa-eye";
3389     });
3390   });
3391 });

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.