1"use strict"; 2 3function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 4window.Happy = window.Happy || {}; 5(function ($, Happy, w) { 6 var $window = $(w); 7 $(function () { 8 var $container = $('.ha-fsb-container'); 9 if ($container.length > 0) { 10 if (window.history && window.history.pushState) { 11 ha_manage_fsb(); 12 } 13 ; 14 $(document.body).on("added_to_cart", function (event, fragments, cart_hash, $button) { 15 ha_manage_fsb(); 16 }); 17 $(document.body).on("removed_from_cart", function (event, fragments, cart_hash, $button) { 18 ha_manage_fsb(); 19 }); 20 } 21 function ha_manage_fsb() { 22 $.ajax({ 23 url: HappyProLocalize.ajax_url, 24 type: "POST", 25 data: { 26 action: "ha_get_cart_subtotal_action", 27 security: HappyProLocalize.nonce 28 }, 29 success: function success(response) { 30 var $data = JSON.parse(response); 31 var $subTotalAmount = $data.subTotalAmount; 32 if ($data.status == 'true' && $subTotalAmount >= 0) { 33 var $container = $('.ha-fsb-container'); 34 var $elem = $container.find('.ha-fsb-size'); 35 var $settings = $container.data('fsb_settings'); 36 if ($settings != undefined) { 37 var $aimationSpeed = $settings.hasOwnProperty('ha_fsb_animation_speed') ? $settings.ha_fsb_animation_speed : 15; 38 var $progressType = $settings.hasOwnProperty('progress_type') ? $settings.progress_type : 'percent'; 39 var $currencySymbol = $settings.hasOwnProperty('currencySymbol') && $progressType == 'percent' ? '%' : $settings.currencySymbol; 40 var $targetAmount = $settings.hasOwnProperty('target_amount') ? $settings.target_amount : 0; 41 var $totalPercent = 0; 42 if (parseFloat($subTotalAmount) >= parseFloat($targetAmount)) { 43 $totalPercent = 100; 44 } else { 45 if (parseFloat($targetAmount) == 0) { 46 $totalPercent = 0; 47 } else { 48 $totalPercent = parseFloat($subTotalAmount) * 100 / parseFloat($targetAmount); 49 } 50 } 51 $totalPercent = parseFloat(Math.round($totalPercent)) >= 100 ? 100 : parseFloat(Math.round($totalPercent)); 52 var $progressText = $progressType == 'percent' ? $totalPercent : $subTotalAmount; 53 var defaultWidth = $(window).width() <= 768 ? 12 : 5; 54 if ($totalPercent > 0) { 55 $elem.text($progressText + $currencySymbol); 56 $elem.css({ 57 'width': $totalPercent + "%", 58 'transition': 'width ' + $aimationSpeed + 'ms ease-in-out' 59 }); 60 } 61 fsbMessageControl($totalPercent); 62 if ($progressText <= 0) { 63 $elem.css('width', +defaultWidth + "%"); 64 $elem.text('0' + $currencySymbol); 65 } 66 } 67 } 68 }, 69 error: function error(_error) {} 70 }); 71 } 72 ; 73 function fsbMessageControl() { 74 var totalPercent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 75 var fsbContainer = $('.ha-fsb-container'); 76 var settings = fsbContainer.data('fsb_settings'); 77 if (fsbContainer && settings) { 78 if (totalPercent >= 100) { 79 $('.ha-fsb-inner-content').html(settings.fsb_success_message); 80 } else { 81 $('.ha-fsb-inner-content').html(settings.announcement); 82 } 83 } 84 } 85 ; 86 function log(event, item, level) { 87 $(document).on(event, item, level); 88 } 89 var e; 90 e = $(".ha-menu-container"); 91 $(e).each(function () { 92 var button = $(this); 93 if ("yes" != button.attr("ha-dom-added")) { 94 if (0 === button.parents(".elementor-widget-ha-nav-menu").length) { 95 button.parents(".ha-wid-con").addClass("ha_menu_responsive_tablet"); 96 } 97 button.attr("ha-dom-added", "yes"); 98 } 99 }); 100 101 /* 102 $(".ha-dropdown-has > a").on("click", function(event) { 103 if (!$(this).parents(".ha-navbar-nav, .ha-vertical-navbar-nav").hasClass("submenu-click-on-icon") || $(event.target).hasClass("ha-submenu-indicator-wrap")) { 104 event.preventDefault(); 105 var $oElemDragged = $(this).parent().find(">.ha-dropdown, >.ha-megamenu-panel"); 106 $oElemDragged.find(".ha-dropdown-open").removeClass("ha-dropdown-open"); 107 if ($oElemDragged.hasClass("ha-dropdown-open")) { 108 $oElemDragged.removeClass("ha-dropdown-open"); 109 } else { 110 $oElemDragged.addClass("ha-dropdown-open"); 111 } 112 } 113 }); */ 114 115 $(".ha-dropdown-has > a").on("click", function (event) { 116 var dropdownHref = $(this).attr("href"); 117 if (dropdownHref === "#" || typeof dropdownHref === "undefined") { 118 event.preventDefault(); 119 var $oElemDragged = $(this).parent().find(">.ha-dropdown, >.ha-megamenu-panel"); 120 $oElemDragged.find(".ha-dropdown-open").removeClass("ha-dropdown-open"); 121 if ($oElemDragged.hasClass("ha-dropdown-open")) { 122 $oElemDragged.removeClass("ha-dropdown-open"); 123 } else { 124 $oElemDragged.addClass("ha-dropdown-open"); 125 } 126 } else { 127 if (!$(this).parents(".ha-navbar-nav, .ha-vertical-navbar-nav").hasClass("submenu-click-on-icon") || $(event.target).hasClass("ha-submenu-indicator-wrap")) { 128 event.preventDefault(); 129 var $oElemDragged = $(this).parent().find(">.ha-dropdown, >.ha-megamenu-panel"); 130 $oElemDragged.find(".ha-dropdown-open").removeClass("ha-dropdown-open"); 131 if ($oElemDragged.hasClass("ha-dropdown-open")) { 132 $oElemDragged.removeClass("ha-dropdown-open"); 133 } else { 134 $oElemDragged.addClass("ha-dropdown-open"); 135 } 136 } 137 } 138 }); 139 140 // $(".ha-menu-toggler").on("click", function(event) { 141 // event.preventDefault(); 142 143 // var el_form_group = $(this).parents(".ha-menu-container").parent(); 144 // if (el_form_group.length < 1) { 145 // el_form_group = $(this).parent(); 146 // } 147 // var $wrapElement = el_form_group.find(".ha-menu-offcanvas-elements"); 148 // if ($wrapElement.hasClass("active")) { 149 // $wrapElement.removeClass("active"); 150 // } else { 151 // $wrapElement.addClass("active"); 152 // } 153 // }); 154 155 $(".ha-navbar-nav li a").on("click", function (event) { 156 if (!$(this).attr("href") && "ha-submenu-indicator-wrap" == event.target.className) { 157 var thirdItem = $(this); 158 var lnk = thirdItem.get(0); 159 var oldUrl = lnk.href; 160 var sepor = oldUrl.indexOf("#"); 161 var s = thirdItem.parents(".ha-menu-container").hasClass("ha-nav-menu-one-page-yes"); 162 if (-1 !== sepor && oldUrl.length > 1 && s && lnk.pathname == window.location.pathname) { 163 event.preventDefault(); 164 thirdItem.parents(".ha-wid-con").find(".ha-menu-close").trigger("click"); 165 } 166 } 167 }); 168 }); 169 function debounce(func, wait, immediate) { 170 var timeout; 171 return function () { 172 var context = this, 173 args = arguments; 174 var later = function later() { 175 timeout = null;
176 if (!immediate) func.apply(context, args); 177 }; 178 var callNow = immediate && !timeout; 179 clearTimeout(timeout); 180 timeout = setTimeout(later, wait); 181 if (callNow) func.apply(context, args); 182 }; 183 } 184 $window.on("elementor/frontend/init", function () { 185 if (typeof haDisplayCondition != "undefined" && haDisplayCondition.status == "true") { 186 // Set user time in cookie 187 var HappyLocalTimeZone = new Date().toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1]; 188 var ha_secure = document.location.protocol === "https:" ? "secure" : ""; 189 document.cookie = "HappyLocalTimeZone=" + HappyLocalTimeZone + ";SameSite=Strict;" + ha_secure; 190 } else { 191 var now = new Date(); 192 now.setTime(now.getTime() - 1000 * 3600); 193 document.cookie = "HappyLocalTimeZone=;expires=" + now.toUTCString() + ";"; 194 } 195 if (typeof haDisplayConditionInitialLoad != "undefined" && haDisplayConditionInitialLoad.status == true) { 196 if (typeof haDisplayConditionInitialLoad.date != "undefined" && haDisplayConditionInitialLoad.date != "") { 197 var ha_secure = document.location.protocol === "https:" ? "secure" : ""; 198 document.cookie = haDisplayConditionInitialLoad.name_1 + "=" + haDisplayConditionInitialLoad.value_1 + ";expires=" + haDisplayConditionInitialLoad.date + ";" + ha_secure; 199 document.cookie = haDisplayConditionInitialLoad.name + "=" + haDisplayConditionInitialLoad.value + ";expires=" + haDisplayConditionInitialLoad.date + ";" + ha_secure; 200 } else { 201 var ha_secure = document.location.protocol === "https:" ? "secure" : ""; 202 document.cookie = haDisplayConditionInitialLoad.name_1 + "=" + haDisplayConditionInitialLoad.value_1 + ";" + ha_secure; 203 document.cookie = haDisplayConditionInitialLoad.name + "=" + haDisplayConditionInitialLoad.value + ";" + ha_secure; 204 } 205 } 206 var CountDown = function CountDown($scope) { 207 var $item = $scope.find(".ha-countdown"); 208 var $countdown_item = $item.find(".ha-countdown-item"); 209 var $end_action = $item.data("end-action"); 210 var $redirect_link = $item.data("redirect-link"); 211 var $end_action_div = $item.find(".ha-countdown-end-action"); 212 var $editor_mode_on = $scope.hasClass("elementor-element-edit-mode"); 213 $item.countdown({ 214 end: function end() { 215 if (("message" === $end_action || "img" === $end_action) && $end_action_div !== undefined) { 216 $countdown_item.css("display", "none"); 217 $end_action_div.css("display", "block"); 218 } else if ("url" === $end_action && $redirect_link !== undefined && $editor_mode_on !== true) { 219 window.location.replace($redirect_link); 220 } 221 } 222 }); 223 }; 224 var SliderBase = elementorModules.frontend.handlers.Base.extend({ 225 onInit: function onInit() { 226 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 227 this.run(); 228 }, 229 getDefaultSettings: function getDefaultSettings() { 230 return { 231 selectors: { 232 container: ".ha-slider-container" 233 } 234 }; 235 }, 236 getDefaultElements: function getDefaultElements() { 237 var selectors = this.getSettings("selectors"); 238 return { 239 $container: this.$element.find(selectors.container) 240 }; 241 }, 242 getReadySettings: function getReadySettings() { 243 var $this = this; 244 var slidesPerView = parseInt(this.getElementSettings("slides_per_view")) || 1; 245 if (this.getElementSettings("thumbs_navigation") == "yes") { 246 var selectorThumbs = this.elements.$container.find(".ha-slider-gallery-thumbs"); 247 var haGallaryThumbs = new HaSwiper(selectorThumbs[0], { 248 spaceBetween: this.getElementSettings("space_between_thumbs"), 249 freeMode: true, 250 watchSlidesVisibility: true, 251 watchSlidesProgress: true 252 }); 253 } 254 // TODO: Need to fix that in future. Currently, Disabled 255 var tempEffect = this.getElementSettings("effect"); 256 if (tempEffect == 'cube') { 257 tempEffect = false;
258 } 259 var settings = { 260 direction: this.getElementSettings("slider_direction"), 261 slidesPerView: slidesPerView || 1, 262 spaceBetween: parseInt(this.getElementSettings("space_between_slides")) || 0, 263 loop: !!(this.getElementSettings("infinity_loop") || false), 264 speed: parseInt(this.getElementSettings("effect_speed")), 265 effect: this.getElementSettings("slider_type") == "multiple" ? this.getElementSettings("effect_multiple") : tempEffect, 266 ha_animation: this.getElementSettings("slider_content_animation"), 267 sliderType: this.getElementSettings("slider_type") 268 }; 269 if (this.getElementSettings("effect") == "flip") { 270 settings.flipEffect = { 271 limitRotation: true, 272 slideShadows: true 273 }; 274 } 275 // TODO: Need to fix that in future. Currently, Disabled 276 // if (this.getElementSettings("effect") == "cube") { 277 // settings.cubeEffect = { 278 // shadow: true, 279 // slideShadows: true, 280 // shadowOffset: 20, 281 // shadowScale: 0.94, 282 // }; 283 // } 284 if (this.getElementSettings("effect_multiple") == "coverflow") { 285 settings.coverflowEffect = { 286 rotate: 50, 287 stretch: 0, 288 depth: 100, 289 modifier: 1, 290 slideShadows: true 291 }; 292 } 293 if (this.getElementSettings("slider_type") == "multiple") { 294 var bpObj = { 295 desktop: { 296 slidesPerView: slidesPerView || 1, 297 spaceBetween: parseInt(this.getElementSettings("space_between_slides")) || 0 298 } 299 }; 300 var breakpoints = elementorFrontend.config.responsive.breakpoints; 301 $.each(breakpoints, function (idx, val) { 302 if (val.is_enabled) { 303 bpObj[idx] = { 304 screenSize: val.value, 305 slidesPerView: parseInt($this.getElementSettings("slides_per_view_" + idx)) || slidesPerView, 306 spaceBetween: parseInt($this.getElementSettings("space_between_slides_" + idx)) || 0 307 }; 308 } 309 }); 310 settings.customBreakpoints = bpObj; 311 settings.customMultiple = true; 312 } 313 if (this.getElementSettings("autoplay") == "yes") { 314 settings.autoplay = { 315 delay: this.getElementSettings("autoplay_speed"), 316 disableOnInteraction: false, 317 stopOnLastSlide: !(this.getElementSettings("infinity_loop") || false) 318 }; 319 } 320 if (this.getElementSettings("arrow_navigation") == "yes") { 321 var selectorNext = this.elements.$container.find(".ha-slider-next"); 322 var selectorPrev = this.elements.$container.find(".ha-slider-prev"); 323 settings.navigation = { 324 nextEl: selectorNext[0], 325 prevEl: selectorPrev[0] 326 }; 327 } 328 if (this.getElementSettings("pagination_type") == "dots") { 329 var selectorPagi = this.elements.$container.find(".ha-slider-pagination"); 330 settings.pagination = { 331 el: selectorPagi[0], 332 clickable: true 333 }; 334 } 335 if (this.getElementSettings("pagination_type") == "progressbar") { 336 var selectorPagi = this.elements.$container.find(".ha-slider-pagination"); 337 settings.pagination = { 338 el: selectorPagi[0], 339 clickable: true, 340 type: "progressbar" 341 }; 342 } 343 if (this.getElementSettings("pagination_type") == "numbers") { 344 var selectorPagi = this.elements.$container.find(".ha-slider-pagination"); 345 settings.pagination = { 346 el: selectorPagi[0], 347 clickable: true, 348 type: this.getElementSettings("number_pagination_type"), 349 renderBullet: function renderBullet(index, className) { 350 return '<span class="' + className + '">' + (index + 1) + "</span>"; 351 }, 352 renderFraction: function renderFraction(currentClass, totalClass) { 353 return '<span class="' + currentClass + '"></span>' + "<span>/</span>" + '<span class="' + totalClass + '"></span>'; 354 } 355 }; 356 } 357 if (this.getElementSettings("scroll_bar") == "yes") { 358 var selectorScroll = this.elements.$container.find(".ha-slider-scrollbar"); 359 settings.scrollbar = { 360 el: selectorScroll[0], 361 hide: this.getElementSettings("scroll_bar_visibility") == "true", 362 draggable: true 363 }; 364 } 365 if (this.getElementSettings("thumbs_navigation") == "yes") { 366 settings.thumbs = { 367 swiper: haGallaryThumbs 368 }; 369 } 370 return $.extend({}, settings); 371 }, 372 run: function run() { 373 var elContainer = this.elements.$container; 374 var slider = elContainer.find(".ha-slider-container"); 375 var readySettings = this.getReadySettings(); 376 var sliderObj = new HaSwiper(slider[0], readySettings); 377 if (readySettings.customMultiple) { 378 $(window).on('resize', function () { 379 var mode = $('body').attr('data-elementor-device-mode'); 380 sliderObj.params.slidesPerView = readySettings.customBreakpoints[mode].slidesPerView; 381 sliderObj.params.spaceBetween = readySettings.customBreakpoints[mode].spaceBetween; 382 sliderObj.update(); 383 }).resize(); 384 } 385 sliderObj.on("slideChange", function () { 386 if (readySettings.sliderType == "multiple") { 387 return; 388 } 389 var aI = sliderObj.activeIndex; 390 var elSlide = elContainer.find(".ha-slider-slide"); 391 var elSlideContent = elContainer.find(".ha-slider-content"); 392 var currentSlide = elSlideContent.eq(aI); 393 currentSlide.hide(); 394 if (currentSlide.length <= 0) {} 395 setTimeout(function () { 396 currentSlide.show(); 397 }, readySettings.speed); 398 elSlide.eq(aI).find(".elementor-invisible, .animated").each(function (e, t) { 399 var i = $(this).data("settings"); 400 if (i && (i._animation || i.animation)) { 401 var n = i._animation_delay ? i._animation_delay : 0, 402 a = i._animation || i.animation; 403 $(this).removeClass("elementor-invisible"); 404 $(this).addClass(a + " animated"); 405 } 406 }); 407 }); 408 sliderObj.on("transitionEnd", function () { 409 var aI = sliderObj.activeIndex; 410 var elSlide = elContainer.find(".ha-slider-slide"); 411 var elSlideContent = elContainer.find(".ha-slider-content"); 412 var currentSlide = elSlideContent.eq(aI); 413 setTimeout(function () { 414 elSlide.eq(aI).find(".animated").each(function (e, t) { 415 var i = $(this).data("settings"); 416 if (i && (i._animation || i.animation)) { 417 var n = i._animation_delay ? i._animation_delay : 0, 418 a = i._animation || i.animation; 419 $(this).removeClass(a); 420 } 421 }); 422 }, readySettings.speed); 423 }); 424 } 425 }); 426 var CarouselBase = elementorModules.frontend.handlers.Base.extend({ 427 onInit: function onInit() { 428 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 429 this.run(); 430 }, 431 getDefaultSettings: function getDefaultSettings() { 432 return { 433 selectors: { 434 container: ".ha-carousel-container" 435 },
436 arrows: false, 437 dots: false, 438 checkVisible: false, 439 infinite: true, 440 slidesToShow: 3, 441 rows: 0, 442 prevArrow: '<button type="button" class="slick-prev"><i class="fa fa-chevron-left"></i></button>', 443 nextArrow: '<button type="button" class="slick-next"><i class="fa fa-chevron-right"></i></button>' 444 }; 445 }, 446 getDefaultElements: function getDefaultElements() { 447 var selectors = this.getSettings("selectors"); 448 return { 449 $container: this.findElement(selectors.container) 450 }; 451 }, 452 onElementChange: function onElementChange() { 453 this.elements.$container.slick("unslick"); 454 this.run(); 455 }, 456 getReadySettings: function getReadySettings() { 457 var $rtl = $('html[dir="rtl"]').length == 1 || $('body').hasClass('rtl'); 458 if ('yes' == this.getElementSettings('vertical')) { 459 $rtl = false; // for vertical direction rtl is off 460 } 461 var settings = { 462 infinite: !!this.getElementSettings("loop"), 463 autoplay: !!this.getElementSettings("autoplay"), 464 autoplaySpeed: this.getElementSettings("autoplay_speed"), 465 speed: this.getElementSettings("animation_speed"), 466 centerMode: !!this.getElementSettings("center"), 467 vertical: !!this.getElementSettings("vertical"), 468 //slidesToScroll: 1, 469 rtl: $rtl 470 }; 471 switch (this.getElementSettings("navigation")) { 472 case "arrow": 473 settings.arrows = true; 474 break; 475 case "dots": 476 settings.dots = true; 477 break; 478 case "both": 479 settings.arrows = true; 480 settings.dots = true; 481 break; 482 } 483 var slides_to_scroll = !!this.getElementSettings('slides_to_scroll'); 484 settings.slidesToShow = parseInt(this.getElementSettings("slides_to_show")) || 1; 485 settings.slidesToScroll = slides_to_scroll ? parseInt(this.getElementSettings('slides_to_show')) || 1 : 1; 486 settings.responsive = [{ 487 breakpoint: elementorFrontend.config.breakpoints.lg, 488 settings: { 489 slidesToShow: parseInt(this.getElementSettings("slides_to_show_tablet")) || settings.slidesToShow, 490 slidesToScroll: slides_to_scroll ? parseInt(this.getElementSettings('slides_to_show_tablet')) || settings.slidesToShow : 1 491 } 492 }, { 493 breakpoint: elementorFrontend.config.breakpoints.md, 494 settings: { 495 slidesToShow: parseInt(this.getElementSettings("slides_to_show_mobile")) || parseInt(this.getElementSettings("slides_to_show_tablet")) || settings.slidesToShow, 496 slidesToScroll: slides_to_scroll ? parseInt(this.getElementSettings('slides_to_show_mobile')) || parseInt(this.getElementSettings('slides_to_show_tablet')) || settings.slidesToShow : 1 497 } 498 }]; 499 return $.extend({}, this.getSettings(), settings); 500 }, 501 run: function run() { 502 this.elements.$container.slick(this.getReadySettings()); 503 } 504 }); 505 506 // Source Code 507 var SourceCode = function SourceCode($scope) { 508 var $item = $scope.find('.ha-source-code'); 509 var $lng_type = $item.data('lng-type'); 510 var $after_copy_text = $item.data('after-copy'); 511 var $code = $item.find('code.language-' + $lng_type); 512 var $copy_btn = $scope.find('.ha-copy-code-button'); 513 $copy_btn.on('click', function () { 514 var $temp = $("<textarea>"); 515 $(this).append($temp); 516 $temp.val($code.text()).select(); 517 document.execCommand("copy"); 518 $temp.remove(); 519 if ($after_copy_text.length) { 520 $(this).text($after_copy_text); 521 } 522 }); 523 if ($lng_type !== undefined && $code !== undefined) { 524 Prism.highlightElement($code.get(0)); 525 } 526 }; 527 528 // Animated text 529 var AnimatedText = function AnimatedText($scope) { 530 var $item = $scope.find(".cd-headline"), 531 $animationDelay = $item.data("animation-delay"); 532 happyAnimatedText({ 533 selector: $item, 534 animationDelay: $animationDelay 535 }); 536 }; 537 //Instagram Feed 538 var InstagramFeed = function InstagramFeed($scope) { 539 var button = $scope.find(".ha-insta-load-more"); 540 var instagram_wrap = $scope.find(".ha-insta-default"); 541 button.on("click", function (e) { 542 e.preventDefault(); 543 var $self = $(this), 544 query_settings = $self.data("settings"), 545 total = $self.data("total"), 546 items = $scope.find(".ha-insta-item").length; 547 $.ajax({ 548 url: HappyProLocalize.ajax_url, 549 type: "POST", 550 data: { 551 action: "ha_instagram_feed_action", 552 security: HappyProLocalize.nonce, 553 query_settings: query_settings, 554 loaded_item: items 555 }, 556 success: function success(response) { 557 if (total > items) { 558 $(response).appendTo(instagram_wrap); 559 } else { 560 $self.text("All Loaded").addClass("loaded"); 561 setTimeout(function () { 562 $self.css({ 563 display: "none" 564 }); 565 }, 800); 566 } 567 }, 568 error: function error(_error2) {} 569 }); 570 }); 571 }; 572 //Scrolling Image 573 var ScrollingImage = elementorModules.frontend.handlers.Base.extend({ 574 onInit: function onInit() { 575 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 576 this.wrapper = this.$element.find(".ha-scrolling-image-wrapper"); 577 this.run(); 578 }, 579 onElementChange: function onElementChange() { 580 this.run(); 581 }, 582 run: function run() {
583 var container_height = this.wrapper.innerHeight(), 584 container_width = this.wrapper.innerWidth(), 585 image_align = this.wrapper.data("align"), 586 scroll_direction = this.wrapper.data("scroll-direction"), 587 items = this.wrapper.find(".ha-scrolling-image-container"), 588 single_image_box = items.find(".ha-scrolling-image-item"), 589 scroll = "scroll" + image_align + scroll_direction + parseInt(container_height) + parseInt(container_width), 590 duration = this.wrapper.data("duration"), 591 direction = "normal", 592 horizontal_align_width = 10, 593 vertical_align_height = 10; 594 var start = { 595 transform: "translateY(" + container_height + "px)" 596 }, 597 end = { 598 transform: "translateY(-101%)" 599 }; 600 if ("bottom" === scroll_direction || "right" === scroll_direction) { 601 direction = "reverse"; 602 } 603 if ("ha-horizontal" === image_align) { 604 start = { 605 transform: "translateX(" + container_width + "px)" 606 }; 607 end = { 608 transform: "translateX(-101%)" 609 }; 610 single_image_box.each(function () { 611 horizontal_align_width += $(this).outerWidth(true); 612 }); 613 items.css({ 614 width: horizontal_align_width, 615 display: "flex" 616 }); 617 items.find("img").css({ 618 "max-width": "100%" 619 }); 620 single_image_box.css({ 621 display: "inline-flex" 622 }); 623 } 624 if ("ha-vertical" === image_align) { 625 single_image_box.each(function () { 626 vertical_align_height += $(this).outerHeight(true); 627 }); 628 } 629 $.keyframe.define([{ 630 name: scroll, 631 "0%": start, 632 "100%": end 633 }]); 634 items.playKeyframe({ 635 name: scroll, 636 duration: duration.toString() + "ms", 637 timingFunction: "linear", 638 delay: "0s", 639 iterationCount: "infinite", 640 direction: direction, 641 fillMode: "none", 642 complete: function complete() {} 643 }); 644 //console.log(items); 645 //console.log( this.$element.hasClass( "ha-scrolling-image-hover-pause--yes" ) ); 646 647 if (this.$element.hasClass("ha-scrolling-image-hover-pause--yes")) { 648 items.find(".ha-scrolling-image-item").on('mouseover mouseleave', function (e) { 649 var $this = $(this); 650 // console.log(e.type); 651 if (e.type === 'mouseover') { 652 items.pauseKeyframe(); 653 } else if (e.type === 'mouseleave') { 654 items.resumeKeyframe(); 655 } 656 }); 657 } 658 } 659 }); 660 //Pricing Table ToolTip 661 var PricingTableToolTip = function PricingTableToolTip($scope) { 662 var tooltip_area = $scope.find(".ha-pricing-table-feature-tooltip"); 663 tooltip_area.on({ 664 mouseenter: function mouseenter(e) { 665 var $this = $(this), 666 direction = $this[0].getBoundingClientRect(), 667 tooltip = $this.find(".ha-pricing-table-feature-tooltip-text"), 668 tooltipW = tooltip.outerWidth(true), 669 tooltipH = tooltip.outerHeight(true), 670 W_width = $(window).width(), 671 W_height = $(window).height(); 672 tooltip.css({ 673 left: "0", 674 right: "auto", 675 top: "calc(100% + 1px)", 676 bottom: "auto" 677 }); 678 if (W_width - direction.left < tooltipW && direction.right < tooltipW) { 679 tooltip.css({ 680 left: "calc(50% - (" + tooltipW + "px/2))" 681 }); 682 } else if (W_width - direction.left < tooltipW) { 683 tooltip.css({ 684 left: "auto", 685 right: "0" 686 }); 687 } 688 if (W_height - direction.bottom < tooltipH) { 689 tooltip.css({ 690 top: "auto", 691 bottom: "calc(100% + 1px)" 692 }); 693 } 694 } 695 }); 696 }; 697 var TabHandlerBase = elementorModules.frontend.handlers.Base.extend({ 698 $activeContent: null, 699 getDefaultSettings: function getDefaultSettings() { 700 return { 701 selectors: { 702 tabTitle: ".ha-tab__title", 703 tabContent: ".ha-tab__content" 704 }, 705 classes: { 706 active: "ha-tab--active" 707 }, 708 showTabFn: "show", 709 hideTabFn: "hide", 710 toggleSelf: false, 711 hidePrevious: true, 712 autoExpand: true 713 }; 714 }, 715 getDefaultElements: function getDefaultElements() {
716 var selectors = this.getSettings("selectors"); 717 return { 718 $tabTitles: this.findElement(selectors.tabTitle), 719 $tabContents: this.findElement(selectors.tabContent) 720 }; 721 }, 722 activateDefaultTab: function activateDefaultTab() { 723 var settings = this.getSettings(); 724 if (!settings.autoExpand || "editor" === settings.autoExpand && !this.isEdit) { 725 return; 726 } 727 var defaultActiveTab = this.getEditSettings("activeItemIndex") || 1, 728 originalToggleMethods = { 729 showTabFn: settings.showTabFn, 730 hideTabFn: settings.hideTabFn 731 }; 732 // Toggle tabs without animation to avoid jumping 733 this.setSettings({ 734 showTabFn: "show", 735 hideTabFn: "hide" 736 }); 737 this.changeActiveTab(defaultActiveTab); 738 // Return back original toggle effects 739 this.setSettings(originalToggleMethods); 740 }, 741 deactivateActiveTab: function deactivateActiveTab(tabIndex) { 742 var settings = this.getSettings(), 743 activeClass = settings.classes.active, 744 activeFilter = tabIndex ? '[data-tab="' + tabIndex + '"]' : "." + activeClass, 745 $activeTitle = this.elements.$tabTitles.filter(activeFilter), 746 $activeContent = this.elements.$tabContents.filter(activeFilter); 747 $activeTitle.add($activeContent).removeClass(activeClass); 748 $activeContent[settings.hideTabFn](); 749 }, 750 activateTab: function activateTab(tabIndex) { 751 var settings = this.getSettings(), 752 activeClass = settings.classes.active, 753 $requestedTitle = this.elements.$tabTitles.filter('[data-tab="' + tabIndex + '"]'), 754 $requestedContent = this.elements.$tabContents.filter('[data-tab="' + tabIndex + '"]'); 755 $requestedTitle.add($requestedContent).addClass(activeClass); 756 $requestedContent[settings.showTabFn](); 757 }, 758 isActiveTab: function isActiveTab(tabIndex) { 759 return this.elements.$tabTitles.filter('[data-tab="' + tabIndex + '"]').hasClass(this.getSettings("classes.active")); 760 }, 761 bindEvents: function bindEvents() { 762 var _this = this; 763 this.elements.$tabTitles.on({ 764 keydown: function keydown(event) { 765 if ("Enter" === event.key) { 766 if ('A' == event.currentTarget.tagName && event.currentTarget.classList.contains('ha-tab__title')) { 767 //this conditional scope in only for advance tab widget 768 return; 769 } 770 event.preventDefault(); 771 _this.changeActiveTab(event.currentTarget.getAttribute("data-tab")); 772 } 773 }, 774 click: function click(event) { 775 if ('A' == event.currentTarget.tagName && event.currentTarget.classList.contains('ha-tab__title')) { 776 //this conditional scope in only for advance tab widget 777 return; 778 } 779 event.preventDefault(); 780 _this.changeActiveTab(event.currentTarget.getAttribute("data-tab")); 781 // iphone specific scroll to top 782 if (/iPhone/i.test(navigator.userAgent)) { 783 $("body,html,document").scrollTop($(this).offset().top); 784 } 785 } 786 }); 787 this.smoothScrollTabs(); 788 }, 789 onInit: function onInit() { 790 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 791 this.activateDefaultTab(); 792 this.smoothScrollTabs(); 793 }, 794 onEditSettingsChange: function onEditSettingsChange(propertyName) { 795 if ("activeItemIndex" === propertyName) { 796 this.activateDefaultTab(); 797 } 798 }, 799 changeActiveTab: function changeActiveTab(tabIndex) { 800 var isActiveTab = this.isActiveTab(tabIndex), 801 settings = this.getSettings(); 802 if ((settings.toggleSelf || !isActiveTab) && settings.hidePrevious) { 803 this.deactivateActiveTab(); 804 } 805 if (!settings.hidePrevious && isActiveTab) { 806 this.deactivateActiveTab(tabIndex); 807 } 808 if (!isActiveTab) { 809 this.activateTab(tabIndex); 810 } 811 $(document).trigger("ha_TabHandlerBase_changed"); 812 $(window).trigger("resize"); 813 }, 814 smoothScrollTabs: function smoothScrollTabs() { 815 var that = this; 816 var tabTitles = this.$element.find('.ha-tabs__nav .ha-tab__title'); 817 $(window).on("resize", function () { 818 // Check if the screen width is less than or equal to 768px 819 if (window.innerWidth <= 768) { 820 tabTitles.each(function () { 821 $(this).on('click', function () { 822 var container = that.$element.find('.ha-tabs__nav')[0]; 823 if (container) { 824 var containerRect = container.getBoundingClientRect(); 825 var itemRect = this.getBoundingClientRect(); 826 // Calculate the scroll position to center the clicked item 827 var scrollPosition = container.scrollLeft + (itemRect.left - containerRect.left) - containerRect.width / 2 + itemRect.width / 2; 828 829 // Smoothly scroll to the calculated position 830 container.scrollTo({ 831 left: scrollPosition, 832 behavior: 'smooth' 833 }); 834 } 835 }); 836 }); 837 } 838 }).trigger("resize"); 839 } 840 }); 841 var TimeLine = function TimeLine($scope) { 842 var T_ID = $scope.data("id"); 843 var timeline = $scope.find(".ha-timeline-wrap"); 844 var dataScroll = timeline.data("scroll"); 845 var timeline_block = timeline.find(".ha-timeline-block"); 846 var event = "scroll.timelineScroll" + T_ID + " resize.timelineScroll" + T_ID; 847 function scroll_tree() { 848 timeline_block.each(function () { 849 var block_height = $(this).outerHeight(true); 850 var $offsetTop = $(this).offset().top;
851 var window_middle_p = $window.scrollTop() + $window.height() / 2; 852 if ($offsetTop < window_middle_p) { 853 $(this).addClass("ha-timeline-scroll-tree"); 854 } else { 855 $(this).removeClass("ha-timeline-scroll-tree"); 856 } 857 var scroll_tree_wrap = $(this).find(".ha-timeline-tree-inner"); 858 var scroll_height = $window.scrollTop() - scroll_tree_wrap.offset().top + $window.outerHeight() / 2; 859 if ($offsetTop < window_middle_p && timeline_block.hasClass("ha-timeline-scroll-tree")) { 860 if (block_height > scroll_height) { 861 scroll_tree_wrap.css({ 862 height: scroll_height * 1.5 + "px" 863 }); 864 } else { 865 scroll_tree_wrap.css({ 866 height: block_height * 1.2 + "px" 867 }); 868 } 869 } else { 870 scroll_tree_wrap.css("height", "0px"); 871 } 872 }); 873 } 874 if ("yes" === dataScroll) { 875 scroll_tree(); 876 $window.on(event, scroll_tree); 877 } else { 878 $window.off(event); 879 } 880 }; 881 var HotSpots = elementorModules.frontend.handlers.Base.extend({ 882 onInit: function onInit() { 883 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 884 this.init(); 885 }, 886 bindEvents: function bindEvents() { 887 if (!this.isEdit) { 888 this.elements.$items.on("click.spotClick", function (e) { 889 e.preventDefault(); 890 }); 891 } 892 }, 893 getDefaultSettings: function getDefaultSettings() { 894 return { 895 selectors: { 896 item: ".ha-hotspots__item" 897 } 898 }; 899 }, 900 getDefaultElements: function getDefaultElements() { 901 return { 902 $items: this.findElement(this.getSettings("selectors.item")) 903 }; 904 }, 905 onElementChange: function onElementChange(changedProp) { 906 if (!this.hasTipso()) { 907 return; 908 } 909 if (changedProp.indexOf("tooltip_") === 0) { 910 this.elements.$items.tipso("destroy"); 911 this.init(); 912 } 913 }, 914 hasTipso: function hasTipso() { 915 return $.fn["tipso"]; 916 }, 917 init: function init() { 918 var position = this.getElementSettings("tooltip_position"), 919 width = this.getElementSettings("tooltip_width"), 920 background = this.getElementSettings("tooltip_bg_color"), 921 color = this.getElementSettings("tooltip_color"), 922 speed = this.getElementSettings("tooltip_speed"), 923 delay = this.getElementSettings("tooltip_delay"), 924 hideDelay = this.getElementSettings("tooltip_hide_delay"), 925 hideArrow = this.getElementSettings("tooltip_hide_arrow"), 926 hover = this.getElementSettings("tooltip_hover"), 927 elementId = this.getID(); 928 if (!this.hasTipso()) { 929 return; 930 } 931 this.elements.$items.each(function (index, item) { 932 var $item = $(item), 933 target = $item.data("target"), 934 settings = $item.data("settings"), 935 classes = ["ha-hotspots--" + elementId, "elementor-repeater-item-" + target]; 936 $item.tipso({ 937 color: color, 938 width: width.size || 200, 939 position: settings.position || position, 940 speed: speed, 941 delay: delay, 942 showArrow: !hideArrow, 943 tooltipHover: !!hover, 944 hideDelay: hideDelay, 945 background: background, 946 useTitle: false, 947 content: $("#ha-" + target).html(), 948 onBeforeShow: function onBeforeShow($e, e, tooltip) { 949 $(document).find('.elementor-repeater-item-' + target).remove();
950 tooltip.tipso_bubble.addClass(classes.join(" ")); 951 } 952 }); 953 }); 954 } 955 }); 956 var LineChart = function LineChart($scope) { 957 haObserveTarget($scope[0], function () { 958 var $container = $scope.find(".ha-line-chart-container"), 959 $chart_canvas = $scope.find("#ha-line-chart"), 960 settings = $container.data("settings"); 961 if ($container.length) { 962 var chart = new Chart($chart_canvas, settings); 963 } 964 }); 965 }; 966 var RadarChart = function RadarChart($scope) { 967 haObserveTarget($scope[0], function () { 968 var $container = $scope.find(".ha-radar-chart-container"), 969 $chart_canvas = $scope.find("#ha-radar-chart"), 970 settings = $container.data("settings"); 971 if ($container.length) { 972 var chart = new Chart($chart_canvas, settings); 973 } 974 }); 975 }; 976 var PolarChart = function PolarChart($scope) { 977 haObserveTarget($scope[0], function () { 978 var $container = $scope.find(".ha-polar-chart-container"), 979 $chart_canvas = $scope.find("#ha-polar-chart"), 980 settings = $container.data("settings"); 981 if ($container.length) { 982 var chart = new Chart($chart_canvas, settings); 983 } 984 }); 985 }; 986 var PieChart = function PieChart($scope) { 987 haObserveTarget($scope[0], function () { 988 var $container = $scope.find(".ha-pie-chart-container"), 989 $chart_canvas = $scope.find("#ha-pie-chart"), 990 settings = $container.data("settings"); 991 if ($container.length) { 992 var chart = new Chart($chart_canvas, settings); 993 } 994 }); 995 }; 996 var StickyVideoArray = []; 997 var StickyVideo = function StickyVideo($scope) { 998 var $id = "#ha-sticky-video-player-" + $scope.data("id"), 999 $wrap = $scope.find(".ha-sticky-video-wrap"), 1000 $settting = $wrap.data("ha-player"), 1001 $box = $wrap.find(".ha-sticky-video-box"), 1002 $overlay_box = $wrap.find(".ha-sticky-video-overlay"), 1003 $overlay_play = $overlay_box.find(".ha-sticky-video-overlay-icon"), 1004 $sticky_close = $wrap.find(".ha-sticky-video-close i"), 1005 $all_box = $(".ha-sticky-video-box"), 1006 event = "scroll.haStickyVideo" + $scope.data("id"), 1007 set; 1008 var playerAbc = new Plyr($id); 1009 var StickyVideoObject = { 1010 player: playerAbc, 1011 event: event, 1012 player_box: $box 1013 }; 1014 StickyVideoArray.push(StickyVideoObject); 1015 1016 //on ready 1017 playerAbc.on("ready", function (e) { 1018 var $box_plyr = $box.find('.plyr.plyr--video'); 1019 if (true == $settting.autoplay) { 1020 $box_plyr.trigger("click"); 1021 } 1022 }); 1023 1024 //on overlay click 1025 if (0 !== $overlay_box.length) { 1026 var $el = 0 !== $overlay_play.length ? $overlay_play : $overlay_box; 1027 $el.on("click", function () { 1028 playerAbc.play(); 1029 }); 1030 } 1031 //on close sticky 1032 $sticky_close.on("click", function () { 1033 $box.removeClass("sticky"); 1034 $box.addClass("sticky-close"); 1035 playerAbc.pause(); 1036 }); 1037 //on Play 1038 playerAbc.on("play", function (e) { 1039 $overlay_box.css("display", "none"); 1040 if ($box.hasClass("sticky-close")) { 1041 $box.removeClass("sticky-close"); 1042 } 1043 StickyVideoArray.forEach(function (item, index) { 1044 if (item.player !== playerAbc) { 1045 item.player.pause(); 1046 } 1047 if (item.event !== event) { 1048 $window.off(item.event); 1049 } 1050 if (item.player_box !== $box) { 1051 item.player_box.removeClass("sticky"); 1052 } 1053 }); 1054 if (true === $settting.sticky) { 1055 $window.on(event, function () { 1056 var height = $box.outerHeight(true); 1057 var $offsetTop = $wrap.offset().top; 1058 var videoBoxTopPoint = $window.scrollTop(); 1059 var videoBoxMiddlePoint = $offsetTop + height / 2; 1060 if (!$box.hasClass("sticky-close")) { 1061 if (videoBoxMiddlePoint < videoBoxTopPoint) { 1062 $box.addClass("sticky"); 1063 } else { 1064 $box.removeClass("sticky"); 1065 } 1066 } 1067 }); 1068 } else { 1069 $window.off(event); 1070 } 1071 }); 1072 // on pause 1073 playerAbc.on("pause", function (e) { 1074 $window.off(event); 1075 }); 1076 $window.on("load resize", debounce(function () { 1077 var height = $box.find(".plyr").height(); 1078 $wrap.css("min-height", height + "px"); 1079 }, 100)); 1080 }; 1081 1082 //facebook feed 1083 var FacebookFeed = function FacebookFeed($scope) { 1084 var button = $scope.find(".ha-facebook-load-more"); 1085 var facebook_wrap = $scope.find(".ha-facebook-items"); 1086 button.on("click", function (e) { 1087 e.preventDefault(); 1088 var $self = $(this), 1089 query_settings = $self.data("settings"), 1090 total = $self.data("total"), 1091 items = $scope.find(".ha-facebook-item").length; 1092 $.ajax({ 1093 url: HappyProLocalize.ajax_url, 1094 type: "POST", 1095 data: { 1096 action: "ha_facebook_feed_action", 1097 security: HappyProLocalize.nonce, 1098 query_settings: query_settings, 1099 loaded_item: items 1100 }, 1101 success: function success(response) { 1102 if (total > items) { 1103 $(response).appendTo(facebook_wrap); 1104 } else { 1105 $self.text("All Loaded").addClass("loaded"); 1106 setTimeout(function () { 1107 $self.css({ 1108 display: "none" 1109 }); 1110 }, 800); 1111 } 1112 }, 1113 error: function error(_error3) {} 1114 }); 1115 }); 1116 }; 1117 //SmartPostList 1118 var SmartPostList = function SmartPostList($scope) { 1119 var filterWrap = $scope.find(".ha-spl-filter"), 1120 customSelect = $scope.find(".ha-spl-custom-select"),
1121 gridWrap = $scope.find(".ha-spl-grid-area"), 1122 mainWrapper = $scope.find(".ha-spl-wrapper"), 1123 querySettings = mainWrapper.data("settings"), 1124 dataOffset = mainWrapper.attr("data-offset"), 1125 nav = $scope.find(".ha-spl-pagination button"), 1126 navPrev = $scope.find(".ha-spl-pagination button.prev"), 1127 navNext = $scope.find(".ha-spl-pagination button.next"), 1128 filter = $scope.find("ul.ha-spl-filter-list li span"), 1129 event; 1130 customSelect.niceSelect(); 1131 var select = $scope.find(".ha-spl-custom-select li"); 1132 function afterClick(e) { 1133 e.preventDefault(); 1134 var $self = $(this), 1135 dataFilter = filterWrap.attr("data-active"), 1136 dataTotalOffset = mainWrapper.attr("data-total-offset"), 1137 offset = "", 1138 termId = ""; 1139 if (e.target.classList.contains("prev") || e.target.classList.contains("fa-angle-left")) { 1140 if (0 == parseInt(dataTotalOffset)) { 1141 navPrev.attr("disabled", true); 1142 return; 1143 } 1144 offset = 0 !== parseInt(dataTotalOffset) ? parseInt(dataTotalOffset) - parseInt(dataOffset) : "0"; 1145 if (undefined !== dataFilter) { 1146 termId = dataFilter; 1147 } 1148 } else if (e.target.classList.contains("next") || e.target.classList.contains("fa-angle-right")) { 1149 offset = parseInt(dataTotalOffset) + parseInt(dataOffset); 1150 if (undefined !== dataFilter) { 1151 termId = dataFilter; 1152 } 1153 } 1154 if (e.target.hasAttribute("data-value")) { 1155 termId = e.target.dataset["value"]; 1156 filterWrap[0].setAttribute("data-active", termId); 1157 if ("SPAN" === e.target.tagName) { 1158 filter.removeClass("ha-active"); 1159 e.target.classList.toggle("ha-active"); 1160 } 1161 offset = 0; 1162 navPrev.attr("disabled", true); 1163 navNext.removeAttr("disabled"); 1164 } 1165 $.ajax({ 1166 url: HappyProLocalize.ajax_url, 1167 type: "POST", 1168 data: { 1169 action: "ha_smart_post_list_action", 1170 security: HappyProLocalize.nonce, 1171 querySettings: querySettings, 1172 offset: offset, 1173 termId: termId 1174 }, 1175 success: function success(response) { 1176 if ($(response).length > 0) { 1177 gridWrap.css("height", gridWrap.outerHeight(true) + "px"); 1178 gridWrap.html(""); 1179 $(response).appendTo(gridWrap); 1180 gridWrap.css("height", ""); 1181 mainWrapper[0].attributes["data-total-offset"].value = offset; 1182 if (e.target.classList.contains("prev") || e.target.classList.contains("fa-angle-left")) { 1183 navNext.removeAttr("disabled"); 1184 } 1185 if (e.target.classList.contains("next") || e.target.classList.contains("fa-angle-right")) { 1186 navPrev.removeAttr("disabled"); 1187 } 1188 } else { 1189 if (e.target.classList.contains("next") || e.target.classList.contains("fa-angle-right")) { 1190 navNext.attr("disabled", true); 1191 } 1192 } 1193 }, 1194 error: function error(_error4) {} 1195 }); 1196 } 1197 nav.on("click", afterClick); 1198 filter.on("click", afterClick); 1199 select.on("click", afterClick); 1200 }; 1201 1202 //PostGrid 1203 var postGridSkins = ["classic", "hawai", "standard", "monastic", "stylica", "outbox", "crossroad"]; 1204 var PostGrid = function PostGrid($scope) { 1205 var wrapper = $scope.find(".ha-pg-wrapper"), 1206 gridWrap = wrapper.find(".ha-pg-grid-wrap"), 1207 button = wrapper.find("button.ha-pg-loadmore"); 1208 button.on("click", function (e) { 1209 e.preventDefault(); 1210 var $self = $(this), 1211 querySettings = $self.data("settings"), 1212 items = wrapper.find(".ha-pg-item").length; 1213 $self.attr("disabled", true); 1214 $.ajax({ 1215 url: HappyProLocalize.ajax_url, 1216 type: "POST", 1217 data: { 1218 action: "hapro_post_grid_action", 1219 security: HappyProLocalize.nonce, 1220 querySettings: querySettings, 1221 loadedItem: items 1222 }, 1223 beforeSend: function beforeSend() { 1224 $self.find(".eicon-loading").css({ 1225 display: "inline-block" 1226 }); 1227 }, 1228 success: function success(response) { 1229 if (response) { 1230 $(response).each(function () { 1231 var $self = $(this); 1232 if ($self.hasClass("ha-pg-item")) { 1233 $self.addClass("ha-pg-item-loaded").appendTo(gridWrap); 1234 } else { 1235 $self.appendTo(gridWrap); 1236 } 1237 }); 1238 } else { 1239 $self.text("All Loaded").addClass("loaded"); 1240 setTimeout(function () { 1241 $self.css({ 1242 display: "none" 1243 }); 1244 }, 800); 1245 } 1246 $self.find(".eicon-loading").css({ 1247 display: "none" 1248 }); 1249 $self.removeAttr("disabled"); 1250 }, 1251 error: function error(_error5) {} 1252 }); 1253 }); 1254 }; 1255 1256 // Happy Loop Grid 1257 var LoopGrid = function LoopGrid($scope) { 1258 var wrapper = $scope.find(".ha-hlg-wrapper"), 1259 gridWrap = wrapper.find(".ha-hlg-grid-wrap"), 1260 button = wrapper.find("button.ha-hlg-loadmore"), 1261 createTemplate = $scope.find('.hlg-create-template'); 1262 // handle load more button 1263 button.on("click", function (e) { 1264 e.preventDefault(); 1265 var $self = $(this), 1266 querySettings = $self.data("settings"), 1267 items = wrapper.find(".ha-hlg-grid-item").length; 1268 $self.attr("disabled", true); 1269 $.ajax({ 1270 url: HappyProLocalize.ajax_url, 1271 type: "POST", 1272 data: { 1273 action: "hapro_loop_grid_action", 1274 security: HappyProLocalize.nonce, 1275 querySettings: querySettings, 1276 loadedItem: items 1277 }, 1278 beforeSend: function beforeSend() { 1279 $self.find(".eicon-loading").css({ 1280 display: "inline-block" 1281 }); 1282 }, 1283 success: function success(response) { 1284 if (response) { 1285 $(response).each(function () { 1286 var $self = $(this); 1287 if ($self.hasClass("ha-hlg-grid-item")) { 1288 $self.addClass("ha-hlg-grid-item-loaded").appendTo(gridWrap); 1289 } else { 1290 $self.appendTo(gridWrap); 1291 } 1292 }); 1293 } else { 1294 $self.text("All Loaded").addClass("loaded"); 1295 setTimeout(function () { 1296 $self.css({ 1297 display: "none" 1298 }); 1299 }, 800); 1300 } 1301 $self.find(".eicon-loading").css({ 1302 display: "none" 1303 }); 1304 $self.removeAttr("disabled"); 1305 }, 1306 error: function error(_error6) {} 1307 }); 1308 }); 1309 // handle create template 1310 if (createTemplate.length > 0) { 1311 createTemplate.on("click", function (e) { 1312 e.preventDefault(); 1313 window.open($(this).attr('href'), '_blank').focus(); 1314 }); 1315 } 1316 }; 1317 1318 // Advanced Data Table 1319 var DataTable = function DataTable($scope) { 1320 var dataTable = $scope.find(".ha-advanced-table"); 1321 var widgetWrapper = $scope.find(".elementor-widget-container"); 1322 var row_td = $scope.find(".ha-advanced-table__body-row-cell"); 1323 var search = dataTable.data("search") == true ? true : false;
1324 var paging = dataTable.data("paging") == true ? true : false; 1325 var scrollX = dataTable.data("scroll-x") == undefined ? false : true; 1326 if (window.innerWidth <= 767) { 1327 var scrollX = true; 1328 } 1329 if (0 == widgetWrapper.length) { 1330 widgetWrapper = $scope; 1331 } 1332 // DataTables.js settings 1333 $(dataTable).DataTable({ 1334 searching: search, 1335 paging: paging, 1336 orderCellsTop: true, 1337 scrollX: scrollX, 1338 aaSorting: [] 1339 }); 1340 var column_th = $scope.find(".ha-advanced-table__head-column-cell"); 1341 column_th.each(function (index, v) { 1342 $(column_th[index]).css("width", ""); 1343 }); 1344 // export table button 1345 if (dataTable.data("export-table") == true) { 1346 widgetWrapper.prepend('<div class="ha-advanced-table-btn-wrap"><button class="ha-advanced-table-btn">' + dataTable.data("export-table-text") + "</button></div>"); 1347 var dataTableBtn = $scope.find(".ha-advanced-table-btn"); 1348 dataTableBtn.on("click", function () { 1349 var oldDownloadNode = document.querySelector(".ha-advanced-data-table-export"); 1350 if (oldDownloadNode) { 1351 oldDownloadNode.parentNode.removeChild(oldDownloadNode); 1352 } 1353 var csv = []; 1354 dataTable.find("tr").each(function (index, tr) { 1355 var data = []; 1356 $(tr).find("th").each(function (index, th) { 1357 data.push(th.textContent); 1358 }); 1359 $(tr).find("td").each(function (index, td) { 1360 data.push(td.textContent); 1361 }); 1362 csv.push(data.join(",")); 1363 }); 1364 var csvFile = new Blob([csv.join("\n")], { 1365 type: "text/csv" 1366 }); 1367 var downloadNode = document.createElement("a"); 1368 var url = URL.createObjectURL(csvFile); 1369 var date = new Date(); 1370 var options = { 1371 day: "2-digit", 1372 month: "short", 1373 year: "numeric", 1374 hour: "numeric", 1375 minute: "numeric", 1376 second: "numeric" 1377 }; 1378 var formatedDate = date.toLocaleDateString("en-BD", options); 1379 var dateString = JSON.stringify(formatedDate.replace(/[ , :]/g, "-")); 1380 downloadNode.download = "advanced-data-table-" + dateString + "~" + dataTable.data("widget-id") + ".csv"; 1381 downloadNode.setAttribute("href", url); 1382 downloadNode.classList.add("ha-advanced-data-table-export"); 1383 downloadNode.style.visibility = "hidden"; 1384 document.body.appendChild(downloadNode); 1385 downloadNode.click(); 1386 }); 1387 } 1388 //for fit table th&td 1389 $(window).trigger('resize'); 1390 }; 1391 // ModalPopup 1392 var ModalPopup = function ModalPopup($scope) { 1393 var boxWrapper = $scope.find(".ha-modal-popup-box-wrapper"); 1394 var triggerType = boxWrapper.data("trigger-type"); 1395 var trigger = $scope.find(".ha-modal-popup-trigger"); 1396 var overlayClose = $scope.find(".ha-modal-popup-overlay"); 1397 var iconClose = $scope.find(".ha-modal-popup-content-close"); 1398 var modal = $scope.find(".ha-modal-popup-content-wrapper"); 1399 var modalAnimation = modal.data("animation"); 1400 var modalDelay = modal.data("display-delay"); 1401 if ("pageload" == triggerType) { 1402 if (!modal.hasClass("ha-modal-show")) { 1403 setTimeout(function () { 1404 modal.addClass("ha-modal-show"); 1405 modal.find(".ha-modal-animation").addClass(modalAnimation); 1406 }, parseInt(modalDelay)); 1407 } 1408 } else { 1409 trigger.on("click", function (e) { 1410 e.preventDefault(); 1411 var wrapper = $(this).closest(".ha-modal-popup-box-wrapper"), 1412 modal = wrapper.find(".ha-modal-popup-content-wrapper"), 1413 modalAnimation = modal.data("animation"), 1414 modalContent = modal.find(".ha-modal-animation"); 1415 if (!modal.hasClass("ha-modal-show")) { 1416 modal.addClass("ha-modal-show"); 1417 modalContent.addClass(modalAnimation); 1418 } 1419 }); 1420 } 1421 overlayClose.on("click", close_modal); 1422 iconClose.on("click", close_modal); 1423 function close_modal(el) { 1424 var wrap = $(this).closest(".ha-modal-popup-content-wrapper"), 1425 modalAnimation = wrap.data("animation"); 1426 if (wrap != null && wrap.hasClass("ha-modal-show")) { 1427 var doSetTimeout = function doSetTimeout(target, source) { 1428 setTimeout(function () { 1429 target.attr("src", source); 1430 }, 500); 1431 }; 1432 var nVideo = wrap.find("iframe, video"); 1433 $.each(nVideo, function (idx, val) { 1434 var videoSrc = $(this).attr("src"); 1435 $(this).attr("src", "https://happyaddons.com/marvin/index.html"); 1436 doSetTimeout($(this), videoSrc); 1437 }); 1438 wrap.removeClass("ha-modal-show"); 1439 wrap.find("." + modalAnimation).removeClass(modalAnimation); 1440 } 1441 } 1442 }; 1443 //Mini Cart 1444 var miniCart = function miniCart($scope) { 1445 $scope.find(".ha-mini-cart-inner").on("click mouseenter mouseleave", function (e) { 1446 var cart_btn = $(this), 1447 on_click = cart_btn.hasClass("ha-mini-cart-on-click"), 1448 on_hover = cart_btn.hasClass("ha-mini-cart-on-hover"), 1449 popup = cart_btn.find(".ha-mini-cart-popup"); 1450 if (popup.length == 0) { 1451 return; 1452 } 1453 if ("click" === e.type && on_click) { 1454 popup.fadeToggle(); 1455 } 1456 if ("mouseenter" === e.type && on_hover) { 1457 popup.fadeIn(); 1458 } 1459 if ("mouseleave" === e.type && on_hover) { 1460 popup.fadeOut(); 1461 } 1462 }); 1463 if ($scope.find(".ha-mini-cart-popup").length > 0 && $scope.find(".ha-mini-cart-on-click").length > 0) { 1464 $("body").on("click", function (e) { 1465 if ($(e.target).hasClass("ha-mini-cart-popup") || $(e.target).parents().hasClass("ha-mini-cart-popup") || $(e.target).hasClass("ha-mini-cart-button") || $(e.target).parents().hasClass("ha-mini-cart-button")) { 1466 return; 1467 } else { 1468 $scope.find(".ha-mini-cart-popup").removeAttr("style"); 1469 } 1470 }); 1471 } 1472 }; 1473 1474 //Image Scroller 1475 var ImageScroller = elementorModules.frontend.handlers.Base.extend({ 1476 onInit: function onInit() { 1477 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 1478 this.wrapper = this.$element.find(".ha-image-scroller-wrapper"); 1479 this.run(); 1480 }, 1481 onElementChange: function onElementChange() { 1482 this.run(); 1483 }, 1484 run: function run() { 1485 var triggerType = this.wrapper.data("trigger-type"); 1486 if ("hover" !== triggerType) { 1487 return; 1488 } 1489 var figure = this.wrapper.find(".ha-image-scroller-container"); 1490 var scrollType = this.wrapper.data("scroll-type"); 1491 var scrollDirection = this.wrapper.data("scroll-direction"); 1492 var imageScroll = figure.find("img"); 1493 var transformY = imageScroll.height() - figure.height(); 1494 var transformX = imageScroll.width() - figure.width(); 1495 if (scrollType === "vertical" && transformY > 0) { 1496 if ("top" === scrollDirection) { 1497 mouseEvent("translateY", transformY); 1498 } else { 1499 imageScroll.css("transform", "translateY" + "( -" + transformY + "px)"); 1500 mouseEventRevers("translateY", transformY); 1501 } 1502 } 1503 if (scrollType === "horizontal" && transformX > 0) { 1504 if ("left" === scrollDirection) { 1505 mouseEvent("translateX", transformX); 1506 } else { 1507 imageScroll.css("transform", "translateX" + "( -" + transformX + "px)"); 1508 mouseEventRevers("translateX", transformX); 1509 } 1510 } 1511 function mouseEvent(cssProperty, value) { 1512 figure.on("mouseenter", function () { 1513 imageScroll.css("transform", cssProperty + "( -" + value + "px)"); 1514 }); 1515 figure.on("mouseleave", function () { 1516 imageScroll.css("transform", cssProperty + "( 0px)"); 1517 }); 1518 } 1519 function mouseEventRevers(cssProperty, value) { 1520 figure.on("mouseenter", function () { 1521 imageScroll.css("transform", cssProperty + "( 0px)"); 1522 }); 1523 figure.on("mouseleave", function () { 1524 imageScroll.css("transform", cssProperty + "( -" + value + "px)"); 1525 }); 1526 } 1527 } 1528 }); 1529 // Mega Menu 1530 var NavMenu = function _init($scope) { 1531 $scope.find(".ha-menu-toggler").on("click", function (event) { 1532 event.preventDefault(); 1533 var el_form_group = $(this).parents(".ha-menu-container").parent(); 1534 if (el_form_group.length < 1) { 1535 el_form_group = $(this).parent(); 1536 } 1537 var $wrapElement = el_form_group.find(".ha-menu-offcanvas-elements"); 1538 if ($wrapElement.hasClass("active")) { 1539 $wrapElement.removeClass("active"); 1540 } else { 1541 $wrapElement.addClass("active"); 1542 } 1543 }); 1544 if ($scope.find(".ha-menu-container").length > 0) { 1545 var additionalDigits = $scope.find(".ha-wid-con").data("responsive-breakpoint");
1546 var sidebar_mousemove = $scope.find(".ha-megamenu-has"); 1547 var tabPadding = $scope.find(".ha-menu-container").outerHeight(); 1548 1549 // Prevent flashes loading 1550 $(document).ready(function () { 1551 $scope.find(".ha-megamenu-panel").css({ 1552 visibility: "visible" 1553 }); 1554 }); 1555 $(window).on("resize", function () { 1556 $scope.find(".ha-megamenu-panel").css({ 1557 top: tabPadding 1558 }); 1559 }).trigger("resize"); 1560 sidebar_mousemove.on("mouseenter", function () { 1561 var q = $(this).data("vertical-menu"); 1562 var jqel = $(this).children(".ha-megamenu-panel"); 1563 if ($(this).hasClass("ha-dropdown-menu-full_width") && $(this).hasClass("top_position")) { 1564 /** @type {number} */ 1565 var ffleft = Math.floor($(this).position().left - $(this).offset().left); 1566 var $sharepreview = $(this); 1567 $sharepreview.find(".ha-megamenu-panel").css("width", $(window).width()); 1568 $(window).on("resize", function () { 1569 $sharepreview.find(".ha-megamenu-panel").css({ 1570 left: ffleft + "px" 1571 }); 1572 }).trigger("resize"); 1573 } 1574 if (!$(this).hasClass("ha-dropdown-menu-full_width") && $(this).hasClass("top_position")) { 1575 $(this).on({ 1576 mouseenter: function setup() { 1577 if (0 === $(".default_menu_position").length) { 1578 $(this).parents(".elementor-section-wrap").addClass("default_menu_position"); 1579 } 1580 }, 1581 mouseleave: function setup() { 1582 if (0 !== $(".default_menu_position").length) { 1583 $(this).parents(".elementor-section-wrap").removeClass("default_menu_position"); 1584 } 1585 } 1586 }); 1587 } 1588 if (q && q !== undefined) { 1589 if ("string" == typeof q) { 1590 if (/^[0-9]/.test(q)) { 1591 $(window).on("resize", function () { 1592 jqel.css({ 1593 width: q 1594 }); 1595 if (!($(document).width() > Number(additionalDigits))) { 1596 jqel.removeAttr("style"); 1597 } 1598 }).trigger("resize"); 1599 } else { 1600 $(window).on("resize", function () { 1601 jqel.css({ 1602 width: q + "px" 1603 }); 1604 if (!($(document).width() > Number(additionalDigits))) { 1605 jqel.removeAttr("style"); 1606 } 1607 }).trigger("resize"); 1608 } 1609 } else { 1610 jqel.css({ 1611 width: q + "px" 1612 }); 1613 } 1614 } else { 1615 $(window).on("resize", function () { 1616 jqel.css({ 1617 width: q + "px" 1618 }); 1619 if (!($(document).width() > Number(additionalDigits))) { 1620 jqel.removeAttr("style"); 1621 } 1622 }).trigger("resize"); 1623 } 1624 }); 1625 sidebar_mousemove.trigger("mouseenter"); 1626 } 1627 }; 1628 elementorFrontend.hooks.addAction("frontend/element_ready/ha-countdown.default", CountDown); 1629 elementorFrontend.hooks.addAction("frontend/element_ready/ha-team-carousel.default", function ($scope) { 1630 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1631 $element: $scope, 1632 selectors: { 1633 container: ".ha-team-carousel-wrap" 1634 }, 1635 prevArrow: '<button type="button" class="slick-prev"><i class="hm hm-arrow-left"></i></button>', 1636 nextArrow: '<button type="button" class="slick-next"><i class="hm hm-arrow-right"></i></button>' 1637 }); 1638 }); 1639 elementorFrontend.hooks.addAction("frontend/element_ready/ha-source-code.default", SourceCode); 1640 elementorFrontend.hooks.addAction("frontend/element_ready/ha-animated-text.default", AnimatedText); 1641 elementorFrontend.hooks.addAction("frontend/element_ready/ha-logo-carousel.default", function ($scope) { 1642 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1643 $element: $scope, 1644 selectors: { 1645 container: ".ha-logo-carousel-wrap" 1646 } 1647 }); 1648 }); 1649 elementorFrontend.hooks.addAction("frontend/element_ready/ha-testimonial-carousel.default", function ($scope) { 1650 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1651 $element: $scope, 1652 selectors: { 1653 container: ".ha-testimonial-carousel__wrap" 1654 } 1655 }); 1656 }); 1657 elementorFrontend.hooks.addAction("frontend/element_ready/ha-advanced-tabs.default", function ($scope) { 1658 elementorFrontend.elementsHandler.addHandler(TabHandlerBase, { 1659 $element: $scope 1660 }); 1661 }); 1662 elementorFrontend.hooks.addAction("frontend/element_ready/ha-instagram-feed.default", InstagramFeed); 1663 elementorFrontend.hooks.addAction("frontend/element_ready/ha-scrolling-image.default", function ($scope) { 1664 elementorFrontend.elementsHandler.addHandler(ScrollingImage, { 1665 $element: $scope 1666 }); 1667 }); 1668 elementorFrontend.hooks.addAction("frontend/element_ready/ha-pricing-table.default", PricingTableToolTip); 1669 elementorFrontend.hooks.addAction("frontend/element_ready/ha-accordion.default", function ($scope) { 1670 elementorFrontend.elementsHandler.addHandler(TabHandlerBase, { 1671 $element: $scope, 1672 selectors: { 1673 tabTitle: ".ha-accordion__item-title", 1674 tabContent: ".ha-accordion__item-content" 1675 }, 1676 classes: { 1677 active: "ha-accordion__item--active" 1678 }, 1679 showTabFn: "slideDown", 1680 hideTabFn: "slideUp" 1681 }); 1682 }); 1683 elementorFrontend.hooks.addAction("frontend/element_ready/ha-toggle.default", function ($scope) { 1684 elementorFrontend.elementsHandler.addHandler(TabHandlerBase, { 1685 $element: $scope, 1686 selectors: { 1687 tabTitle: ".ha-toggle__item-title", 1688 tabContent: ".ha-toggle__item-content" 1689 }, 1690 classes: { 1691 active: "ha-toggle__item--active" 1692 }, 1693 hidePrevious: false, 1694 autoExpand: "editor", 1695 showTabFn: "slideDown", 1696 hideTabFn: "slideUp" 1697 }); 1698 }); 1699 elementorFrontend.hooks.addAction("frontend/element_ready/ha-timeline.default", TimeLine); 1700 elementorFrontend.hooks.addAction("frontend/element_ready/ha-hotspots.default", function ($scope) { 1701 elementorFrontend.elementsHandler.addHandler(HotSpots, { 1702 $element: $scope 1703 }); 1704 }); 1705 elementorFrontend.hooks.addAction("frontend/element_ready/ha-line-chart.default", LineChart); 1706 elementorFrontend.hooks.addAction("frontend/element_ready/ha-pie-chart.default", PieChart); 1707 elementorFrontend.hooks.addAction("frontend/element_ready/ha-polar-chart.default", PolarChart); 1708 elementorFrontend.hooks.addAction("frontend/element_ready/ha-radar-chart.default", RadarChart); 1709 elementorFrontend.hooks.addAction("frontend/element_ready/ha-facebook-feed.default", FacebookFeed); 1710 elementorFrontend.hooks.addAction("frontend/element_ready/ha-smart-post-list.default", SmartPostList); 1711 elementorFrontend.hooks.addAction("frontend/element_ready/ha-advanced-data-table.default", DataTable); 1712 elementorFrontend.hooks.addAction("frontend/element_ready/ha-twitter-carousel.default", function ($scope) { 1713 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1714 $element: $scope, 1715 selectors: { 1716 container: ".ha-tweet-carousel-items" 1717 } 1718 }); 1719 }); 1720 1721 // Post Carousel
1722 elementorFrontend.hooks.addAction("frontend/element_ready/ha-post-carousel.default", function ($scope) { 1723 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1724 $element: $scope, 1725 selectors: { 1726 container: ".ha-posts-carousel-wrapper" 1727 }, 1728 prevArrow: '<button type="button" class="slick-prev"><i class="hm hm-arrow-left"></i></button>', 1729 nextArrow: '<button type="button" class="slick-next"><i class="hm hm-arrow-right"></i></button>' 1730 }); 1731 }); 1732 1733 // EDD Download product carousel 1734 function initEddCarousel($scope) { 1735 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1736 $element: $scope, 1737 selectors: { 1738 container: ".ha-edd-product-carousel-wrapper" 1739 }, 1740 prevArrow: '<button type="button" class="slick-prev"><i class="hm hm-arrow-left"></i></button>', 1741 nextArrow: '<button type="button" class="slick-next"><i class="hm hm-arrow-right"></i></button>' 1742 }); 1743 } 1744 function eddCarouselHandlerCallback($scope) { 1745 initEddCarousel($scope); 1746 initProductQuickView($scope); 1747 1748 // if ( 1749 // $scope 1750 // .find(".ha-edd-product-carousel-wrapper") 1751 // .hasClass("ha-layout-classic") 1752 // ) { 1753 // $scope 1754 // .find(".ha-product-carousel-add-to-cart a") 1755 // .html('<i class="fas fa-shopping-cart"></i>'); 1756 // } 1757 } 1758 1759 // Carousel 1760 elementorFrontend.hooks.addAction("frontend/element_ready/ha-edd-product-carousel.default", eddCarouselHandlerCallback); 1761 1762 // product carousel 1763 function initProductCarousel($scope) { 1764 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1765 $element: $scope, 1766 selectors: { 1767 container: ".ha-product-carousel-wrapper" 1768 }, 1769 prevArrow: '<button type="button" class="slick-prev"><i class="hm hm-arrow-left"></i></button>', 1770 nextArrow: '<button type="button" class="slick-next"><i class="hm hm-arrow-right"></i></button>' 1771 }); 1772 } 1773 function productCarouselHandlerCallback($scope) { 1774 initProductCarousel($scope); 1775 initProductQuickView($scope); 1776 if ($scope.find(".ha-product-carousel-wrapper").hasClass("ha-layout-modern")) { 1777 $scope.find(".ha-product-carousel-add-to-cart a").html('<i class="fas fa-shopping-cart"></i>'); 1778 } 1779 } 1780 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-carousel.classic", productCarouselHandlerCallback); 1781 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-carousel.modern", productCarouselHandlerCallback); 1782 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-carousel-new.default", productCarouselHandlerCallback); 1783 // product category carousel 1784 var productCategoryCarouselSkins = ["classic", "minimal"]; 1785 function initProductCategoryCarousel($scope) { 1786 elementorFrontend.elementsHandler.addHandler(CarouselBase, { 1787 $element: $scope, 1788 selectors: { 1789 container: ".ha-product-cat-carousel" 1790 }, 1791 prevArrow: '<button type="button" class="slick-prev"><i class="hm hm-arrow-left"></i></button>', 1792 nextArrow: '<button type="button" class="slick-next"><i class="hm hm-arrow-right"></i></button>' 1793 }); 1794 } 1795 productCategoryCarouselSkins.forEach(function (index) { 1796 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-category-carousel." + index, initProductCategoryCarousel); 1797 }); 1798 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-category-carousel-new.default", initProductCategoryCarousel); 1799 1800 // EDD category carousel 1801 elementorFrontend.hooks.addAction("frontend/element_ready/ha-edd-category-carousel.default", initProductCategoryCarousel); 1802 postGridSkins.forEach(function (index) { 1803 elementorFrontend.hooks.addAction("frontend/element_ready/ha-post-grid." + index, PostGrid); 1804 }); 1805 elementorFrontend.hooks.addAction("frontend/element_ready/ha-post-grid-new.default", PostGrid); 1806 // elementorFrontend.hooks.addAction("frontend/element_ready/ha-happy-loop-grid.default", PostGrid); 1807 elementorFrontend.hooks.addAction("frontend/element_ready/ha-happy-loop-grid.default", Lo
1807opGrid); 1808 elementorFrontend.hooks.addAction("frontend/element_ready/ha-sticky-video.default", StickyVideo); 1809 elementorFrontend.hooks.addAction("frontend/element_ready/ha-modal-popup.default", ModalPopup); 1810 function initProductQuickView($scope) { 1811 var $button = $scope.find(".ha-pqv-btn"); 1812 if (!$.fn["magnificPopup"]) { 1813 return; 1814 } 1815 $button.magnificPopup({ 1816 type: "ajax", 1817 ajax: { 1818 settings: { 1819 cache: true, 1820 dataType: "html" 1821 }, 1822 cursor: "mfp-ajax-cur", 1823 tError: "The product could not be loaded." 1824 }, 1825 callbacks: { 1826 ajaxContentAdded: function ajaxContentAdded() { 1827 $(this.content).addClass(this.currItem.el.data("modal-class")); 1828 } 1829 } 1830 }); 1831 } 1832 var initOnePageNav = elementorModules.frontend.handlers.Base.extend({ 1833 onInit: function onInit() { 1834 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 1835 this.run(); 1836 }, 1837 onElementChange: function onElementChange(e) { 1838 if (e == 'scroll_wheel' || e == 'touch_swipe' || e == 'scroll_keys') { 1839 this.run(); 1840 } 1841 }, 1842 getReadySettings: function getReadySettings() { 1843 var settings = { 1844 design: this.getElementSettings('select_design'), 1845 speed: this.getElementSettings('scrolling_speed') || 700, 1846 offset: this.getElementSettings('row_to_offset') || 0, 1847 threshold: this.getEditSettings('section_threshold') || 0.50, 1848 scrollWheel: this.getElementSettings('scroll_wheel') == 'yes', 1849 touchSwipe: this.getElementSettings('touch_swipe') == 'yes', 1850 scrollKeys: this.getElementSettings('scroll_keys') == 'yes' 1851 }; 1852 return $.extend({}, this.getSettings(), settings); 1853 }, 1854 scroll: function scroll(id, speed, offset) { 1855 $('html, body').animate({ 1856 scrollTop: $('#' + id).offset().top - offset 1857 }, speed); 1858 }, 1859 run: function run() { 1860 var $this = this; 1861 var settings = this.getReadySettings(); 1862 var track = false; 1863 var $navWrapper = settings.design == 'ha-opn-design-default' ? this.$element.find(".ha-opn-dotted-item") : this.$element.find(".ha_opn__item"); 1864 $navWrapper.on('click', function (e) { 1865 e.preventDefault(); 1866 var targetId = $(this).find('a').data("section-id"); 1867 if ($('#' + targetId).length > 0) { 1868 track = false; 1869 $this.scroll(targetId, settings.speed, settings.offset); 1870 $navWrapper.removeClass('ha_opn__item--current'); 1871 $(this).addClass('ha_opn__item--current'); 1872 } 1873 }); 1874 var sections = []; 1875 var navItems = {}; 1876 if ($navWrapper.length > 0) { 1877 $.each($navWrapper, function (index, nav) { 1878 var targetId = $(this).find('a').data('section-id'); 1879 var targetSection = $('#' + targetId); 1880 sections.push(targetSection[0]); 1881 navItems[targetId] = $(this)[0]; 1882 }); 1883 } 1884 var observerOptions = { 1885 root: null, 1886 rootMargin: "0px 0px -100px 0px", 1887 threshold: settings.threshold 1888 }; 1889 var currentEvent; 1890 var observer = new IntersectionObserver(function (entries) { 1891 entries.forEach(function (entry) { 1892 if (entry.isIntersecting) { 1893 var navItem = navItems[entry.target.id]; 1894 navItem.classList.add('ha_opn__item--current'); 1895 Object.values(navItems).forEach(function (item) { 1896 if (item != navItem) { 1897 item.classList.remove('ha_opn__item--current'); 1898 } 1899 }); 1900 if (typeof elementor === 'undefined') { 1901 if (currentEvent == 'load' && track) { 1902 track = false; 1903 $this.scroll(entry.target.id, settings.speed, settings.offset); 1904 } 1905 if (settings.scrollWheel && currentEvent == 'scroll' && track) { 1906 track = false;
1907 $this.scroll(entry.target.id, settings.speed, settings.offset); 1908 } 1909 if (settings.scrollKeys && currentEvent == 'keys' && track) { 1910 track = false; 1911 $this.scroll(entry.target.id, settings.speed, settings.offset); 1912 } 1913 if (settings.touchSwipe && currentEvent == 'touch' && track) { 1914 track = false; 1915 $this.scroll(entry.target.id, settings.speed, settings.offset); 1916 } 1917 } 1918 } 1919 }); 1920 }, observerOptions); 1921 $(window).on('load', function () { 1922 track = true; 1923 if (sections.length > 0) { 1924 sections.forEach(function (sec) { 1925 if (!(sec == undefined)) { 1926 currentEvent = 'load'; 1927 observer.observe(sec); 1928 } 1929 }); 1930 } 1931 }); 1932 $(window).on('mousewheel DOMMouseScroll', debounce(function (e) { 1933 track = true; 1934 if (sections.length > 0) { 1935 sections.forEach(function (sec) { 1936 if (!(sec == undefined)) { 1937 currentEvent = 'scroll'; 1938 observer.observe(sec); 1939 } 1940 }); 1941 } 1942 }, 200)); 1943 if (typeof elementor === 'undefined') { 1944 if (settings.scrollKeys) { 1945 $(window).on('keydown', debounce(function (evt) { 1946 track = true; 1947 var code = parseInt(evt.keyCode); 1948 // code == 38 for arrow up key 1949 // code == 40 for arrow up key 1950 if (sections.length > 0) { 1951 sections.forEach(function (sec) { 1952 if (!(sec == undefined)) { 1953 currentEvent = 'keys'; 1954 observer.observe(sec); 1955 } 1956 }); 1957 } 1958 }, 200)); 1959 } 1960 if (settings.touchSwipe) { 1961 $(window).on('touchmove', debounce(function (evt) { 1962 track = true; 1963 if (sections.length > 0) { 1964 sections.forEach(function (sec) { 1965 if (!(sec == undefined)) { 1966 currentEvent = 'touch'; 1967 observer.observe(sec); 1968 } 1969 }); 1970 } 1971 }, 200)); 1972 } 1973 } 1974 } 1975 }); 1976 elementorFrontend.hooks.addAction("frontend/element_ready/ha-one-page-nav.default", function ($scope) { 1977 elementorFrontend.elementsHandler.addHandler(initOnePageNav, { 1978 $element: $scope 1979 }); 1980 }); 1981 // advancedSliderHandler 1982 elementorFrontend.hooks.addAction("frontend/element_ready/ha-advanced-slider.default", function ($scope) { 1983 elementorFrontend.elementsHandler.addHandler(SliderBase, { 1984 $element: $scope, 1985 selectors: { 1986 container: ".ha-slider-widget-wrapper" 1987 } 1988 }); 1989 }); 1990 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-grid.classic", initProductQuickView); 1991 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-grid.hover", initProductQuickView); 1992 elementorFrontend.hooks.addAction("frontend/element_ready/ha-product-grid-new.default", initProductQuickView); 1993 elementorFrontend.hooks.addAction("frontend/element_ready/ha-single-product.classic", initProductQuickView); 1994 elementorFrontend.hooks.addAction("frontend/element_ready/ha-single-product.standard", initProductQuickView); 1995 elementorFrontend.hooks.addAction("frontend/element_ready/ha-single-product.landscape", initProductQuickView); 1996 elementorFrontend.hooks.addAction("frontend/element_ready/ha-single-product-new.default", initProductQuickView); 1997 elementorFrontend.hooks.addAction("frontend/element_ready/ha-edd-single-product.default", initProductQuickView); 1998 elementorFrontend.hooks.addAction("frontend/element_ready/ha-edd-product-grid.default", initProductQuickView); 1999 $(document.body).on("added_to_cart", function (event, fragment, hash, $addToCart) { 2000 if ($addToCart != undefined && $addToCart.length > 0) { 2001 $addToCart.parent(".ha-product-grid__btns").removeClass("ha-is--adding").addClass("ha-is--added"); 2002 } 2003 }); 2004 elementorFrontend.hooks.addAction("frontend/element_ready/ha-mini-cart.default", miniCart); 2005 elementorFrontend.hooks.addAction("frontend/element_ready/ha-image-scroller.default", function ($scope) { 2006 elementorFrontend.elementsHandler.addHandler(ImageScroller, { 2007 $element: $scope 2008 }); 2009 }); 2010 elementorFrontend.hooks.addAction("frontend/element_ready/ha-nav-menu.default", NavMenu); 2011 2012 // Off Canvas 2013 var $trigger; 2014 var OffCanvas = function OffCanvas($scope) { 2015 this.node = $scope; 2016 this.wrap = $scope.find(".ha-offcanvas-content-wrap"); 2017 this.cart_wrap = $scope.find(".ha-offcanvas-cart-container"); 2018 this.content = $scope.find(".ha-offcanvas-content"); 2019 this.button = $scope.find(".ha-offcanvas-toggle"); 2020 this.settings = this.wrap.data("settings"); 2021 this.toggle_source = this.settings.toggle_source; 2022 this.id = this.settings.content_id; 2023 this.toggle_id = this.settings.toggle_id; 2024 this.toggle_class = this.settings.toggle_class; 2025 this.transition = this.settings.transition; 2026 this.esc_close = this.settings.esc_close; 2027 this.body_click_close = this.settings.body_click_close; 2028 this.links_click_close = this.settings.links_click_close; 2029 this.direction = this.settings.direction; 2030 this.buttons_position = this.settings.buttons_position; 2031 this.duration = 500; 2032 this.destroy(); 2033 this.init(); 2034 }; 2035 OffCanvas.prototype = { 2036 id: "", 2037 node: "", 2038 wrap: "", 2039 content: "", 2040 button: "", 2041 settings: {}, 2042 transition: "", 2043 duration: 400, 2044 initialized: false, 2045 animations: ["slide", "slide-along", "reveal", "push"],
2046 init: function init() { 2047 if (!this.wrap.length) { 2048 return; 2049 } 2050 $("html").addClass("ha-offcanvas-content-widget"); 2051 if ($(".ha-offcanvas-container").length === 0) { 2052 var faProJs = $("#font-awesome-pro-js").length > 0 ? $("#font-awesome-pro-js").attr("src") : false; 2053 if (faProJs) { 2054 $("#font-awesome-pro-js").remove(); 2055 } 2056 $("body").wrapInner('<div class="ha-offcanvas-container" />'); 2057 this.content.insertBefore(".ha-offcanvas-container"); 2058 if (faProJs) { 2059 $("body").append('<script type="text/javascript" id="font-awesome-pro-js" src="' + faProJs + '"></script>'); 2060 } 2061 } 2062 if (this.wrap.find(".ha-offcanvas-content").length > 0) { 2063 if ($(".ha-offcanvas-container > .ha-offcanvas-content-" + this.id).length > 0) { 2064 $(".ha-offcanvas-container > .ha-offcanvas-content-" + this.id).remove(); 2065 } 2066 if ($("body > .ha-offcanvas-content-" + this.id).length > 0) { 2067 $("body > .ha-offcanvas-content-" + this.id).remove(); 2068 } 2069 $("body").prepend(this.wrap.find(".ha-offcanvas-content")); 2070 } 2071 this.bindEvents(); 2072 }, 2073 destroy: function destroy() { 2074 this.close(); 2075 this.animations.forEach(function (animation) { 2076 if ($("html").hasClass("ha-offcanvas-content-" + animation)) { 2077 $("html").removeClass("ha-offcanvas-content-" + animation); 2078 } 2079 }); 2080 if ($("body > .ha-offcanvas-content-" + this.id).length > 0) { 2081 //$('body > .ha-offcanvas-content-' + this.id ).remove(); 2082 } 2083 }, 2084 setTrigger: function setTrigger() { 2085 var $trigger = false; 2086 if (this.toggle_source == "element-id" && this.toggle_id != "") { 2087 $trigger = $("#" + this.toggle_id); 2088 } else if (this.toggle_source == "element-class" && this.toggle_class != "") { 2089 $trigger = $("." + this.toggle_class); 2090 } else { 2091 $trigger = this.node.find(".ha-offcanvas-toggle"); 2092 } 2093 return $trigger; 2094 }, 2095 bindEvents: function bindEvents() { 2096 $trigger = this.setTrigger(); 2097 if ($trigger) { 2098 $trigger.on("click", $.proxy(this.toggleContent, this)); 2099 } 2100 $("body").delegate(".ha-offcanvas-content .ha-offcanvas-close", "click", $.proxy(this.close, this)); 2101 if (this.links_click_close === "yes") { 2102 $("body").delegate(".ha-offcanvas-content .ha-offcanvas-body a", "click", $.proxy(this.close, this)); 2103 } 2104 if (this.esc_close === "yes") { 2105 this.closeESC(); 2106 } 2107 if (this.body_click_close === "yes") { 2108 this.closeClick(); 2109 } 2110 $(window).resize($.proxy(this._resize, this)); 2111 }, 2112 toggleContent: function toggleContent(e) { 2113 e.preventDefault(); 2114 if (!$("html").hasClass("ha-offcanvas-content-open")) { 2115 this.show(); 2116 } else { 2117 this.close(); 2118 } 2119 this._resize(); 2120 }, 2121 show: function show() { 2122 $(".ha-offcanvas-content-" + this.id).addClass("ha-offcanvas-content-visible"); 2123 // init animation class. 2124 $("html").addClass("ha-offcanvas-content-" + this.transition); 2125 $("html").addClass("ha-offcanvas-content-" + this.direction); 2126 $("html").addClass("ha-offcanvas-content-open"); 2127 $("html").addClass("ha-offcanvas-content-" + this.id + "-open"); 2128 $("html").addClass("ha-offcanvas-content-reset"); 2129 this.button.addClass("ha-is-active"); 2130 this._resize(); 2131 }, 2132 close: function close() { 2133 $("html").removeClass("ha-offcanvas-content-open"); 2134 $("html").removeClass("ha-offcanvas-content-" + this.id + "-open"); 2135 setTimeout($.proxy(function () { 2136 $("html").removeClass("ha-offcanvas-content-reset"); 2137 $("html").removeClass("ha-offcanvas-content-" + this.transition); 2138 $("html").removeClass("ha-offcanvas-content-" + this.direction); 2139 $(".ha-offcanvas-content-" + this.id).removeClass("ha-offcanvas-content-visible"); 2140 }, this), 500); 2141 this.button.removeClass("ha-is-active"); 2142 }, 2143 closeESC: function closeESC() { 2144 var self = this; 2145 if ("" === self.settings.esc_close) { 2146 return; 2147 } 2148 // menu close on ESC key 2149 $(document).on("keydown", function (e) { 2150 if (e.keyCode === 27) { 2151 self.close(); 2152 } 2153 }); 2154 }, 2155 closeClick: function closeClick() { 2156 var self = this; 2157 if (this.toggle_source == "element-id" && this.toggle_id != "") { 2158 $trigger = "#" + this.toggle_id; 2159 } else if (this.toggle_source == "element-class" && this.toggle_class != "") { 2160 $trigger = "." + this.toggle_class; 2161 } else { 2162 $trigger = ".ha-offcanvas-toggle"; 2163 } 2164 $(document).on("click", function (e) { 2165 if ($(e.target).is(".ha-offcanvas-content") || $(e.target).parents(".ha-offcanvas-content").length > 0 || $(e.target).is(".ha-offcanvas-toggle") || $(e.target).parents(".ha-offcanvas-toggle").length > 0 || $(e.target).is($trigger) || $(e.target).parents($trigger).length > 0 || !$(e.target).is(".ha-offcanvas-container")) { 2166 return; 2167 } else { 2168 self.close(); 2169 } 2170 }); 2171 }, 2172 _resize: function _resize() { 2173 if (!this.cart_wrap.length) { 2174 return; 2175 } 2176 var off_canvas = $(".ha-offcanvas-content-" + this.id); 2177 if (off_canvas && off_canvas.length > 0) { 2178 if (this.buttons_position === "bottom") { 2179 var winHeight = window.innerHeight; 2180 var offset = 0; 2181 if ($("body").hasClass("admin-bar")) { 2182 offset = 32; 2183 } 2184 winHeight = winHeight - offset; 2185 off_canvas.find(".ha-offcanvas-inner").css({ 2186 height: winHeight + "px", 2187 top: offset 2188 }); 2189 headerHeight = off_canvas.find(".ha-offcanvas-cart-header").outerHeight(true); 2190 wrapHeight = off_canvas.find(".ha-offcanvas-wrap").outerHeight(); 2191 cartTotalHeight = off_canvas.find(".woocommerce-mini-cart__total").outerHeight(); 2192 cartButtonsHeight = off_canvas.find(".woocommerce-mini-cart__buttons").outerHeight(); 2193 cartMessageHeight = off_canvas.find(".ha-woo-menu-cart-message").outerHeight(); 2194 itemsHeight = winHeight - (headerHeight + cartTotalHeight + cartButtonsHeight + cartMessageHeight); 2195 finalItemsHeight = itemsHeight - (winHeight - wrapHeight); 2196 finalItemsHeight += "px"; 2197 } else { 2198 finalItemsHeight = "auto"; 2199 } 2200 var style = '<style id="ha-woo-style-' + this.id + '">'; 2201 style += "#" + off_canvas.attr("id") + " .woocommerce-mini-cart.cart_list {"; 2202 style += "height: " + finalItemsHeight; 2203 style += "}"; 2204 style += "</style>"; 2205 if ($("#ha-woopack-style-" + this.id).length > 0) { 2206 $("#ha-woopack-style-" + this.id).remove(); 2207 } 2208 $("head").append(style); 2209 } 2210 } 2211 }; 2212 var initOffCanvas = function initOffCanvas($scope, $) { 2213 var content_wrap = $scope.find(".ha-offcanvas-content-wrap"); 2214 if ($(content_wrap).length > 0) { 2215 new OffCanvas($scope); 2216 } 2217 }; 2218 elementorFrontend.hooks.addAction("frontend/element_ready/ha-off-canvas.default", initOffCanvas); 2219 var Unfold = elementorModules.frontend.handlers.Base.extend({ 2220 onInit: function onInit() { 2221 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 2222 this.run(); 2223 }, 2224 onElementChange: function onElementChange(e) { 2225 if (e == "unfold_text" || e == "unfold_icon" || e == "fold_text" || e == "fold_icon" || e == "fold_height" || e == "transition_duration" || e == "trigger") { 2226 this.run(); 2227 if (e == "fold_height") { 2228 this.$element.find(".ha-unfold-data").css("height", this.getCollapseHeight() + "px"); 2229 } 2230 } 2231 }, 2232 getReadySettings: function getReadySettings() { 2233 var settings = { 2234 collapse_height: this.getElementSettings("fold_height") || 50,
2235 collapse_height_tablet: this.getElementSettings("fold_height_tablet") || this.getElementSettings("fold_height") || 50, 2236 collapse_height_mobile: this.getElementSettings("fold_height_mobile") || this.getElementSettings("fold_height_tablet") || this.getElementSettings("fold_height") || 50, 2237 trigger: this.getElementSettings("trigger"), 2238 transition_duration: this.getElementSettings("transition_duration") || 500, 2239 collapse_text: this.getElementSettings("unfold_text"), 2240 collapse_icon: this.getElementSettings("unfold_icon"), 2241 expand_text: this.getElementSettings("fold_text"), 2242 expand_icon: this.getElementSettings("fold_icon") 2243 }; 2244 return $.extend({}, settings); 2245 }, 2246 getCollapseHeight: function getCollapseHeight() { 2247 var body = this.$element.parents("body"); 2248 var unfoldSettings = this.getReadySettings(); 2249 var collapse_height = 50; 2250 if (body.attr("data-elementor-device-mode") == "desktop") { 2251 collapse_height = unfoldSettings.collapse_height; 2252 } 2253 if (body.attr("data-elementor-device-mode") == "tablet") { 2254 collapse_height = unfoldSettings.collapse_height_tablet; 2255 } 2256 if (body.attr("data-elementor-device-mode") == "mobile") { 2257 collapse_height = unfoldSettings.collapse_height_mobile; 2258 } 2259 return collapse_height; 2260 }, 2261 fold: function fold(unfoldData, button, collapse_height, unfoldRender) { 2262 var unfoldSettings = this.getReadySettings(); 2263 var html = unfoldSettings.collapse_icon ? unfoldSettings.collapse_icon.value ? '<i aria-hidden="true" class="' + unfoldSettings.collapse_icon.value + '"></i>' : "" : ""; 2264 html += unfoldSettings.collapse_text ? "<span>" + unfoldSettings.collapse_text + "</span>" : ""; 2265 unfoldData.css({ 2266 "transition-duration": unfoldSettings.transition_duration + "ms", 2267 "height": unfoldRender.outerHeight(true) + 'px' 2268 }); 2269 unfoldData.animate({ 2270 height: collapse_height 2271 }, 0); 2272 var timeOut = setTimeout(function () { 2273 button.html(html); 2274 clearTimeout(timeOut); 2275 }, unfoldSettings.transition_duration); 2276 unfoldData.removeClass("folded"); 2277 }, 2278 unfold: function unfold(unfoldData, unfoldRender, button) { 2279 var unfoldSettings = this.getReadySettings(); 2280 var html = unfoldSettings.expand_icon ? unfoldSettings.expand_icon.value ? '<i aria-hidden="true" class="' + unfoldSettings.expand_icon.value + '"></i>' : "" : ""; 2281 html += unfoldSettings.expand_text ? "<span>" + unfoldSettings.expand_text + "</span>" : ""; 2282 unfoldData.css("transition-duration", unfoldSettings.transition_duration + "ms"); 2283 unfoldData.animate({ 2284 height: unfoldRender.outerHeight(true) 2285 }, 0); 2286 var timeOut = setTimeout(function () { 2287 unfoldData.css("height", 'auto'); 2288 button.html(html); 2289 clearTimeout(timeOut); 2290 }, unfoldSettings.transition_duration); 2291 unfoldData.addClass("folded"); 2292 }, 2293 run: function run() { 2294 var $this = this; 2295 var button = this.$element.find(".ha-unfold-btn"), 2296 unfoldData = this.$element.find(".ha-unfold-data"), 2297 unfoldRender = this.$element.find(".ha-unfold-data-render"); 2298 var unfoldSettings = this.getReadySettings(); 2299 var collapse_height = $this.getCollapseHeight(); 2300 unfoldData.css("height", collapse_height + "px"); 2301 if (unfoldSettings.trigger == "click") { 2302 button.on("click", function () { 2303 collapse_height = $this.getCollapseHeight(); 2304 if (unfoldData.hasClass("folded")) { 2305 $this.fold(unfoldData, button, collapse_height, unfoldRender); 2306 } else { 2307 $this.unfold(unfoldData, unfoldRender, button); 2308 } 2309 }); 2310 } else if (unfoldSettings.trigger == "hover") { 2311 unfoldData.on("mouseenter", function () { 2312 $this.unfold(unfoldData, unfoldRender, button); 2313 }); 2314 unfoldData.on("mouseleave", function () { 2315 collapse_height = $this.getCollapseHeight(); 2316 $this.fold(unfoldData, button, collapse_height, unfoldRender); 2317 }); 2318 } 2319 } 2320 }); 2321 var Maps = elementorModules.frontend.handlers.Base.extend({ 2322 onInit: function onInit() { 2323 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 2324 this.runMap(); 2325 }, 2326 defaultStyle: function defaultStyle() { 2327 var defaultStyles = { 2328 standard: "", 2329 silver: [{ 2330 elementType: "geometry", 2331 stylers: [{ 2332 color: "#f5f5f5" 2333 }] 2334 }, { 2335 elementType: "labels.icon", 2336 stylers: [{ 2337 visibility: "off" 2338 }] 2339 }, { 2340 elementType: "labels.text.fill", 2341 stylers: [{ 2342 color: "#616161" 2343 }] 2344 }, { 2345 elementType: "labels.text.stroke", 2346 stylers: [{ 2347 color: "#f5f5f5" 2348 }] 2349 }, { 2350 featureType: "administrative.land_parcel", 2351 elementType: "labels.text.fill", 2352 stylers: [{ 2353 color: "#bdbdbd" 2354 }] 2355 }, { 2356 featureType: "poi", 2357 elementType: "geometry", 2358 stylers: [{ 2359 color: "#eeeeee" 2360 }] 2361 }, { 2362 featureType: "poi", 2363 elementType: "labels.text.fill", 2364 stylers: [{ 2365 color: "#757575" 2366 }] 2367 }, { 2368 featureType: "poi.park", 2369 elementType: "geometry", 2370 stylers: [{ 2371 color: "#e5e5e5" 2372 }] 2373 }, { 2374 featureType: "poi.park", 2375 elementType: "labels.text.fill", 2376 stylers: [{ 2377 color: "#9e9e9e" 2378 }] 2379 }, { 2380 featureType: "road", 2381 elementType: "geometry", 2382 stylers: [{ 2383 color: "#ffffff" 2384 }] 2385 }, { 2386 featureType: "road.arterial", 2387 elementType: "labels.text.fill", 2388 stylers: [{ 2389 color: "#757575" 2390 }] 2391 }, { 2392 featureType: "road.highway", 2393 elementType: "geometry", 2394 stylers: [{ 2395 color: "#dadada" 2396 }] 2397 }, { 2398 featureType: "road.highway", 2399 elementType: "labels.text.fill", 2400 stylers: [{ 2401 color: "#616161" 2402 }] 2403 }, { 2404 featureType: "road.local", 2405 elementType: "labels.text.fill", 2406 stylers: [{ 2407 color: "#9e9e9e" 2408 }] 2409 }, { 2410 featureType: "transit.line", 2411 elementType: "geometry", 2412 stylers: [{ 2413 color: "#e5e5e5" 2414 }] 2415 }, { 2416 featureType: "transit.station", 2417 elementType: "geometry", 2418 stylers: [{ 2419 color: "#eeeeee" 2420 }] 2421 }, { 2422 featureType: "water", 2423 elementType: "geometry", 2424 stylers: [{ 2425 color: "#c9c9c9" 2426 }] 2427 }, { 2428 featureType: "water", 2429 elementType: "labels.text.fill", 2430 stylers: [{ 2431 color: "#9e9e9e" 2432 }] 2433 }], 2434 retro: [{ 2435 elementType: "geometry", 2436 stylers: [{ 2437 color: "#ebe3cd" 2438 }] 2439 }, { 2440 elementType: "labels.text.fill", 2441 stylers: [{ 2442 color: "#523735" 2443 }] 2444 }, { 2445 elementType: "labels.text.stroke", 2446 stylers: [{ 2447 color: "#f5f1e6" 2448 }] 2449 }, { 2450 featureType: "administrative", 2451 elementType: "geometry.stroke", 2452 stylers: [{ 2453 color: "#c9b2a6" 2454 }] 2455 }, { 2456 featureType: "administrative.land_parcel", 2457 elementType: "geometry.stroke", 2458 stylers: [{ 2459 color: "#dcd2be" 2460 }] 2461 }, { 2462 featureType: "administrative.land_parcel", 2463 elementType: "labels.text.fill", 2464 stylers: [{ 2465 color: "#ae9e90" 2466 }] 2467 }, { 2468 featureType: "landscape.natural", 2469 elementType: "geometry", 2470 stylers: [{ 2471 color: "#dfd2ae" 2472 }] 2473 }, { 2474 featureType: "poi", 2475 elementType: "geometry", 2476 stylers: [{ 2477 color: "#dfd2ae" 2478 }] 2479 }, { 2480 featureType: "poi", 2481 elementType: "labels.text.fill", 2482 stylers: [{ 2483 color: "#93817c" 2484 }] 2485 }, { 2486 featureType: "poi.park", 2487 elementType: "geometry.fill", 2488 stylers: [{ 2489 color: "#a5b076" 2490 }] 2491 }, { 2492 featureType: "poi.park", 2493 elementType: "labels.text.fill", 2494 stylers: [{ 2495 color: "#447530" 2496 }] 2497 }, { 2498 featureType: "road", 2499 elementType: "geometry", 2500 stylers: [{ 2501 color: "#f5f1e6" 2502 }] 2503 }, { 2504 featureType: "road.arterial", 2505 elementType: "geometry", 2506 stylers: [{ 2507 color: "#fdfcf8" 2508 }] 2509 }, { 2510 featureType: "road.highway", 2511 elementType: "geometry", 2512 stylers: [{ 2513 color: "#f8c967" 2514 }] 2515 }, { 2516 featureType: "road.highway", 2517 elementType: "geometry.stroke", 2518 stylers: [{ 2519 color: "#e9bc62" 2520 }] 2521 }, { 2522 featureType: "road.highway.controlled_access", 2523 elementType: "geometry", 2524 stylers: [{ 2525 color: "#e98d58" 2526 }] 2527 }, { 2528 featureType: "road.highway.controlled_access", 2529 elementType: "geometry.stroke", 2530 stylers: [{ 2531 color: "#db8555" 2532 }] 2533 }, { 2534 featureType: "road.local", 2535 elementType: "labels.text.fill", 2536 stylers: [{ 2537 color: "#806b63" 2538 }] 2539 }, { 2540 featureType: "transit.line", 2541 elementType: "geometry", 2542 stylers: [{ 2543 color: "#dfd2ae" 2544 }] 2545 }, { 2546 featureType: "transit.line", 2547 elementType: "labels.text.fill", 2548 stylers: [{ 2549 color: "#8f7d77" 2550 }] 2551 }, { 2552 featureType: "transit.line", 2553 elementType: "labels.text.stroke", 2554 stylers: [{ 2555 color: "#ebe3cd" 2556 }] 2557 }, { 2558 featureType: "transit.station", 2559 elementType: "geometry", 2560 stylers: [{ 2561 color: "#dfd2ae" 2562 }] 2563 }, { 2564 featureType: "water", 2565 elementType: "geometry.fill", 2566 stylers: [{ 2567 color: "#b9d3c2" 2568 }] 2569 }, { 2570 featureType: "water", 2571 elementType: "labels.text.fill", 2572 stylers: [{ 2573 color: "#92998d" 2574 }] 2575 }], 2576 dark: [{ 2577 elementType: "geometry", 2578 stylers: [{ 2579 color: "#212121" 2580 }] 2581 }, { 2582 elementType: "labels.icon", 2583 stylers: [{ 2584 visibility: "off" 2585 }] 2586 }, { 2587 elementType: "labels.text.fill", 2588 stylers: [{ 2589 color: "#757575" 2590 }] 2591 }, { 2592 elementType: "labels.text.stroke", 2593 stylers: [{ 2594 color: "#212121" 2595 }] 2596 }, { 2597 featureType: "administrative", 2598 elementType: "geometry", 2599 stylers: [{ 2600 color: "#757575" 2601 }] 2602 }, { 2603 featureType: "administrative.country", 2604 elementType: "labels.text.fill", 2605 stylers: [{ 2606 color: "#9e9e9e" 2607 }] 2608 }, { 2609 featureType: "administrative.land_parcel", 2610 stylers: [{ 2611 visibility: "off" 2612 }] 2613 }, { 2614 featureType: "administrative.locality", 2615 elementType: "labels.text.fill", 2616 stylers: [{ 2617 color: "#bdbdbd" 2618 }] 2619 }, { 2620 featureType: "poi", 2621 elementType: "labels.text.fill", 2622 stylers: [{ 2623 color: "#757575" 2624 }] 2625 }, { 2626 featureType: "poi.park", 2627 elementType: "geometry", 2628 stylers: [{ 2629 color: "#181818" 2630 }] 2631 }, { 2632 featureType: "poi.park", 2633 elementType: "labels.text.fill", 2634 stylers: [{ 2635 color: "#616161" 2636 }] 2637 }, { 2638 featureType: "poi.park", 2639 elementType: "labels.text.stroke", 2640 stylers: [{ 2641 color: "#1b1b1b" 2642 }] 2643 }, { 2644 featureType: "road", 2645 elementType: "geometry.fill", 2646 stylers: [{ 2647 color: "#2c2c2c" 2648 }] 2649 }, { 2650 featureType: "road", 2651 elementType: "labels.text.fill", 2652 stylers: [{ 2653 color: "#8a8a8a" 2654 }] 2655 }, { 2656 featureType: "road.arterial", 2657 elementType: "geometry", 2658 stylers: [{ 2659 color: "#373737" 2660 }] 2661 }, { 2662 featureType: "road.highway", 2663 elementType: "geometry", 2664 stylers: [{ 2665 color: "#3c3c3c" 2666 }] 2667 }, { 2668 featureType: "road.highway.controlled_access", 2669 elementType: "geometry", 2670 stylers: [{ 2671 color: "#4e4e4e" 2672 }] 2673 }, { 2674 featureType: "road.local", 2675 elementType: "labels.text.fill", 2676 stylers: [{ 2677 color: "#616161" 2678 }] 2679 }, { 2680 featureType: "transit", 2681 elementType: "labels.text.fill", 2682 stylers: [{ 2683 color: "#757575" 2684 }] 2685 }, { 2686 featureType: "water", 2687 elementType: "geometry", 2688 stylers: [{ 2689 color: "#000000" 2690 }] 2691 }, { 2692 featureType: "water", 2693 elementType: "labels.text.fill", 2694 stylers: [{ 2695 color: "#3d3d3d" 2696 }] 2697 }], 2698 night: [{ 2699 elementType: "geometry", 2700 stylers: [{ 2701 color: "#242f3e" 2702 }] 2703 }, { 2704 elementType: "labels.text.fill", 2705 stylers: [{ 2706 color: "#746855" 2707 }] 2708 }, { 2709 elementType: "labels.text.stroke", 2710 stylers: [{ 2711 color: "#242f3e" 2712 }] 2713 }, { 2714 featureType: "administrative.locality", 2715 elementType: "labels.text.fill", 2716 stylers: [{ 2717 color: "#d59563" 2718 }] 2719 }, { 2720 featureType: "poi", 2721 elementType: "labels.text.fill", 2722 stylers: [{ 2723 color: "#d59563" 2724 }] 2725 }, { 2726 featureType: "poi.park", 2727 elementType: "geometry", 2728 stylers: [{ 2729 color: "#263c3f" 2730 }] 2731 }, { 2732 featureType: "poi.park", 2733 elementType: "labels.text.fill", 2734 stylers: [{ 2735 color: "#6b9a76" 2736 }] 2737 }, { 2738 featureType: "road", 2739 elementType: "geometry", 2740 stylers: [{ 2741 color: "#38414e" 2742 }] 2743 }, { 2744 featureType: "road", 2745 elementType: "geometry.stroke", 2746 stylers: [{ 2747 color: "#212a37" 2748 }] 2749 }, { 2750 featureType: "road", 2751 elementType: "labels.text.fill", 2752 stylers: [{ 2753 color: "#9ca5b3" 2754 }] 2755 }, { 2756 featureType: "road.highway", 2757 elementType
2757: "geometry", 2758 stylers: [{ 2759 color: "#746855" 2760 }] 2761 }, { 2762 featureType: "road.highway", 2763 elementType: "geometry.stroke", 2764 stylers: [{ 2765 color: "#1f2835" 2766 }] 2767 }, { 2768 featureType: "road.highway", 2769 elementType: "labels.text.fill", 2770 stylers: [{ 2771 color: "#f3d19c" 2772 }] 2773 }, { 2774 featureType: "transit", 2775 elementType: "geometry", 2776 stylers: [{ 2777 color: "#2f3948" 2778 }] 2779 }, { 2780 featureType: "transit.station", 2781 elementType: "labels.text.fill", 2782 stylers: [{ 2783 color: "#d59563" 2784 }] 2785 }, { 2786 featureType: "water", 2787 elementType: "geometry", 2788 stylers: [{ 2789 color: "#17263c" 2790 }] 2791 }, { 2792 featureType: "water", 2793 elementType: "labels.text.fill", 2794 stylers: [{ 2795 color: "#515c6d" 2796 }] 2797 }, { 2798 featureType: "water", 2799 elementType: "labels.text.stroke", 2800 stylers: [{ 2801 color: "#17263c" 2802 }] 2803 }], 2804 aubergine: [{ 2805 elementType: "geometry", 2806 stylers: [{ 2807 color: "#1d2c4d" 2808 }] 2809 }, { 2810 elementType: "labels.text.fill", 2811 stylers: [{ 2812 color: "#8ec3b9" 2813 }] 2814 }, { 2815 elementType: "labels.text.stroke", 2816 stylers: [{ 2817 color: "#1a3646" 2818 }] 2819 }, { 2820 featureType: "administrative.country", 2821 elementType: "geometry.stroke", 2822 stylers: [{ 2823 color: "#4b6878" 2824 }] 2825 }, { 2826 featureType: "administrative.land_parcel", 2827 elementType: "labels.text.fill", 2828 stylers: [{ 2829 color: "#64779e" 2830 }] 2831 }, { 2832 featureType: "administrative.province", 2833 elementType: "geometry.stroke", 2834 stylers: [{ 2835 color: "#4b6878" 2836 }] 2837 }, { 2838 featureType: "landscape.man_made", 2839 elementType: "geometry.stroke", 2840 stylers: [{ 2841 color: "#334e87" 2842 }] 2843 }, { 2844 featureType: "landscape.natural", 2845 elementType: "geometry", 2846 stylers: [{ 2847 color: "#023e58" 2848 }] 2849 }, { 2850 featureType: "poi", 2851 elementType: "geometry", 2852 stylers: [{ 2853 color: "#283d6a" 2854 }] 2855 }, { 2856 featureType: "poi", 2857 elementType: "labels.text.fill", 2858 stylers: [{ 2859 color: "#6f9ba5" 2860 }] 2861 }, { 2862 featureType: "poi", 2863 elementType: "labels.text.stroke", 2864 stylers: [{ 2865 color: "#1d2c4d" 2866 }] 2867 }, { 2868 featureType: "poi.park", 2869 elementType: "geometry.fill", 2870 stylers: [{ 2871 color: "#023e58" 2872 }] 2873 }, { 2874 featureType: "poi.park", 2875 elementType: "labels.text.fill", 2876 stylers: [{ 2877 color: "#3C7680" 2878 }] 2879 }, { 2880 featureType: "road", 2881 elementType: "geometry", 2882 stylers: [{ 2883 color: "#304a7d" 2884 }] 2885 }, { 2886 featureType: "road", 2887 elementType: "labels.text.fill", 2888 stylers: [{ 2889 color: "#98a5be" 2890 }] 2891 }, { 2892 featureType: "road", 2893 elementType: "labels.text.stroke", 2894 stylers: [{ 2895 color: "#1d2c4d" 2896 }] 2897 }, { 2898 featureType: "road.highway", 2899 elementType: "geometry", 2900 stylers: [{ 2901 color: "#2c6675" 2902 }] 2903 }, { 2904 featureType: "road.highway", 2905 elementType: "geometry.stroke", 2906 stylers: [{ 2907 color: "#255763" 2908 }] 2909 }, { 2910 featureType: "road.highway", 2911 elementType: "labels.text.fill", 2912 stylers: [{ 2913 color: "#b0d5ce" 2914 }] 2915 }, { 2916 featureType: "road.highway", 2917 elementType: "labels.text.stroke", 2918 stylers: [{ 2919 color: "#023e58" 2920 }] 2921 }, { 2922 featureType: "transit", 2923 elementType: "labels.text.fill", 2924 stylers: [{ 2925 color: "#98a5be" 2926 }] 2927 }, { 2928 featureType: "transit", 2929 elementType: "labels.text.stroke", 2930 stylers: [{ 2931 color: "#1d2c4d" 2932 }] 2933 }, { 2934 featureType: "transit.line", 2935 elementType: "geometry.fill", 2936 stylers: [{ 2937 color: "#283d6a"
2938 }] 2939 }, { 2940 featureType: "transit.station", 2941 elementType: "geometry", 2942 stylers: [{ 2943 color: "#3a4762" 2944 }] 2945 }, { 2946 featureType: "water", 2947 elementType: "geometry", 2948 stylers: [{ 2949 color: "#0e1626" 2950 }] 2951 }, { 2952 featureType: "water", 2953 elementType: "labels.text.fill", 2954 stylers: [{ 2955 color: "#4e6d70" 2956 }] 2957 }] 2958 }; 2959 return defaultStyles; 2960 }, 2961 settings: function settings(wrapper) { 2962 var item = document.querySelector(wrapper); 2963 var settings = { 2964 latitude: parseFloat(item.dataset.latitude), 2965 longitude: parseFloat(item.dataset.longitude), 2966 mapType: item.dataset.mapType, 2967 markers: item.dataset.markers, 2968 polylines: item.dataset.polylines, 2969 mapZoom: parseInt(item.dataset.mapZoom), 2970 mapZoomMobile: parseInt(item.dataset.mapZoomMobile), 2971 mapZoomTablet: parseInt(item.dataset.mapZoomTablet), 2972 scrollWheelZoom: item.dataset.scrollWheelZoom, 2973 zoomControl: item.dataset.zoomControl, 2974 fullscreenControl: item.dataset.fullScreen, 2975 mapDraggable: item.dataset.disableMapDrag, 2976 showLegend: item.dataset.showLegend, 2977 showRoute: item.dataset.showRoute, 2978 googleMapType: item.dataset.googleMapType, 2979 mapTypeControl: item.dataset.mapTypeControl, 2980 streetViewControl: item.dataset.streetView, 2981 infoOpen: item.dataset.infoOpen, 2982 infoOpenHover: item.dataset.infoOpenHover, 2983 mapStyle: item.dataset.mapStyle, 2984 customMapStyles: item.dataset.customMapStyle, 2985 defaultStyle: this.defaultStyle(), 2986 strokeColor: item.dataset.strokeColor, 2987 strokeOpacity: item.dataset.strokeOpacity, 2988 strokeWeight: item.dataset.strokeWeight, 2989 strokeFill: item.dataset.strokeFill, 2990 strokeFillOpacity: item.dataset.strokeFillOpacity, 2991 originLat: item.dataset.originLat, 2992 originLng: item.dataset.originLng, 2993 destLat: item.dataset.destLat, 2994 destLng: item.dataset.destLng, 2995 travelMode: item.dataset.travelMode 2996 }; 2997 return settings; 2998 }, 2999 isValidJsonString: function isValidJsonString(jsonString) { 3000 try { 3001 JSON.parse(jsonString); 3002 } catch (e) { 3003 return false; 3004 } 3005 return true; 3006 }, 3007 mapInit: function mapInit(wrapper) { 3008 var settings = this.settings(wrapper); 3009 var markersOptionsArray = JSON.parse(settings.markers); 3010 var map; 3011 var directionsService = new google.maps.DirectionsService(); 3012 var directionsRenderer = new google.maps.DirectionsRenderer(); 3013 var finalZoomLevel = settings.mapZoom; 3014 window.addEventListener("resize", function () { 3015 if (elementorFrontend.getCurrentDeviceMode() == "mobile") { 3016 finalZoomLevel = settings.mapZoomMobile; 3017 } else if (elementorFrontend.getCurrentDeviceMode() == "tablet") { 3018 finalZoomLevel = settings.mapZoomTablet; 3019 } else { 3020 finalZoomLevel = settings.mapZoom; 3021 } 3022 }); 3023 map = new google.maps.Map(document.querySelector(".ha-adv-google-map__wrapper" + wrapper), { 3024 center: { 3025 lat: settings.latitude === "" ? -34.391 : settings.latitude, 3026 lng: settings.longitude === "" ? 150.644 : settings.longitude 3027 }, 3028 zoom: finalZoomLevel, 3029 mapTypeId: settings.mapType, 3030 zoomControl: settings.zoomControl === "yes", 3031 mapTypeControl: settings.mapTypeControl === "yes", 3032 fullscreenControl: settings.fullscreenControl === "yes", 3033 streetViewControl: settings.streetViewControl === "yes", 3034 gestureHandling: settings.scrollWheelZoom === "yes" ? "greedy" : "cooperative", 3035 draggable: settings.mapDraggable !== "yes", 3036 styles: settings.mapStyle !== "custom" ? settings.defaultStyle[settings.mapStyle] : !this.isValidJsonString(settings.customMapStyles) ? "" : JSON.parse(settings.customMapStyles) 3037 }); 3038 if (settings.mapDraggable === "yes") { 3039 map.setOptions({ 3040 draggableCursor: "default" 3041 }); 3042 } 3043 3044 // adding markers and info window on map 3045 markersOptionsArray.forEach(function (option) { 3046 var marker = new google.maps.Marker({ 3047 icon: option.pin_icon.url === "" ? "" : { 3048 url: option.pin_icon.url, 3049 scaledSize: new google.maps.Size(option.rectangular_image === "yes" ? +option.rectangular_pin_size_width.size : +option.square_pin_size.size, option.rectangular_image === "yes" ? +option.rectangular_pin_size_height.size : +option.square_pin_size.size) 3050 }, 3051 map: map, 3052 position: { 3053 lat: +option.pin_latitude, 3054 lng: +option.pin_longitude 3055 } 3056 }); 3057 var infoWindow = new google.maps.InfoWindow({ 3058 content: '<div class="ha-adv-google-map__marker-wrapper">' + '<div class="ha-adv-google-map__marker-title-wrapper">' + '<div class="ha-adv-google-map__marker-title" style="display: inline-block">' + option.pin_item_title + "</div>" + "</div>" + '<div class="ha-adv-google-map__marker-description-wrapper">' + '<div class="ha-adv-google-map__marker-description">' + option.pin_item_description + "</div>" + "</div>" + "</div>" 3059 }); 3060 if (settings.infoOpen === "yes") { 3061 infoWindow.open(map, marker); 3062 } 3063 if (settings.infoOpenHover === "yes") { 3064 marker.addListener("mouseover", function (e) { 3065 infoWindow.open(map, marker); 3066 }); 3067 marker.addListener("mouseout", function (e) { 3068 var timeOut = setTimeout(function () { 3069 infoWindow.close(); 3070 clearTimeout(timeOut); 3071 }, 1000); 3072 }); 3073 } else { 3074 marker.addListener("click", function () { 3075 infoWindow.open(map, marker); 3076 }); 3077 } 3078 }); 3079 3080 // adding map legend 3081 if (settings.showLegend === "yes") { 3082 var legend = document.querySelector(wrapper).nextElementSibling; 3083 map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(legend); 3084 } 3085 if (settings.googleMapType == "polyline") { 3086 var polylines_data = JSON.parse(settings.polylines); 3087 var polylines_arr = []; 3088 polylines_data.forEach(function (polyline) { 3089 polylines_arr.push({ 3090 lat: parseFloat(polyline.ha_gmap_polyline_lat), 3091 lng: parseFloat(polyline.ha_gmap_polyline_lng) 3092 }); 3093 }); 3094 var polyLinePath = JSON.parse(JSON.stringify(polylines_arr)); 3095 var polyPath = new google.maps.Polyline({ 3096 path: polyLinePath, 3097 strokeColor: settings.strokeColor, 3098 strokeOpacity: settings.strokeOpacity, 3099 strokeWeight: settings.strokeWeight 3100 });
3101 polyPath.setMap(map); 3102 } 3103 if (settings.googleMapType == "polygon") { 3104 var polylines_data = JSON.parse(settings.polylines); 3105 var polylines_arr = []; 3106 polylines_data.forEach(function (polyline) { 3107 polylines_arr.push({ 3108 lat: parseFloat(polyline.ha_gmap_polyline_lat), 3109 lng: parseFloat(polyline.ha_gmap_polyline_lng) 3110 }); 3111 }); 3112 var polyLinePath = JSON.parse(JSON.stringify(polylines_arr)); 3113 var polygon = new google.maps.Polygon({ 3114 path: polyLinePath, 3115 strokeColor: settings.strokeColor, 3116 strokeOpacity: settings.strokeOpacity, 3117 strokeWeight: settings.strokeWeight, 3118 fillColor: settings.strokeFill, 3119 fillOpacity: settings.strokeFillOpacity 3120 }); 3121 polygon.setMap(map); 3122 } 3123 if (settings.googleMapType == "routes") { 3124 this.routeDraw(directionsService, directionsRenderer, settings); 3125 directionsRenderer.setMap(map); 3126 } 3127 google.maps.event.addDomListener(window, "resize", function () { 3128 var center = map.getCenter(); 3129 google.maps.event.trigger(map, "resize"); 3130 map.setCenter(center); 3131 map.setZoom(finalZoomLevel); 3132 }); 3133 }, 3134 routeDraw: function routeDraw(directionsService, directionsRenderer, settings) { 3135 var start = settings.originLat + "," + settings.originLng; 3136 var end = settings.destLat + "," + settings.destLng; 3137 directionsService.route({ 3138 origin: { 3139 query: start 3140 }, 3141 destination: { 3142 query: end 3143 }, 3144 travelMode: settings.travelMode.toUpperCase() 3145 }, function (response, status) { 3146 if (status === "OK") { 3147 directionsRenderer.setDirections(response); 3148 } else {} 3149 }); 3150 }, 3151 runMap: function runMap() { 3152 var gmaper = document.querySelectorAll(".ha-adv-google-map__wrapper"); 3153 for (var i = 0; i < gmaper.length; i++) { 3154 gmaper[i].classList.add("ha-adv-google-map__wrapper--item" + i); 3155 this.mapInit(".ha-adv-google-map__wrapper--item" + i); 3156 } 3157 } 3158 }); 3159 elementorFrontend.hooks.addAction("frontend/element_ready/ha-google-map.default", function ($scope) { 3160 elementorFrontend.elementsHandler.addHandler(Maps, { 3161 $element: $scope, 3162 selectors: { 3163 container: ".ha-adv-google-map__wrapper" 3164 } 3165 }); 3166 }); 3167 elementorFrontend.hooks.addAction("frontend/element_ready/ha-unfold.default", function ($scope) { 3168 elementorFrontend.elementsHandler.addHandler(Unfold, { 3169 $element: $scope 3170 }); 3171 }); 3172 var EddCart = function EddCart($scope) { 3173 var optionEL = $scope.find('.ha-edd-table-wrap'); 3174 var settings = optionEL.data('options'); 3175 var removeEl = $scope.find('.edd-remove-from-cart'); 3176 if (settings.cart_btn_type == 'icon') { 3177 removeEl.html("<i class=\"".concat(settings.icon.value, "\"></i>")); 3178 } else { 3179 removeEl.text(settings.btn_text); 3180 } 3181 }; 3182 elementorFrontend.hooks.addAction('frontend/element_ready/ha-edd-cart.default', EddCart); 3183 var EddCheckout = function EddCheckout($scope) { 3184 var optionEL = $scope.find('.ha-edd-table-wrap'); 3185 var settings = optionEL.data('options'); 3186 var removeEl = $scope.find('.edd_cart_remove_item_btn'); 3187 if (settings.cart_btn_type == 'icon') { 3188 removeEl.html("<i class=\"".concat(settings.icon.value, "\"></i>")); 3189 } else { 3190 removeEl.text(settings.btn_text); 3191 } 3192 }; 3193 elementorFrontend.hooks.addAction('frontend/element_ready/ha-edd-checkout.default', EddCheckout); 3194 var EddAjaxBtn = function EddAjaxBtn($scope) { 3195 var btn = $scope.find(".ha_edd_ajax_btn"); 3196 btn.on('click', function (event) { 3197 event.preventDefault(); 3198 var $self = $(this), 3199 download_id = $self.data('download-id'), 3200 nonce = $self.data('nonce'); 3201 $.ajax({ 3202 url: HappyProLocalize.ajax_url, 3203 type: "POST", 3204 data: { 3205 action: "ha_edd_ajax_add_to_cart_link", 3206 security: HappyProLocalize.nonce, 3207 download_id: download_id 3208 }, 3209 success: function success(response) { 3210 if (response.success == true) { 3211 $self.html("<i class=\"fas fa-cart-plus\"></i>"); 3212 } 3213 } 3214 }); 3215 }); 3216 }; 3217 elementorFrontend.hooks.addAction('frontend/element_ready/ha-edd-product-grid.default', EddAjaxBtn); 3218 elementorFrontend.hooks.addAction('frontend/element_ready/ha-edd-product-carou
3218sel.default', EddAjaxBtn); 3219 elementorFrontend.hooks.addAction('frontend/element_ready/ha-edd-single-product.default', EddAjaxBtn); 3220 var Image_Swap = function Image_Swap($scope) { 3221 var element = $scope.find('.ha-image-swap-wrapper'); 3222 var trigger_type = element.data('trigger'); 3223 var status; 3224 if (trigger_type === 'click') { 3225 element.on('click', element, function () { 3226 var self = $(this); 3227 var click = self.attr('data-click'); 3228 if ('inactive' == click) { 3229 status = 'active'; 3230 } else { 3231 status = 'inactive'; 3232 } 3233 self.attr('data-click', status); 3234 var first_img = self.find('.img_swap_first'); 3235 var second_img = self.find('.img_swap_second'); 3236 }); 3237 } 3238 var elm = $scope.find('.ha-image-swap-ctn'); 3239 var elm_img = $scope.find('.ha-image-swap-item'); 3240 var trigger = elm.data('trigger'); 3241 if (elm.length > 0) { 3242 $('.ha-image-swap-ctn').on('click', '.ha-image-swap-item', function (e) { 3243 var elem = $(this); 3244 var parent = elem.parent('.ha-image-swap-insider'); 3245 var firstChild = parent.children('.ha-image-swap-item:first-of-type'); 3246 var secondChild = parent.children('.ha-image-swap-item:nth-of-type(2)'); 3247 if (!elem.is(':first-child')) { 3248 parent.addClass('changed'); 3249 setTimeout(function () { 3250 firstChild.remove(); 3251 parent.append(firstChild); 3252 parent.removeClass('changed'); 3253 }, 400); 3254 } 3255 }); 3256 } 3257 // if( trigger == 'hover'){ 3258 // elm.hover(function (e){ 3259 // var target = e.target; 3260 3261 // if(!$(target).hasClass('active')){ 3262 3263 // var $self = $(this); 3264 // var parent = $self.find('.ha-image-swap-insider'); 3265 // var firstChild = parent.children('.ha-image-swap-item:first-of-type'); 3266 // var secondChild = parent.children('.ha-image-swap-item:nth-of-type(2)'); 3267 3268 // firstChild.toggleClass('active'); 3269 // secondChild.toggleClass('active'); 3270 // } 3271 // }); 3272 // } 3273 }; 3274 var FlipBox = function FlipBox($scope) { 3275 // For Flip Box Back editor mode 3276 var ha_flip_box_back = sessionStorage.getItem('haFlipBoxBack'); 3277 if (elementorFrontend.isEditMode() && ha_flip_box_back && 'yes' == ha_flip_box_back) { 3278 $scope.find('.ha-flip-box-inner').addClass('flip-styling flip'); 3279 } // For Flip Box Back editor mode end 3280 3281 var element = $scope.find('.ha-flip-box-inner'); 3282 // touchstart 3283 element.on('mouseenter mouseleave touchstart', function (e) { 3284 if (elementorFrontend.isEditMode() && $(this).hasClass('flip-styling')) { 3285 return; 3286 } 3287 if (('mouseenter' == e.type || 'touchstart' == e.type) && !$(this).hasClass('flip')) { 3288 $(this).addClass('flip'); 3289 } else if (('mouseleave' == e.type || 'touchstart' == e.type) && $(this).hasClass('flip')) { 3290 $(this).removeClass('flip'); 3291 } else if ('touchstart' == e.type && $(this).hasClass('flip')) { 3292 $(this).removeClass('flip'); 3293 } 3294 }); 3295 }; 3296 elementorFrontend.hooks.addAction('frontend/element_ready/ha-image-swap.default', Image_Swap); 3297 var FreeShippingBar = function FreeShippingBar($scope) { 3298 var $fsbContainer = $scope.find('.ha-fsb-container'); 3299 if ($fsbContainer) { 3300 var $settings = $fsbContainer.data('fsb_settings'); 3301 if ($settings != undefined) { 3302 var $aimationSpeed = $settings.hasOwnProperty('ha_fsb_animation_speed') ? $settings.ha_fsb_animation_speed : 15; 3303 var $achivePercent = $settings.hasOwnProperty('achive_percent') ? $settings.achive_percent : 0; 3304 var $progressType = $settings.hasOwnProperty('progress_type') ? $settings.progress_type : 'percent'; 3305 var $currencySymbol = $settings.hasOwnProperty('currencySymbol') && $progressType == 'percent' ? '%' : $settings.currencySymbol; 3306 var $cartTotal = $settings.hasOwnProperty('cart_total') ? $settings.cart_total : 0; 3307 var $totalPercent = parseFloat(Math.round($achivePercent)) >= 100 ? 100 : parseFloat(Math.round($achivePercent)); 3308 var $progressText = $progressType == 'percent' ? $totalPercent : $cartTotal; 3309 var $elem = $fsbContainer.find('.ha-fsb-size'); 3310 $elem.text($progressText + $currencySymbol); 3311 var defaultWidth = $(window).width() <= 768 ? 12 : 5; 3312 $totalPercent > 0 ? $elem.css({ 3313 'width': $totalPercent + "%", 3314 'transition': 'width ' + $aimationSpeed + 'ms ease-in-out' 3315 }) : $elem.css('width', +defaultWidth + "%"); 3316 } 3317 } 3318 }; 3319 elementorFrontend.hooks.addAction('frontend/element_ready/ha-shipping-bar.default', FreeShippingBar); 3320 $('.fsb-close-icon').on('click', function () { 3321 document.cookie = "ha_close_fsb = yes;path=/"; 3322 $('.ha-fsb-container').hide(); 3323 }); 3324 elementorFrontend.hooks.addAction('frontend/element_ready/ha-flip-box.default', FlipBox
3324); 3325 var HaRemoteCarousel = function HaRemoteCarousel($scope) { 3326 var $rcContainer = $scope.find('.ha-remote-carousel-container'); 3327 if ($rcContainer) { 3328 var $rcBtn = $($rcContainer).find('.ha-custom-nav-remote-carousel'); 3329 if ($rcBtn) { 3330 var $prevSliderIndex = 0; 3331 var $slides_to_show = 0; 3332 var $ha_show_thumbnail = $($rcBtn).parent().data('show_thumbnail'); 3333 var $ha_rc_unique_id = $($rcBtn).parent().data('ha_rc_id'); 3334 var $haRcSelector = $ha_rc_unique_id ? $('[data-ha_rcc_uid="' + $ha_rc_unique_id + '"]') : ''; 3335 if ($ha_show_thumbnail && $ha_show_thumbnail == 'yes') { 3336 $haRcSelector.on('init', function (event, slick, currentSlide) { 3337 var $dataSettingsSelector = $haRcSelector.parent().parent(); 3338 var $dataSettings = $dataSettingsSelector.data('settings'); 3339 $slides_to_show = typeof $dataSettings === "undefined" ? $slides_to_show : $dataSettings.slides_to_show; 3340 $prevSliderIndex = (currentSlide ? currentSlide : 0) - 1; 3341 var $nextIndex = parseInt($slides_to_show) + parseInt($prevSliderIndex) + 1; 3342 var $nextItem = $haRcSelector.find('[data-slick-index="' + $nextIndex + '"]');
3343 var $nextImg = $nextItem.find('img').attr('src'); 3344 var $prevItem = $haRcSelector.find('[data-slick-index="' + $prevSliderIndex + '"]'); 3345 var $prevImg = $prevItem.find('img').attr('src'); 3346 var $nextBtn = $rcContainer.find('.ha-remote-carousel-btn-next'); 3347 var $prevBtn = $rcContainer.find('.ha-remote-carousel-btn-prev'); 3348 $nextBtn.css({ 3349 'background-image': 'url(' + $nextImg + ')', 3350 'background-position': 'center' 3351 }); 3352 $prevBtn.css({ 3353 'background-image': 'url(' + $prevImg + ')', 3354 'background-position': 'center' 3355 }); 3356 }); 3357 $haRcSelector.trigger('init'); 3358 $($rcBtn).on("click", function (e) { 3359 e.preventDefault(); 3360 $haRcSelector.on('afterChange', function (event, slick, currentSlideIndex) { 3361 var $dataSettingsSelector = $haRcSelector.parent().parent(); 3362 var $dataSettings = $dataSettingsSelector.data('settings'); 3363 var $slides_to_show = $dataSettings ? $dataSettings.slides_to_show : currentSlideIndex; 3364 $prevSliderIndex = parseInt(currentSlideIndex - 1); 3365 var $nextIndex = parseInt($slides_to_show) + parseInt($prevSliderIndex) + 1; 3366 var $nextItem = $haRcSelector.find('[data-slick-index="' + $nextIndex + '"]');
3367 var $nextImg = $nextItem.find('img').attr('src'); 3368 var $prevItem = $haRcSelector.find('[data-slick-index="' + $prevSliderIndex + '"]'); 3369 var $prevImg = $prevItem.find('img').attr('src'); 3370 var $nextBtn = $rcContainer.find('.ha-remote-carousel-btn-next'); 3371 var $prevBtn = $rcContainer.find('.ha-remote-carousel-btn-prev'); 3372 if ($nextBtn) { 3373 $nextBtn.css({ 3374 'background-image': 'url(' + $nextImg + ')', 3375 'background-position': 'center' 3376 }); 3377 } 3378 if ($prevBtn) { 3379 $prevBtn.css({ 3380 'background-image': 'url(' + $prevImg + ')', 3381 'background-position': 'center' 3382 }); 3383 } 3384 }); 3385 if ($(this).data("ha_rc_nav") == 'ha_rc_next_btn') { 3386 $haRcSelector.slick("slickNext"); 3387 } else if ($(this).data("ha_rc_nav") == 'ha_rc_prev_btn') { 3388 $haRcSelector.slick("slickPrev"); 3389 } 3390 }); 3391 } else { 3392 $($rcBtn).on("click", function (e) { 3393 e.preventDefault(); 3394 if ($(this).data("ha_rc_nav") == 'ha_rc_next_btn') { 3395 $haRcSelector.slick("slickNext"); 3396 } else if ($(this).data("ha_rc_nav") == 'ha_rc_prev_btn') { 3397 $haRcSelector.slick("slickPrev"); 3398 } 3399 }); 3400 } 3401 } 3402 } 3403 }; 3404 elementorFrontend.hooks.addAction('frontend/element_ready/ha-remote-carousel.default', HaRemoteCarousel); 3405 var HaTOC = elementorModules.frontend.handlers.Base.extend({ 3406 getDefaultSettings: function getDefaultSettings() { 3407 var elementSettings = this.getElementSettings(), 3408 listWrapperTag = "numbers" === elementSettings.marker_view ? "ol" : "ul"; 3409 return { 3410 selectors: { 3411 widgetContainer: ".ha-toc-wrapper", 3412 container: '.elementor:not([data-elementor-type="header"]):not([data-elementor-type="footer"])', 3413 expandButton: ".ha-toc__header", 3414 collapseButton: ".ha-toc__header", 3415 body: ".ha-toc__body", 3416 headerTitle: ".ha-toc__header-title", 3417 scrollTop: ".ha-toc__scroll-to-top--container" 3418 }, 3419 classes: { 3420 anchor: "ha-toc-menu-anchor", 3421 listWrapper: "ha-toc__list-wrapper", 3422 listItem: "ha-toc__list-item", 3423 listTextWrapper: "ha-toc__list-item-text-wrapper", 3424 firstLevelListItem: "ha-toc__top-level", 3425 listItemText: "ha-toc__list-item-text", 3426 activeItem: "ha-toc-item-active", 3427 headingAnchor: "ha-toc__heading-anchor", 3428 collapsed: "ha-toc--collapsed" 3429 }, 3430 listWrapperTag: listWrapperTag 3431 }; 3432 }, 3433 getDefaultElements: function getDefaultElements() { 3434 var settings = this.getSettings(), 3435 elementSettings = this.getElementSettings(); 3436 return { 3437 $pageContainer: jQuery(elementSettings.container || settings.selectors.container), 3438 $widgetContainer: this.$element.find(settings.selectors.widgetContainer), 3439 $expandButton: this.$element.find(settings.selectors.expandButton), 3440 $collapseButton: this.$element.find(settings.selectors.collapseButton), 3441 $tocBody: this.$element.find(settings.selectors.body), 3442 $listItems: this.$element.find("." + settings.classes.listItem), 3443 $scrollTop: this.$element.find(settings.selectors.scrollTop) 3444 }; 3445 }, 3446 bindEvents: function bindEvents() { 3447 var $self = this; 3448 var elementSettings = this.getElementSettings(); 3449 if (elementSettings.minimize_box) { 3450 this.elements.$expandButton.on("click", function () { 3451 if (!$($self.$element).hasClass($self.getSettings("classes.collapsed"))) { 3452 return $self.collapseBox(); 3453 } else { 3454 return $self.expandBox(); 3455 } 3456 }); 3457 } 3458 if (elementSettings.collapse_subitems) { 3459 this.elements.$listItems.hover(function (event) { 3460 return jQuery(event.target).slideToggle(); 3461 }); 3462 } 3463 if (elementSettings.sticky_toc_toggle) { 3464 elementorFrontend.elements.$window.on("resize", this.handleStickyToc); 3465 } 3466 if (elementSettings.scroll_to_top_toggle) { 3467 this.elements.$scrollTop.on("click", function () { 3468 $self.scrollToTop(); 3469 }); 3470 } 3471 }, 3472 getHeadings: function getHeadings() { 3473 // Get all headings from document by user-selected tags 3474 var elementSettings = this.getElementSettings(), 3475 tags = elementSettings.headings_by_tags.join(","),
3476 selectors = this.getSettings("selectors"), 3477 excludedSelectors = elementSettings.exclude_headings_by_selector; 3478 return this.elements.$pageContainer.find(tags).not(selectors.headerTitle).filter(function (index, heading) { 3479 return !jQuery(heading).closest(excludedSelectors).length; // Handle excluded selectors if there are any 3480 }); 3481 }, 3482 addAnchorsBeforeHeadings: function addAnchorsBeforeHeadings() { 3483 var $this = this; 3484 // Add an anchor element right before each TOC heading to create anchors for TOC links 3485 var classes = this.getSettings("classes"); 3486 this.elements.$headings.before(function (index) { 3487 var anchorLink = $this.getHeadingAnchorLink(index, classes); 3488 return '<span id="' + anchorLink + '" class="' + classes.anchor + ' "></span>'; 3489 }); 3490 }, 3491 activateItem: function activateItem($listItem) { 3492 var classes = this.getSettings("classes"); 3493 this.deactivateActiveItem($listItem); 3494 $listItem.addClass(classe
3494s.activeItem); 3495 this.$activeItem = $listItem; 3496 if (!this.getElementSettings("sticky_toc_toggle")) { 3497 //Note:- The "Collapse" option will not work unless you make the Table of Contents sticky. 3498 return; 3499 } 3500 if (!this.getElementSettings("collapse_subitems")) { 3501 return; 3502 } 3503 var $activeList = void 0; 3504 if ($listItem.hasClass(classes.firstLevelListItem)) { 3505 $activeList = $listItem.parent().next(); 3506 } else { 3507 $activeList = $listItem.parents("." + classes.listWrapper).eq(-2); 3508 } 3509 if (!$activeList.length) { 3510 delete this.$activeList; 3511 return; 3512 } 3513 this.$activeList = $activeList; 3514 this.$activeList.stop().slideDown(); 3515 }, 3516 deactivateActiveItem: function deactivateActiveItem($activeToBe) { 3517 if (!this.$activeItem || this.$activeItem.is($activeToBe)) { 3518 return; 3519 } 3520 var _getSettings = this.getSettings(), 3521 classes = _getSettings.classes; 3522 this.$activeItem.removeClass(classes.activeItem); 3523 if (this.$activeList && (!$activeToBe || !this.$activeList[0].contains($activeToBe[0]))) { 3524 this.$activeList.slideUp(); 3525 } 3526 }, 3527 followAnchor: function followAnchor($element, index) { 3528 var $self = this; 3529 var anchorSelector = $element[0].hash; 3530 var $anchor = void 0; 3531 try { 3532 // `decodeURIComponent` for UTF8 characters in the hash. 3533 $anchor = jQuery(decodeURIComponent(anchorSelector)); 3534 } catch (e) { 3535 return; 3536 } 3537 if (0 === index) { 3538 haObserveTarget($anchor[0], function (direction) { 3539 if ($self.itemClicked) { 3540 return; 3541 } 3542 if ("down" === direction) { 3543 $self.activateItem($element); 3544 } else { 3545 $self.deactivateActiveItem(); 3546 } 3547 }); 3548 } 3549 haObserveTarget($anchor[0], function (direction) { 3550 if ($self.itemClicked) { 3551 return; 3552 } 3553 if ("down" === direction) { 3554 $self.activateItem($self.$listItemTexts.eq(index + 1)); 3555 } else { 3556 $self.activateItem($element); 3557 } 3558 }); 3559 }, 3560 followAnchors: function followAnchors() { 3561 var $self = this; 3562 this.$listItemTexts.each(function (index, element) { 3563 return $self.followAnchor(jQuery(element), index); 3564 }); 3565 }, 3566 setOffset: function setOffset($listItem) { 3567 var $this = this; 3568 var settings = this.getSettings(); 3569 var list = this.$element.find("." + settings.classes.listItem); 3570 var offset = this.getCurrentDeviceSetting("scroll_offset"); 3571 list.each(function () { 3572 $('a', this).on('click', function (e) { 3573 e.preventDefault(); 3574 var hash = this.hash; 3575 $('html, body').animate({ 3576 scrollTop: $(hash).offset().top - parseInt(offset.size) 3577 }, 800); 3578 }); 3579 }); 3580 }, 3581 populateTOC: function populateTOC() { 3582 var $self = this; 3583 this.listItemPointer = 0; 3584 var elementSettings = this.getElementSettings(); 3585 if (elementSettings.custom_style == 'yes') { 3586 this.elements.$widgetContainer.html(this.createSideDot()); 3587 } else { 3588 if (elementSettings.hierarchical_view) { 3589 this.createNestedList(); 3590 } else { 3591 this.createFlatList(); 3592 } 3593 } 3594 this.$listItemTexts = this.$element.find(".ha-toc__list-item-text"); 3595 this.$listItemTexts.on("click", this.onListItemClick.bind(this)); 3596 if (!elementorFrontend.isEditMode()) { 3597 this.followAnchors(); 3598 } 3599 $(window).on('scroll', function () { 3600 if ("window_top" === elementSettings.scroll_to_top_option) { 3601 if ($(window).scrollTop() > 0) { 3602 $self.elements.$scrollTop.show(); 3603 } else { 3604 $self.elements.$scrollTop.hide(); 3605 } 3606 } else { 3607 var $id = $self.getID().parents('.elementor-element'); 3608 if ($id.offset().top >= $(window).scrollTop()) { 3609 $self.elements.$scrollTop.hide(); 3610 } else { 3611 $self.elements.$scrollTop.show(); 3612 } 3613 } 3614 }); 3615 }, 3616 createNestedList: function createNestedList() { 3617 var $self = this; 3618 this.headingsData.forEach(function (heading, index) { 3619 heading.level = 0; 3620 for (var i = index - 1; i >= 0; i--) { 3621 var currentOrderedItem = $self.headingsData[i]; 3622 if (currentOrderedItem.tag <= heading.tag) { 3623 heading.level = currentOrderedItem.level; 3624 if (currentOrderedItem.tag < heading.tag) {
3625 heading.level++; 3626 } 3627 break; 3628 } 3629 } 3630 }); 3631 this.elements.$tocBody.html(this.getNestedLevel(0)); 3632 }, 3633 createFlatList: function createFlatList() { 3634 this.elements.$tocBody.html(this.getNestedLevel()); 3635 }, 3636 createSideDot: function createSideDot(level) { 3637 var settings = this.getSettings(), 3638 elementSettings = this.getElementSettings(), 3639 icon = this.getElementSettings("icon"), 3640 htmlul = ''; 3641 if (elementSettings.custom_style == 'yes') { 3642 htmlul += "<div class=\"".concat(elementSettings.custom_style_list, "\">\n <div class=\"hm-toc \">\n <ul class=\"hm-toc-items\" style=\"list-style: none;\">\n <li>"); 3643 if (elementSettings.custom_style_list == 'hm-toc-slide-style') { 3644 htmlul += "<".concat(elementSettings.html_tag, " class=\"hm-toc-title\"><span>").concat(elementSettings.widget_title, "<span></").concat(elementSettings.html_tag, ">"); 3645 } else { 3646 htmlul += "<".concat(elementSettings.html_tag, " class=\"hm-toc-title\">").concat(elementSettings.widget_title, "</").concat(elementSettings.html_tag, ">"); 3647 } 3648 htmlul += "<".concat(settings.listWrapperTag, " class=\"hm-toc-items-inner\">"); 3649 for (var i = 0; i < this.headingsData.length; i++) { 3650 var list = ''; 3651 var currentItemDot = this.headingsData[i]; 3652 if (level > currentItemDot.level) { 3653 break; 3654 } 3655 var listItemTextClasses = settings.classes.listItemText; 3656 if (0 === currentItemDot.level) { 3657 // If the current list item is a top level item, give it the first level class 3658 listItemTextClasses += " " + settings.classes.firstLevelListItem; 3659 } 3660 if (level === currentItemDot.level) { 3661 list += "<li class=\"hm-toc-entry ".concat(settings.classes.listItem, "\">"); 3662 if ('bullets' === elementSettings.marker_view && icon && elementSettings.custom_style_list == 'hm-toc-slide-style') { 3663 list += "<i class=\"".concat(icon.value, "\"></i>"); 3664 } 3665 list += "<a href=\"#".concat(currentItemDot.anchorLink, "\" class=\"").concat(listItemTextClasses, "\"><span>").concat(currentItemDot.text, "</span></a>"); 3666 list += "</li>"; 3667 } 3668 htmlul += list; 3669 } 3670 htmlul += "</".concat(settings.listWrapperTag, ">"); 3671 htmlul += "</li>\n </ul>"; 3672 } 3673 return htmlul; 3674 }, 3675 getNestedLevel: function getNestedLevel(level) { 3676 var settings = this.getSettings(), 3677 elementSettings = this.getElementSettings(), 3678 icon = this.getElementSettings("icon"); 3679 var html = ''; 3680 3681 // Open new list/nested list 3682 html += "<" + settings.listWrapperTag + ' class="' + settings.classes.listWrapper + '">'; 3683 3684 // for each list item, build its markup. 3685 while (this.listItemPointer < this.headingsData.length) { 3686 var currentItem = this.headingsData[this.listItemPointer]; 3687 var listItemTextClasses = settings.classes.listItemText; 3688 if (0 === currentItem.level) { 3689 // If the current list item is a top level item, give it the first level class 3690 listItemTextClasses += " " + settings.classes.firstLevelListItem; 3691 } 3692 if (level > currentItem.level) { 3693 break; 3694 } 3695 if (level === currentItem.level) { 3696 html += '<li class="' + settings.classes.listItem + " " + "level-" + level + '">'; 3697 html += '<div class="' + settings.classes.listTextWrapper + '">'; 3698 var liContent = '<a href="#' + currentItem.anchorLink + '" class="' + listItemTextClasses + '">' + currentItem.text + "</a>"; 3699 3700 // If list type is bullets, add the bullet icon as an <i> tag 3701 if ("bullets" === elementSettings.marker_view && icon) { 3702 liContent = '<i class="' + icon.value + '"></i>' + liContent; 3703 } 3704 html += liContent; 3705 html += "</div>"; 3706 this.listItemPointer++; 3707 var nextItem = this.headingsData[this.listItemPointer]; 3708 if (nextItem && level < nextItem.level) { 3709 // If a new nested list has to be created under the current item, 3710 // this entire method is called recursively (outside the while loop, a list wrapper is created) 3711 html += this.getNestedLevel(nextItem.level); 3712 } 3713 html += "</li>"; 3714 } 3715 } 3716 html += "</" + settings.listWrapperTag + ">"; 3717 return html; 3718 }, 3719 handleNoHeadingsFound: function handleNoHeadingsFound() { 3720 var _messages = 'No headings were found on this page.'; 3721 if (elementorFrontend.isEditMode()) { 3722 return this.elements.$tocBody.html(_messages); 3723 } 3724 }, 3725 collapseOnInit: function collapseOnInit() { 3726 var $self = this; 3727 var minimizedOn = this.getElementSettings("minimized_on"), 3728 currentDeviceMode = elementorFrontend.getCurrentDeviceMode(); 3729 if ("" !== minimizedOn && "array" !== typeof minimizedOn) { 3730 minimizedOn = [minimizedOn]; 3731 } 3732 if (0 !== minimizedOn.length && "object" === _typeof(minimizedOn)) {
3733 minimizedOn.forEach(function (value) { 3734 if ("desktop" === value[0] && "desktop" == currentDeviceMode && $(window).width() < elementorFrontend.config.breakpoints.xxl || "tablet" === value[0] && "tablet" === currentDeviceMode && $(window).width() < elementorFrontend.config.breakpoints.lg || "mobile" === value[0] && "mobile" === currentDeviceMode && $(window).width() < elementorFrontend.config.breakpoints.md) { 3735 $self.collapseBox(); 3736 } 3737 }); 3738 } 3739 }, 3740 getHeadingAnchorLink: function getHeadingAnchorLink(index, classes) { 3741 var headingID = this.elements.$headings[index].id, 3742 wrapperID = this.elements.$headings[index].closest('.elementor-widget').id; 3743 var anchorLink = ''; 3744 if (headingID) { 3745 anchorLink = headingID; 3746 } else if (wrapperID) { 3747 // If the heading itself has an ID, we don't want to overwrite it 3748 anchorLink = wrapperID; 3749 } // If there is no existing ID, use the heading text to create a semantic ID 3750 3751 if (headingID || wrapperID) { 3752 jQuery(this.elements.$headings[index]).data('hasOwnID', true); 3753 } else { 3754 anchorLink = "".concat(classes.headingAnchor, "-").concat(index); 3755 } 3756 return anchorLink; 3757 }, 3758 setHeadingsData: function setHeadingsData() { 3759 var $this = this; 3760 this.headingsData = []; 3761 var classes = this.getSettings("classes"); 3762 3763 // Create an array for simplifying TOC list creation 3764 this.elements.$headings.each(function (index, element) { 3765 var anchorLink = $this.getHeadingAnchorLink(index, classes); 3766 $this.headingsData.push({ 3767 tag: +element.nodeName.slice(1), 3768 text: element.textContent, 3769 anchorLink: anchorLink 3770 }); 3771 }); 3772 }, 3773 run: function run() { 3774 var elementSettings = this.getElementSettings(); 3775 this.elements.$headings = this.getHeadings(); 3776 if (!this.elements.$headings.length) { 3777 return this.handleNoHeadingsFound(); 3778 } 3779 this.setHeadingsData(); 3780 if (!elementorFrontend.isEditMode()) { 3781 this.addAnchorsBeforeHeadings(); 3782 } 3783 this.populateTOC(); 3784 if (elementSettings.minimize_box) { 3785 this.collapseOnInit(); 3786 } 3787 if (elementSettings.sticky_toc_toggle) { 3788 this.handleStickyToc(); 3789 } 3790 if ("" !== elementSettings.scroll_offset.size) { 3791 this.setOffset(); 3792 } 3793 }, 3794 expandBox: function expandBox() { 3795 var boxHeight = this.getCurrentDeviceSetting("min_height"); 3796 this.$element.removeClass(this.getSettings("classes.collapsed")); 3797 this.elements.$tocBody.slideDown(); 3798 3799 // return container to the full height in case a min-height is defined by the user 3800 this.elements.$widgetContainer.css("min-height", boxHeight.size + boxHeight.unit); 3801 }, 3802 collapseBox: function collapseBox() { 3803 this.$element.addClass(this.getSettings("classes.collapsed")); 3804 this.elements.$tocBody.slideUp(); 3805 3806 // close container in case a min-height is defined by the user 3807 this.elements.$widgetContainer.css("min-height", "0px"); 3808 }, 3809 onInit: function onInit() { 3810 var $self = this; 3811 this.initElements(); 3812 this.bindEvents(); 3813 jQuery(document).ready(function () { 3814 $self.run(); 3815 }); 3816 }, 3817 onListItemClick: function onListItemClick(event) { 3818 var $self = this; 3819 this.itemClicked = true; 3820 setTimeout(function () { 3821 return $self.itemClicked = false; 3822 }, 2000); 3823 var $clickedItem = jQuery(event.target), 3824 $list = $clickedItem.parent().next(), 3825 collapseNestedList = this.getElementSettings("collapse_subitems"); 3826 if ("SPAN" == $clickedItem[0].tagName && 'yes' == this.getElementSettings("custom_style")) { 3827 $clickedItem = jQuery(event.currentTarget); 3828 } 3829 var listIsActive = void 0; 3830 if (collapseNestedList && $clickedItem.hasClass(this.getSettings("classes.firstLevelListItem"))) { 3831 if ($list.is(":visible")) { 3832 listIsActive = true; 3833 } 3834 } 3835 this.activateItem($clickedItem); 3836 if (collapseNestedList && listIsActive) { 3837 $list.slideUp(); 3838 } 3839 }, 3840 handleStickyToc: function handleStickyToc() { 3841 var elementSettings = this.getElementSettings(); 3842 var currentDeviceMode = elementorFrontend.getCurrentDeviceMode(); 3843 var $devices = elementSettings.sticky_toc_disable_on; 3844 var target = this.getID(); 3845 var type = elementSettings.sticky_toc_type; 3846 if ("in-place" === type) { 3847 var parentWidth = target.parent().parent().outerWidth(); 3848 target.css("width", parentWidth); 3849 } else if ("custom-position" === type) { 3850 var parentWidth = target.parent().parent().outerWidth(); 3851 target.css("width", parentWidth); 3852 } 3853 if (-1 == $.inArray(currentDeviceMode, $devices)) { 3854 target.removeClass('floating-toc'); 3855 $(window).off('scroll', this.stickyScroll); 3856 return; 3857 } 3858 $(window).on('scroll', $.proxy(this.stickyScroll, this)); 3859 }, 3860 stickyScroll: function stickyScroll() { 3861 var target = this.getID(); 3862 var elementSettings = this.getElementSettings(); 3863 var item = document.querySelector(".ha-table-of-contents"); 3864 var bound, tocHeight; 3865 bound = item.getBoundingClientRect(); 3866 tocHeight = target.outerHeight(); 3867 if (target.hasClass("floating-toc")) { 3868 target.parent().parent().css("height", tocHeight); 3869 } else { 3870 target.parent().parent().css("height", ''); 3871 } 3872 if (bound.y + bound.height / 2 < 0) { 3873 if (target.hasClass('floating-toc')) { 3874 return; 3875 } 3876 target.addClass("floating-toc"); 3877 } else { 3878 if (!target.hasClass('floating-toc')) { 3879 return; 3880 } 3881 target.removeClass("floating-toc"); 3882 } 3883 }, 3884 scrollToTop: function scrollToTop() { 3885 var $self = this; 3886 var scrollTo = this.getElementSettings("scroll_to_top_option"); 3887 if ("window_top" === scrollTo) { 3888 $("html, body").animate({ 3889 scrollTop: 0 3890 }, 250); 3891 } else { 3892 var $id = this.getID().parents('.ha-table-of-contents'); 3893 $("html, body").animate({ 3894 scrollTop: $($id).offset().top - 60 3895 }, 1000); 3896 } 3897 }, 3898 getID: function getID() { 3899 return $("#ha-toc-" + this.$element[0].attributes["data-id"].nodeValue); 3900 } 3901 }); 3902 elementorFrontend.hooks.addAction("frontend/element_ready/ha-table-of-contents.default", function ($scope) { 3903 elementorFrontend.elementsHandler.addHandler(HaTOC, { 3904 $element: $scope 3905 }); 3906 }); 3907 3908 //creativeSlider 3909 var HaCreativeSlider = function HaCreativeSlider($scope) { 3910 var $rcContainer = $scope.find('.ha-creative-slider-container'); 3911 if ($rcContainer) { 3912 // var $haCsWidth = window.innerWidth; 3913 var $haCsWidth = $(window).width(); 3914 var $haCsNextSelector = parseInt($haCsWidth) <= 767 ? $rcContainer.find('.ha_cs_mobile_next') : $rcContainer.find('.ha_cc_next_wrapper'); 3915 var $haCsPrevSelector = parseInt($haCsWidth) <= 767 ? $rcContainer.find('.ha_cs_mobile_prev') : $rcContainer.find('.ha_cc_prev_wrapper'); 3916 var csTextItemDelay = parseInt($haCsWidth) <= 767 ? 40 : 30; 3917 var csImageItemDelay = 40; 3918 var csPrevItemsOwl = $rcContainer.find('.ha_cc_prev_items'); 3919 var csTextItemsOwl = $rcContainer.find('.ha_cc_text_items'); 3920 var csImageItemsOwl = $rcContainer.find('.ha_cc_inner_image_items'); 3921 var csNextItemsOwl = $rcContainer.find('.ha_cc_next_items'); 3922 var csPrevNavOptions = { 3923 loop: true, 3924 dots: false, 3925 nav: false, 3926 items: 1, 3927 autoplay: false, 3928 smartSpeed: 500, 3929 touchDrag: false, 3930 mouseDrag: false, 3931 rewind: true, 3932 startPosition: -1 3933 }; 3934 var csNextNavOptions = { 3935 loop: true, 3936 dots: false, 3937 nav: false, 3938 items: 1, 3939 autoplay: false, 3940 smartSpeed: 500, 3941 touchDrag: false, 3942 mouseDrag: false, 3943 rewind: true, 3944 startPosition: 1 3945 }; 3946 var csGeneralOptions = { 3947 loop: true, 3948 dots: false, 3949 nav: false, 3950 items: 1, 3951 autoplay: false, 3952 smartSpeed: 1000, 3953 touchDrag: false, 3954 mouseDrag: false, 3955 singleItem: true, 3956 animateOut: 'fadeOutRight', 3957 animateIn: 'fadeInLeft', 3958 rewind: true 3959 }; 3960 } 3961 csPrevItemsOwl.owlCarousel(csPrevNavOptions); 3962 csNextItemsOwl.owlCarousel(csNextNavOptions); 3963 csTextItemsOwl.owlCarousel(csGeneralOptions); 3964 csImageItemsOwl.owlCarousel(csGeneralOptions); 3965 window.parent.addEventListener('message', function (e) { 3966 if ('ha_cs_reinit' == e.data) { 3967 csTextItemsOwl.owlCarousel('refresh'); 3968 csImageItemsOwl.owlCarousel('refresh'); 3969 } 3970 }); 3971 $($haCsPrevSelector).click(function (e) { 3972 e.preventDefault(); 3973 csPrevItemsOwl.trigger('prev.owl.carousel'); 3974 csNextItemsOwl.trigger('prev.owl.carousel'); 3975 setTimeout(function () { 3976 csTextItemsOwl.trigger('prev.owl.carousel'); 3977 }, csTextItemDelay); 3978 setTimeout(function () { 3979 csImageItemsOwl.trigger('prev.owl.carousel'); 3980 }, csTextItemDelay + csImageItemDelay); 3981 }); 3982 $($haCsNextSelector).click(function (e) { 3983 e.preventDefault(); 3984 csPrevItemsOwl.trigger('next.owl.carousel'); 3985 csNextItemsOwl.trigger('next.owl.carousel'); 3986 setTimeout(function () { 3987 csTextItemsOwl.trigger('next.owl.carousel'); 3988 }, csTextItemDelay); 3989 setTimeout(function () { 3990 csImageItemsOwl.trigger('next.owl.carousel'); 3991 }, csTextItemDelay + csImageItemDelay); 3992 }); 3993 }; 3994 elementorFrontend.hooks.addAction('frontend/element_ready/ha-creative-slider.default', HaCreativeSlider); 3995 3996 //Advanced Comparison Table 3997 var AdvancedComparisonTable = function AdvancedComparisonTable($scope) { 3998 var nav = $scope.find('ul.ha-adct-table-responsive-nav'); 3999 var rows = $scope.find(".ha-adct-row, .ha-adct-child-row"); 4000 var collapse = $scope.find(".ha-adct-collapse-icon-wrap"); 4001 4002 // console.log(rows); 4003 4004 var pos = 2; 4005 nav.on("click", "li", function () { 4006 var pos = $(this).index() + 2; 4007 // console.log( pos ); 4008 4009 rows.find(".ha-adct-column:not(:eq(0))").hide(); 4010 $scope.find(".ha-adct-column:nth-child(" + pos + ")").css("display", "flex"); 4011 nav.find("li").removeClass("active"); 4012 $(this).addClass("active"); 4013 }); 4014 collapse.on("click", function () { 4015 var row_wrap = $(this).closest('.ha-adct-row-wrap'); 4016 // console.log( row_wrap ); 4017 $(this).toggleClass('open'); 4018 row_wrap.find('.ha-adct-child-row-wrap').slideToggle("slow"); 4019 // row_wrap.find('.ha-adct-child-row-wrap .ha-adct-column').slideToggle("slow"); 4020 // $('.ha-adct-heading').slideToggle("slow"); 4021 }); 4022 4023 // Initialize the media query 4024 //var mediaQuery = window.matchMedia("(min-width: 767px)"); 4025 // console.log(mediaQuery); 4026 var mode = $('body').attr('data-elementor-device-mode'); 4027 var w_width = $(window).outerWidth(true); 4028 function hideAndShowColumn(mode) { 4029 if ('tablet' == mode || 'mobile_extra' == mode || 'mobile' == mode) { 4030 rows.find(".ha-adct-column:not(:eq(0))").hide(); 4031 $scope.find(".ha-adct-column:nth-child(" + pos + ")").css("display", "flex"); 4032 } else { 4033 rows.find(".ha-adct-column").removeAttr("style"); 4034 } 4035 } 4036 ; 4037 hideAndShowColumn(mode); 4038 $(window).on('resize', function (e) { 4039 var mode = $('body').attr('data-elementor-device-mode'); 4040 var w_resize_width = $(window).outerWidth(true); 4041 if (w_width != w_resize_width) { 4042 w_width = w_resize_width; 4043 hideAndShowColumn(mode); 4044 } 4045 }); 4046 }; 4047 elementorFrontend.hooks.addAction('frontend/element_ready/ha-advanced-comparison-table.default', AdvancedComparisonTable); 4048 4049 //Title Tips 4050 var TitleTips = function TitleTips($scope) { 4051 var element = $scope.find('.ha-flip-box-inner'); 4052 var items = $scope.find('.ha-title-tips-hover li > a'); 4053 var rect = $scope.find('.ha-title-tips-hover')[0].getBoundingClientRect(); 4054 if ($scope.find('.ha-title-tips-hover').hasClass('swap')) { 4055 var wrapper = $scope.find('.ha-title-tips-hover'); 4056 var anchor_item = $scope.find('.ha-title-tips-hover-item.have-image'); 4057 var figure = $scope.find('figure'); 4058 var Work = { 4059 _register: { 4060 hover: { 4061 active: !1, 4062 currentX: 0, 4063 currentY: 0, 4064 targetX: 0, 4065 targetY: 0 4066 } 4067 }, 4068 _init: function _init() { 4069 this._base(), this._events(); 4070 }, 4071 _base: function _base() { 4072 figure.find('img').each(function () { 4073 var item = $(this); 4074 // console.log( item.height() ); 4075 item.attr("height_ratio", item.height()); 4076 }); 4077 requestAnimationFrame(function () { 4078 Work._interaction.hover.move_image(); 4079 }); 4080 }, 4081 _events: function _events() { 4082 anchor_item.on("mouseenter", "a", function () { 4083 Work._interaction.hover.image($(this)); 4084 }); 4085 anchor_item.on("mouseleave", "a", function () { 4086 Work._interaction.hover.leave(); 4087 }); 4088 anchor_item.on("mousemove", "a", function (e) { 4089 Work._interaction.hover.move(e); 4090 }); 4091 }, 4092 _functions: { 4093 round: function round(e, t) { 4094 var t = void 0 === t ? 100 : Math.pow(10, t); 4095 return Math.round(e * t) / t; 4096 } 4097 }, 4098 _interaction: { 4099 hover: { 4100 image: function image(e) { 4101 e.parents("li").addClass("active").removeClass("not-selected").siblings().removeClass("active").addClass("not-selected"); 4102 if (!Work._register.hover.visible && (Work._register.hover.currentX || Work._register.hover.currentY)) { 4103 Work._register.hover.visible = !0; 4104 figure.addClass("visible"); 4105 } 4106 4107 // $img = $('#work-hover img[project="' + e.attr("href") + '"]');
4108 var $img = figure.find('img[data-filter-id="' + e.attr("data-filter-id") + '"]'); 4109 $img.addClass("active").siblings(".active").removeClass("active").addClass("was-active"); 4110 // console.log($img); 4111 // console.log($img.height()); 4112 // figure.get()[0].style.setProperty("--height_ratio", ( Math.floor(Math.random() * (500 - 150 + 1) ) + 150 ) + 'px' ); 4113 4114 // figure.get()[0].style.setProperty("--height_ratio", ( $img.height() ) + 'px' ); 4115 figure.get()[0].style.setProperty("--height_ratio", $img.attr("height_ratio") + 'px'); 4116 // .style.setProperty("--height_ratio", $img.attr("height_ratio")), 4117 4118 clearTimeout(figure.prop("leave")); 4119 clearTimeout(figure.prop("animate")); 4120 figure.addClass("animate").prop("animate", setTimeout(function () { 4121 figure.removeClass("animate").find("img.was-active").removeClass("was-active"); 4122 }, 400)); 4123 }, 4124 leave: function leave() { 4125 anchor_item.removeClass("active not-selected"); 4126 clearTimeout(figure.prop("leave")); 4127 clearTimeout(figure.prop("active")); 4128 figure.prop("leave", setTimeout(function () { 4129 // Work._register.hover.visible = !1; 4130 Work._register.hover.visible = false; 4131 figure.removeClass("visible"); 4132 }, 1)); 4133 figure.prop("active", setTimeout(function () { 4134 Work._register.hover.active = !1; 4135 }, 2e3)); 4136 }, 4137 move: function move(e) { 4138 var currentReact = e.currentTarget.getBoundingClientRect(); 4139 var currentWrapperReact = wrapper.get()[0].getBoundingClientRect(); 4140 var targetMiddle = currentReact.top + currentReact.height / 2; 4141 Work._register.hover.active || (Work._register.hover.active = !0, requestAnimationFrame(function () { 4142 Work._interaction.hover.move_image(); 4143 }), clearTimeout(figure.prop("active")), figure.prop("active", setTimeout(function () { 4144 Work._register.hover.active = !1; 4145 }, 2e3))); 4146 // var react = $("#work-projects").get()[0].getBoundingClientRect(); 4147 var s = 0; 4148 var targetItem = anchor_item.find('a').offset().left - 40; 4149 if ($scope.hasClass('ha_title_tips_img_pos--left')) { 4150 // Work._register.hover.targetX = currentReact.left - figure.width(); // for left side 4151 Work._register.hover.targetX = -(figure.width() + 10); // for left side 4152 } else { 4153 Work._register.hover.targetX = currentReact.width + 10; // for right side 4154 } 4155 // Work._register.hover.targetY = targetMiddle; 4156 Work._register.hover.targetY = e.pageY - (currentWrapperReact.top + window.scrollY); 4157 if (!Work._register.hover.visible && (Work._register.hover.currentX || Work._register.hover.currentY)) { 4158 Work._register.hover.visible = true; 4159 figure.addClass("visible"); 4160 } 4161 }, 4162 move_image: function move_image() { 4163 if (figure.length) { 4164 Work._register.hover.currentX += (Work._register.hover.targetX - Work._register.hover.currentX) * 0.09; 4165 Work._register.hover.currentY += (Work._register.hover.targetY - Work._register.hover.currentY) * 0.09; 4166 figure.get()[0].style.transform = " translate3d(\n\t\t\t\t\t\t\t\t\t\t".concat(Work._functions.round(Work._register.hover.currentX), "px,\n\t\t\t\t\t\t\t\t\t\t").concat(Work._functions.round(Work._register.hover.currentY), "px, 0px\n\t\t\t\t\t\t\t\t\t)"); 4167 if (Work._register.hover.active) { 4168 requestAnimationFrame(function () { 4169 Work._interaction.hover.move_image(); 4170 }); 4171 } 4172 } 4173 } 4174 } 4175 } 4176 }; 4177 Work._init(); 4178 } 4179 }; 4180 elementorFrontend.hooks.addAction('frontend/element_ready/ha-title-tips.default', TitleTips); 4181 4182 // Loop Tab 4183 var LoopTabBase = elementorModules.frontend.handlers.Base.extend({ 4184 onInit: function onInit() { 4185 var _this2 = this; 4186 elementorModules.frontend.handlers.Base.prototype.onInit.apply(this, arguments); 4187 this.wrapper = this.$element.find('.ha-loop-tab-wrapper'); 4188 this._pillAnim = null; 4189 this._animating = false;
4190 this._uid = 'ha_loop_tab_' + this.getUniqueHandlerID(); 4191 this._initialized = false; // guard: has run() completed at least once? 4192 this._wasVisible = false; 4193 this._observer = null; 4194 this._self = this; 4195 this.run(); 4196 // Only tab-handler changes should re-run (not accordion â handled by observer) 4197 $(document).on('ha_TabHandlerBase_changed.' + this._uid, function () { 4198 setTimeout(function () { 4199 _this2._initialized = false; 4200 if (_this2.$element.hasClass('ha-loop-tab-loaded')) { 4201 return; 4202 } 4203 _this2.run(); 4204 }, 200); 4205 }); 4206 this._startVisibilityObserver(); 4207 }, 4208 getUniqueHandlerID: function getUniqueHandlerID() { 4209 return 'ha_loop_tab_' + this.$element.data('id') + '_' + Math.random().toString(36).substr(2, 9); 4210 }, 4211 onDestroy: function onDestroy() { 4212 $(document).off('.' + this._uid); 4213 if (this._resizeHandler) { 4214 window.removeEventListener('resize', this._resizeHandler); 4215 this._resizeHandler = null; 4216 } 4217 if (this._pillAnim) { 4218 this._pillAnim.cancel(); 4219 this._pillAnim = null; 4220 } 4221 if (this._observer) { 4222 this._observer.disconnect(); 4223 this._observer = null; 4224 } 4225 }, 4226 onElementChange: debounce(function (changedProp) { 4227 var $keys = ['tab_action', 'tab_transition_delay', 'tab_nav_item_width', 'tab_nav_item_height', 'tab_nav_item_border_radius', 'tab_nav_item_stroke_width']; 4228 if ($keys.indexOf(changedProp) !== -1) { 4229 this._initialized = false; // allow re-run on settings change 4230 this.run(); 4231 } 4232 }, 300), 4233 _startVisibilityObserver: function _startVisibilityObserver() { 4234 var _this3 = this; 4235 if (this._observer) { 4236 this._observer.disconnect(); 4237 } 4238 var el = this.$element[0]; 4239 var isVisible = function isVisible() { 4240 return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length); 4241 }; 4242 this._wasVisible = isVisible(); 4243 this._observer = new MutationObserver(function () { 4244 var nowVisible = isVisible(); 4245 if (nowVisible && !_this3._wasVisible) { 4246 _this3._wasVisible = true; 4247 _this3._initialized = false; // widget just appeared, allow fresh run 4248 if (_this3._pillAnim) { 4249 _this3._pillAnim.cancel(); 4250 _this3._pillAnim = null; 4251 _this3._animating = false; 4252 } 4253 setTimeout(function () { 4254 _this3.run(); 4255 }, 100); 4256 } else if (!nowVisible) { 4257 _this3._wasVisible = false; 4258 } 4259 }); 4260 var ancestor = el.parentElement; 4261 while (ancestor && ancestor !== document.body) { 4262 this._observer.observe(ancestor, { 4263 attributes: true, 4264 attributeFilter: ['class', 'style', 'hidden'] 4265 }); 4266 ancestor = ancestor.parentElement; 4267 } 4268 }, 4269 getReadySettings: function getReadySettings() { 4270 var settings = {}; 4271 var tab_action = this.getElementSettings('tab_action'); 4272 if (tab_action) settings.tab_action = tab_action; 4273 var tab_transition_delay = this.getElementSettings('tab_transition_delay'); 4274 if (tab_transition_delay) settings.tab_transition_delay = tab_transition_delay; 4275 var item_width = elementorFrontend.getCurrentDeviceMode() === 'mobile' ? this.getElementSettings('tab_nav_item_width_mobile') : this.getElementSettings('tab_nav_item_width'); 4276 if (item_width) settings.item_width = item_width['size']; 4277 var item_height = this.getElementSettings('tab_nav_item_height'); 4278 if (item_height) settings.item_height = item_height['size']; 4279 var stroke_ry = elementorFrontend.getCurrentDeviceMode() === 'mobile' ? this.getElementSettings('tab_nav_item_border_radius_mobile') : this.getElementSettings('tab_nav_item_border_radius'); 4280 if (stroke_ry) settings.stroke_ry = stroke_ry['size']; 4281 var stroke_width = this.getElementSettings('tab_nav_item_stroke_width'); 4282 if (stroke_width) settings.stroke_width = stroke_width['size']; 4283 return $.extend({}
4283, this.getSettings(), settings); 4284 }, 4285 run: function run() { 4286 var _this4 = this; 4287 if (this.$element.hasClass('ha-loop-tab-loaded') && this._initialized) { 4288 console.log('Loop Tab already initialized, skipping run.'); 4289 return; 4290 } 4291 this._initialized = true; 4292 this.$element.addClass('ha-loop-tab-loaded'); 4293 console.log('run.'); 4294 if (this._pillAnim) { 4295 this._pillAnim.cancel(); 4296 this._pillAnim = null; 4297 } 4298 this._animating = false; 4299 if (this._resizeHandler) { 4300 window.removeEventListener('resize', this._resizeHandler); 4301 this._resizeHandler = null; 4302 } 4303 this.wrapper.find('.tab-border').each(function () { 4304 this.style.visibility = 'hidden'; 4305 this.style.strokeDasharray = ''; 4306 this.style.strokeDashoffset = ''; 4307 }); 4308 var settings = this.getReadySettings(); 4309 var currentIndex = 0; 4310 var isHovered = false; 4311 var nextIndex = 1; 4312 var animationInProgress = false; 4313 var pillBorderAnim = undefined; 4314 var hoverMode = settings.tab_action === 'on_hover'; 4315 var $wrapper = this.wrapper; 4316 var tabs = $wrapper.find('.ha-loop-tab-nav-item'); 4317 var contents = $wrapper.find('.ha-loop-tab_content'); 4318 var animationTime = settings.tab_transition_delay || 8000; 4319 var itemWidth = settings.item_width || 280; 4320 var itemHeight = settings.item_height && settings.item_height >= 45 ? settings.item_height : settings.item_height ? 45 : 65; 4321 var maxRY = parseFloat(itemHeight / 2); 4322 var strokeRY = settings.stroke_ry >= maxRY ? maxRY : settings.stroke_ry; 4323 var strokeWidth = settings.stroke_width || 2; 4324 var parentElement = this.$element.closest('.e-parent'); 4325 var syncAnimRefs = function syncAnimRefs(anim, inProgress) { 4326 pillBorderAnim = anim; 4327 animationInProgress = inProgress; 4328 _this4._pillAnim = anim; 4329 _this4._animating = inProgress; 4330 }; 4331 4332 // ------------------------------------------------------------------ 4333 // Background containers â scoped, deduplicated 4334 // ------------------------------------------------------------------ 4335 if (parentElement.length > 0) { 4336 parentElement.css({ 4337 position: 'relative', 4338 overflow: 'inherit' 4339 }); 4340 parentElement.find('.ha-loop-tab-bgcontainer').remove(); 4341 tabs.each(function (idx, tab) { 4342 var bgColor = $(tab).attr('container-bgcolors'); 4343 var parsedColor = ''; 4344 try { 4345 parsedColor = JSON.parse(bgColor); 4346 } catch (e) {} 4347 parentElement.append("<div class=\"ha-loop-tab-bgcontainer ha-loop-tab-bgcontainer-".concat(idx, "\" style=\"background:").concat(parsedColor, ";\"></div>")); 4348 }); 4349 parentElement.find('.ha-loop-tab-bgcontainer-0').addClass('ha-loop-tab-active-bg'); 4350 } 4351 var handleSweepTouchEvents = function handleSweepTouchEvents() { 4352 var startX = 0; 4353 var currentX = 0; 4354 var isSwiping = false; 4355 var contentsWrapper = $wrapper.find('.ha-loop-tab-contents')[0]; 4356 if (contentsWrapper) { 4357 contentsWrapper.addEventListener('touchstart', function (e) { 4358 if (!e.touches || e.touches.length !== 1) return; 4359 startX = e.touches[0].clientX; 4360 currentX = startX; 4361 isSwiping = true; 4362 }, { 4363 passive: true 4364 }); 4365 contentsWrapper.addEventListener('touchmove', function (e) { 4366 if (!isSwiping) return; 4367 currentX = e.touches[0].clientX; 4368 }, { 4369 passive: true 4370 }); 4371 contentsWrapper.addEventListener('touchend', function () { 4372 if (!isSwiping) return; 4373 isSwiping = false; 4374 var deltaX = startX - currentX; 4375 var threshold = 60; 4376 if (deltaX > threshold) { 4377 $(tabs[(currentIndex + 1) % tabs.length]).trigger('click'); 4378 } 4379 if (deltaX < -threshold) { 4380 $(tabs[(currentIndex - 1 + tabs.length) % tabs.length]).trigger('click'); 4381 } 4382 }); 4383 } 4384 }; 4385 this._resizeHandler = function () { 4386 hoverMode = window.innerWidth <= 767 ? false : settings.tab_action === 'on_hover'; 4387 }; 4388 window.addEventListener('resize', this._resizeHandler); 4389 if (window.innerWidth <= 767) { 4390 hoverMode = false;
4391 handleSweepTouchEvents(); 4392 } else { 4393 hoverMode = settings.tab_action === 'on_hover'; 4394 } 4395 var handleAnimationEnd = function handleAnimationEnd(targetIndex) { 4396 return function () { 4397 if (!animationInProgress) return; 4398 syncAnimRefs(null, false); 4399 var previousTab = $(tabs[currentIndex]); 4400 var prevBorder = previousTab.find('.tab-border')[0]; 4401 if (prevBorder) { 4402 previousTab.find('.tab-border').css({ 4403 visibility: 'hidden', 4404 strokeDashoffset: prevBorder.getTotalLength ? prevBorder.getTotalLength() : 0 4405 }); 4406 } 4407 activateTab(targetIndex); 4408 $(tabs[targetIndex]).find('.tab-border').css({ 4409 visibility: 'hidden' 4410 }); 4411 smoothScrollTabs(tabs[targetIndex]); 4412 parentElement.find('.ha-loop-tab-bgcontainer').removeClass('ha-loop-tab-active-bg'); 4413 parentElement.find(".ha-loop-tab-bgcontainer-".concat(targetIndex)).addClass('ha-loop-tab-active-bg'); 4414 requestAnimationFrame(function () { 4415 startSvgAnimation((targetIndex + 1) % tabs.length); 4416 }); 4417 }; 4418 }; 4419 var startSvgAnimation = function startSvgAnimation(index) { 4420 var _svgElement$viewBox; 4421 if (hoverMode || animationInProgress) return; 4422 tabs.removeClass('filling'); 4423 var $nextTab = $(tabs[index]); 4424 var svgElement = $nextTab.find('.tab-svg')[0]; 4425 if (!svgElement) return; 4426 if (window.innerWidth <= 767) { 4427 svgElement.setAttribute('width', itemWidth); 4428 svgElement.setAttribute('height', 55); 4429 svgElement.setAttribute('viewBox', "0 0 ".concat(itemWidth, " 55")); 4430 svgElement.style.width = itemWidth + 'px'; 4431 svgElement.style.height = 55 + 'px'; 4432 } else { 4433 svgElement.setAttribute('width', itemWidth); 4434 svgElement.setAttribute('height', itemHeight + 2); 4435 svgElement.setAttribute('viewBox', "0 0 ".concat(itemWidth, " ").concat(itemHeight)); 4436 svgElement.style.height = itemHeight + 2 + 'px'; 4437 } 4438 var borderElement = $nextTab.find('.tab-border')[0]; 4439 if (!borderElement) return; 4440 $nextTab.find('.tab-border').css('visibility', 'visible'); 4441 var bboxWidth = borderElement.getBBox().width || ((_svgElement$viewBox = svgElement.viewBox) === null || _svgElement$viewBox === void 0 || (_svgElement$viewBox = _svgElement$viewBox.baseVal) === null || _svgElement$viewBox === void 0 ? void 0 : _svgElement$viewBox.width) || itemWidth; 4442 if (bboxWidth !== 0) { 4443 if (window.innerWidth <= 767) { 4444 strokeWidth = 2; 4445 borderElement.style.width = itemWidth - 3 + 'px'; 4446 borderElement.style.height = 52 + 'px'; 4447 borderElement.style.x = 1; 4448 borderElement.style.y = 1; 4449 borderElement.setAttribute('x', 1); 4450 borderElement.setAttribute('y', 1); 4451 borderElement.setAttribute('rx', strokeRY); 4452 borderElement.setAttribute('ry', strokeRY); 4453 borderElement.style.rx = strokeRY; 4454 borderElement.style.ry = strokeRY; 4455 } else { 4456 if (strokeWidth > 4) { 4457 borderElement.setAttribute('x', 3); 4458 borderElement.setAttribute('y', 3); 4459 } else if (strokeWidth > 2) { 4460 borderElement.setAttribute('x', 2); 4461 borderElement.setAttribute('y', 2); 4462 } else { 4463 borderElement.setAttribute('x', 1); 4464 borderElement.setAttribute('y', 1); 4465 } 4466 borderElement.setAttribute('rx', strokeRY); 4467 borderElement.setAttribute('ry', strokeRY); 4468 borderElement.style.rx = strokeRY; 4469 borderElement.style.ry = strokeRY; 4470 if (strokeWidth > 4) { 4471 borderElement.style.width = itemWidth - strokeWidth + 'px'; 4472 borderElement.style.height = itemHeight - strokeWidth + 'px'; 4473 borderElement.style.x = 3; 4474 borderElement.style.y = 3; 4475 } else if (strokeWidth > 2) { 4476 borderElement.style.width = itemWidth - 1 - strokeWidth + 'px'; 4477 borderElement.style.height = itemHeight - 2 + 'px'; 4478 borderElement.style.x = 2; 4479 } else { 4480 borderElement.style.width = itemWidth - 2 + 'px'; 4481 borderElement.style.height = itemHeight - 2 + 'px'; 4482 borderElement.style.x = 1; 4483 borderElement.style.y = 1; 4484 } 4485 } 4486 var length; 4487 try { 4488 length = borderElement.getTotalLength() + 5; 4489 if (length <= 5) { 4490 var _w = parseFloat(borderElement.style.width) || itemWidth - 2; 4491 var h = parseFloat(borderElement.style.height) || itemHeight - 2; 4492 length = 2 * (_w + h) + 5; 4493 } 4494 } catch (e) { 4495 var _w2 = parseFloat(borderElement.style.width) || itemWidth - 2; 4496 var _h = parseFloat(borderElement.style.height) || itemHeight - 2; 4497 length = 2 * (_w2 + _h) + 5; 4498 } 4499 borderElement.style.strokeDasharray = length.toString(); 4500 borderElement.style.strokeDashoffset = length.toString(); 4501 var anim = borderElement.animate([{ 4502 strokeDashoffset: length, 4503 strokeWidth: strokeWidth 4504 }, { 4505 strokeDashoffset: 0, 4506 strokeWidth: strokeWidth, 4507 offset: 0.98, 4508 easing: 'cubic-bezier(0.11, 0, 0.5, 0)' 4509 }, { 4510 strokeDashoffset: 0, 4511 strokeWidth: strokeWidth, 4512 easing: 'ease-out' 4513 }], { 4514 duration: animationTime, 4515 delay: 0, 4516 fill: 'forwards' 4517 }); 4518 syncAnimRefs(anim, true); 4519 } 4520 if (!pillBorderAnim) return; 4521 pillBorderAnim.onfinish = handleAnimationEnd(index); 4522 $nextTab.addClass('filling'); 4523 nextIndex = index; 4524 }; 4525 var activateTab = function activateTab(index) { 4526 currentIndex = index; 4527 tabs.removeClass('active'); 4528 contents.removeClass('active'); 4529 $(tabs[index]).addClass('active'); 4530 $(contents[index]).addClass('active'); 4531 }; 4532 tabs.off('mouseenter mouseleave').hover(function () { 4533 if (window.innerWidth <= 767) return; 4534 if (hoverMode) { 4535 var index = $(this).index(); 4536 activateTab(index); 4537 parentElement.find('.ha-loop-tab-bgcontainer').removeClass('ha-loop-tab-active-bg'); 4538 parentElement.find(".ha-loop-tab-bgcontainer-".concat(index)).addClass('ha-loop-tab-active-bg'); 4539 return; 4540 } 4541 isHovered = true; 4542 var $thisTab = $(this); 4543 if ($thisTab.hasClass('filling') && animationInProgress && pillBorderAnim) { 4544 pillBorderAnim.pause(); 4545 } 4546 }, function () { 4547 if (window.innerWidth <= 767) return; 4548 if (hoverMode) return; 4549 isHovered = false;
4550 var $thisTab = $(this); 4551 if ($thisTab.hasClass('filling') && animationInProgress && pillBorderAnim) { 4552 pillBorderAnim.play(); 4553 } 4554 }); 4555 tabs.off('click').on('click', function (e) { 4556 var clickedTab = $(e.currentTarget); 4557 var clickedIndex = clickedTab.index(); 4558 if (clickedIndex === currentIndex) return; 4559 if (animationInProgress && pillBorderAnim) { 4560 pillBorderAnim.cancel(); 4561 syncAnimRefs(null, false); 4562 } 4563 tabs.find('.tab-border').css({ 4564 visibility: 'hidden', 4565 strokeDashoffset: function strokeDashoffset() { 4566 try { 4567 return this.getTotalLength(); 4568 } catch (e) { 4569 return 0; 4570 } 4571 } 4572 }); 4573 activateTab(clickedIndex); 4574 parentElement.find('.ha-loop-tab-bgcontainer').removeClass('ha-loop-tab-active-bg'); 4575 parentElement.find(".ha-loop-tab-bgcontainer-".concat(clickedIndex)).addClass('ha-loop-tab-active-bg'); 4576 setTimeout(function () { 4577 startSvgAnimation((clickedIndex + 1) % tabs.length); 4578 }, 200); 4579 smoothScrollTabs(e.currentTarget); 4580 }); 4581 4582 // ------------------------------------------------------------------ 4583 // Double-click (mobile stop) 4584 // ------------------------------------------------------------------ 4585 tabs.dblclick(function () { 4586 if (window.innerWidth > 767) return; 4587 if (animationInProgress && pillBorderAnim) { 4588 pillBorderAnim.cancel(); 4589 syncAnimRefs(null, false); 4590 } 4591 }); 4592 var smoothScrollTabs = function smoothScrollTabs(clickedTab) { 4593 if (window.innerWidth > 767) return; 4594 var container = $wrapper.find('.ha-loop-tab-nav')[0]; 4595 if (!container) return; 4596 var containerRect = container.getBoundingClientRect(); 4597 var itemRect = clickedTab.getBoundingClientRect(); 4598 var scrollPosition = container.scrollLeft + (itemRect.left - containerRect.left) - containerRect.width / 3 + itemRect.width / 3; 4599 container.scrollTo({ 4600 left: scrollPosition, 4601 behavior: 'smooth' 4602 }); 4603 }; 4604 activateTab(0); 4605 startSvgAnimation(1); 4606 // window.addEventListener("resize", () => { 4607 // $(".ha-loop-tab-loaded").removeClass('ha-loop-tab-loaded'); 4608 4609 // this._self.reset?.(); // optional safe reset 4610 // this._self.run(); 4611 // }); 4612 } 4613 }); 4614 4615 // Loop Tab 4616 elementorFrontend.hooks.addAction("frontend/element_ready/ha-loop-tab.default", function ($scope) { 4617 elementorFrontend.elementsHandler.addHandler(LoopTabBase, { 4618 $element: $scope 4619 }); 4620 }); 4621 var MultiScroll = function MultiScroll($scope) { 4622 var wrap = $scope.find(".ha-multi-scroll-wrap"); 4623 var wrap_inner = $scope.find(".ha-multi-scroll-inner"); 4624 var multi_id = $scope.data("id"); 4625 var multiscroll = $scope.find(".ha-multi-scroll-inner-" + multi_id); 4626 var is_editor = $scope.hasClass("elementor-element-edit-mode"); 4627 var options = wrap.data("settings"); 4628 var device_mode = $("body").attr("data-elementor-device-mode"); 4629 var $left_sections = $scope.find('.ms-left .ms-section'); 4630 var $right_sections = $scope.find('.ms-right .ms-section'); 4631 if (is_editor) { 4632 $(document).find('#multiscroll-nav').remove(); 4633 try { 4634 $.fn.multiscroll.destroy(); 4635 } catch (err) { 4636 console.log(err); 4637 } 4638 } 4639 var $settings = { 4640 loopBottom: options.loopBottom, 4641 loopTop: options.loopTop, 4642 anchors: options.anchors, 4643 navigation: options.dots, 4644 //Dot enable 4645 navigationTooltips: options.dotsTooltips, 4646 navigationPosition: options.dotsPosition + ' ' + options.dotsVertical, 4647 normalScrollElements: null, 4648 menu: options.menu,
4649 leftWidth: options.leftWidth, 4650 rightWidth: options.rightWidth, 4651 navigationInject: wrap_inner, 4652 paddingTop: 0, 4653 paddingBottom: 0 4654 }; 4655 multiscroll.multiscroll($settings); 4656 function check_device(device_mode) { 4657 if (device_mode.includes("tablet") || device_mode.includes("mobile")) { 4658 $.fn.multiscroll.destroy(); 4659 $('html, body').css({ 4660 'overflow': 'visible', 4661 'height': 'auto' 4662 }); 4663 } else { 4664 $.fn.multiscroll.build(); 4665 $('html, body').css({ 4666 'overflow': 'hidden', 4667 'height': '100%' 4668 }); 4669 } 4670 } 4671 check_device(device_mode); 4672 if (is_editor && options.menu) { 4673 // If menu is enabled in editor mode 4674 $(options.menu).on('click', 'a', function (e) { 4675 e.preventDefault(); 4676 var target = $(this).parent().attr('data-menuanchor'); 4677 $.fn.multiscroll.moveTo(target); 4678 }); 4679 } 4680 $(window).on("resize", function () { 4681 var device_mode = $("body").attr("data-elementor-device-mode"); 4682 check_device(device_mode); 4683 }); 4684 }; 4685 elementorFrontend.hooks.addAction("frontend/element_ready/ha-multi-scroll.default", MultiScroll); 4686 var ScrollSequence = function ScrollSequence($scope) { 4687 // For Scroll Sequence editor mode 4688 var get_ID = sessionStorage.getItem('haScrollSequenceChangeApply'); 4689 if (get_ID && get_ID == $scope.data('id')) { 4690 $scope.trigger("click"); 4691 $("body,html,document").scrollTop($scope.offset().top); // for scroll to the widget top 4692 sessionStorage.removeItem('haScrollSequenceChangeApply'); 4693 } // For Scroll Sequence editor mode end 4694 4695 var element = $scope.find('.ha-scroll-sequence-wrap'); 4696 if (!element.length) return; 4697 var settings = element.data('settings'), 4698 canvas_wrap = element.find('.ha-scroll-sequence-canvas-wrap'), 4699 is_editor = $scope.hasClass("elementor-element-edit-mode"), 4700 apply_to = settings.apply_to, 4701 target_wrap = '.ha-scroll-sequence-canvas--' + settings.widget_id + ' .ha-scroll-sequence-canvas-wrap-inner', 4702 image_links = [], 4703 folder_path = '', 4704 name_prefix = '', 4705 number_format = 1, 4706 image_type = 'jpg', 4707 total_image = 0, 4708 parent_wrapper, 4709 contid, 4710 containerSS; 4711 if ("gallery" == settings.image_source) { 4712 image_links = settings.images; 4713 } else if ("server" == settings.image_source) { 4714 folder_path = settings.images, name_prefix = settings.name_prefix, number_format = settings.number_format, image_type = settings.image_type, total_image = settings.total_image, image_links = createImageLink(folder_path, name_prefix, number_format, image_type, total_image); 4715 } 4716 canvas_wrap.remove(); 4717 if ('body' == apply_to) { 4718 parent_wrapper = $(document).find('body'); 4719 containerSS = "body"; 4720 } else if ('container' == apply_to) { 4721 parent_wrapper = $scope.closest('.e-con'); 4722 contid = parent_wrapper.data('id'); 4723 containerSS = ".elementor-element-" + contid; 4724 } else if ('section' == apply_to) { 4725 parent_wrapper = $scope.closest('.elementor-section'); 4726 contid = parent_wrapper.data('id'); 4727 containerSS = ".elementor-element-" + contid; 4728 } else if ('column' == apply_to) { 4729 parent_wrapper = $scope.closest('.elementor-column'); 4730 if (parent_wrapper) { 4731 contid = parent_wrapper.data('id'); 4732 containerSS = ".elementor-element-" + contid; 4733 } 4734 } 4735 if (is_editor) { 4736 try { 4737 parent_wrapper.find('.ha-scroll-sequence-canvas-wrap').remove(); 4738 } catch (err) { 4739 console.log(err); 4740 } 4741 } 4742 parent_wrapper.prepend(canvas_wrap); 4743 $(target_wrap).HappySequencer({ 4744 links: image_links, 4745 // Folder where the images are stored 4746 count: total_image // Number of frames (0 to 50 = 51 frames total) 4747 }, function () { 4748 //console.log('All frames loaded.'); 4749 }); 4750 function createImageLink(folder_path, name_prefix, number_format, image_type, total_image) { 4751 var imgGallery = []; 4752 if (!isNaN(number_format) && folder_path !== '' && total_image && ['jpg', 'png', 'webp'].includes(image_type)) { 4753 for (var i = 1; i <= total_image; i++) { 4754 var paddedNumber = i.toString().padStart(number_format, '0'); 4755 var imgUrl = "".concat(folder_path, "/").concat(name_prefix).concat(pad
4755dedNumber, ".").concat(image_type); 4756 imgGallery.push(imgUrl); 4757 } 4758 } 4759 return imgGallery; 4760 } 4761 }; 4762 elementorFrontend.hooks.addAction('frontend/element_ready/ha-scroll-sequence.default', ScrollSequence); 4763 var ScrollTabs = function ScrollTabs($scope) { 4764 content_1(); 4765 function content_1() { 4766 var contentwrap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.ha-scroll-tab-content-wrapper'; 4767 var navItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '.ha-scroll-tab-nav-item'; 4768 var $contentWrapper = $scope.find('.ha-scroll-tab-content-wrapper'); 4769 var totalInnerSection = $contentWrapper.find('.ha-scroll-tab-content-section').length; 4770 var $navItems = $scope.find('.ha-scroll-tab-nav-item'); 4771 // const sectionHeight = 668; 4772 var sectionHeight = $contentWrapper.height(); 4773 var isScrolling = false; 4774 var isAnimating = false; 4775 // let scrollTimer = null; 4776 var animDuration = 10; 4777 var debounceTime = 200; 4778 4779 // Handle navigation item clicks 4780 $navItems.on('click', debounce(function () { 4781 var sectionIndex = parseInt($(this).data('section')); 4782 scrollToSection(sectionIndex); 4783 }, debounceTime)); 4784 4785 // Scroll to specific section 4786 function scrollToSection(sectionIndex) { 4787 isScrolling = true; 4788 isAnimating = true; 4789 var targetScroll = sectionIndex * sectionHeight; 4790 $contentWrapper.animate({ 4791 scrollTop: targetScroll 4792 }, animDuration, function () { 4793 isScrolling = false; 4794 isAnimating = false; 4795 // Ensure final state is correct after animation 4796 updateActiveStates(sectionIndex); 4797 }); 4798 } 4799 function getCurrentSection(deltaY, target) { 4800 var sectionIndex = null; 4801 if (deltaY < 0) { 4802 if (target.hasClass('ha-scroll-tab-content-section')) { 4803 sectionIndex = parseInt(target.data('section')); 4804 } else if (target.closest('.ha-scroll-tab-content-section').length > 0) { 4805 sectionIndex = parseInt(target.closest('.ha-scroll-tab-content-section').data('section')); 4806 } 4807 } else if (deltaY > 0) { 4808 if (target.hasClass('ha-scroll-tab-content-section')) { 4809 sectionIndex = parseInt(target.data('section')); 4810 } else if (target.closest('.ha-scroll-tab-content-section').length > 0) { 4811 sectionIndex = parseInt(target.closest('.ha-scroll-tab-content-section').data('section')); 4812 } 4813 } 4814 return sectionIndex; 4815 } 4816 4817 // Update active states for navigation 4818 function updateActiveStates(activeIndex) { 4819 // Only update if not currently animating to prevent blinking and intermediate activations 4820 if (!isAnimating) { 4821 $navItems.removeClass('active'); 4822 $navItems.filter("[data-section=\"".concat(activeIndex, "\"]")).addClass('active'); 4823 } 4824 } 4825 4826 // Handle scroll event on content wrapper 4827 $contentWrapper.on('scroll', debounce(function () { 4828 if (isScrolling || isAnimating) return; 4829 var scrollTop = $(this).scrollTop(); 4830 var currentSection = Math.round(scrollTop / sectionHeight); 4831 if (false == isAnimating) { 4832 isAnimating = true; 4833 var targetScroll = currentSection * sectionHeight; 4834 $contentWrapper.animate({ 4835 scrollTop: targetScroll 4836 }, animDuration, function () { 4837 isAnimating = false; 4838 updateActiveStates(currentSection); 4839 }); 4840 } 4841 4842 // Only update active states if not animating 4843 if (false == isAnimating) { 4844 updateActiveStates(currentSection); 4845 } 4846 }, debounceTime)); 4847 4848 // Handle wheel scrolling for smoother section transitions 4849 $contentWrapper.on('wheel', debounce(function (e) { 4850 var scrollTop = $(this).scrollTop(); 4851 var currentSection = Math.round(scrollTop / sectionHeight); 4852 var delta = e.originalEvent.deltaY; 4853 var maxScroll = $contentWrapper[0].scrollHeight - $contentWrapper.height(); 4854 var present = getCurrentSection(delta, $(e.target)); 4855 4856 // Allow normal page scroll when at top and scrolling up 4857 if (scrollTop <= 0 && delta < 0) { 4858 return; // Don't prevent default, allow page scroll 4859 } 4860 4861 // Allow normal page scroll when at bottom and scrolling down 4862 if (scrollTop >= maxScroll && delta > 0) { 4863 return; // Don't prevent default, allow page scroll 4864 } 4865 4866 // Custom section scrolling for middle content 4867 e.preventDefault(); 4868 var targetSection = currentSection; 4869 if (e.originalEvent.deltaY < 0) { 4870 // Scrolling up 4871 targetSection = 0 == present ? 0 : present - 1; 4872 } else if (e.originalEvent.deltaY > 0) { 4873 // Scrolling down 4874 targetSection = totalInnerSection - 0 == present ? present : present + 1; 4875 }
4876 if (targetSection !== currentSection && false == isAnimating) { 4877 scrollToSection(targetSection); 4878 // $contentWrapper.trigger( "scroll" ); 4879 } 4880 }, debounceTime)); 4881 4882 // Handle general page wheel scrolling to detect when over content wrapper 4883 $(document).on('wheel', debounce(function (e) { 4884 var $target = $(e.target); 4885 4886 // If scrolling over content wrapper or its children, let the content wrapper handle it 4887 if ($target.closest('.ha-scroll-tab-content-wrapper').length > 0) { 4888 return; 4889 } 4890 4891 // For other areas, allow normal page scrolling 4892 }, debounceTime)); 4893 } 4894 }; 4895 elementorFrontend.hooks.addAction('frontend/element_ready/ha-scroll-tabs.default', ScrollTabs); 4896 var advancedPricingTable = function advancedPricingTable($scope) { 4897 var currentIndex = 0; 4898 var table = $scope.find('.ha-adv-pricing-table-wrap'); 4899 var data = table.data('price-settings'); 4900 var tiers = data; 4901 4902 // console.log(tiers); 4903 // console.log(data); 4904 4905 function advancePrice(priceContainer, items) { 4906 contentManage(priceContainer, items, 0); 4907 priceContainer.find('.ha-adv-pricing-table-slider-dot').on('click', function () { 4908 // const index = $('.slider-dot').index(this); 4909 var index = priceContainer.find('.ha-adv-pricing-table-slider-dot').index(this); 4910 // setTier(index); 4911 contentManage(priceContainer, items, index); 4912 var sliderContainer = priceContainer.find('.ha-adv-pricing-table-slider-container.style-1'); 4913 //console.log(sliderContainer); 4914 if (0 < sliderContainer.length) { 4915 sliderControl(sliderContainer, items, index); 4916 } 4917 }); 4918 var $style_1 = priceContainer.find('.ha-adv-pricing-table-slider-container.style-1'); 4919 if (0 < $style_1.length) { 4920 $style_1.find('input[type="range"]').on('input', function (e) { 4921 var value = parseInt($(this).val()); 4922 // setTier(value); 4923 contentManage(priceContainer, items, value); 4924 4925 // var sliderContainer = priceContainer.find('.ha-adv-pricing-table-slider-container.style-1'); 4926 //console.log($style_1); 4927 // if ( 0 < $style_1.length ) { 4928 sliderControl($style_1, items, value); 4929 // } 4930 }); 4931 } 4932 var $style_2 = priceContainer.find('.ha-adv-pricing-table-slider-container.style-2 input[type="range"]'); 4933 if (0 < $style_2.length) { 4934 $style_2.rangeslider({ 4935 polyfill: false, 4936 onInit: function onInit() { 4937 var range = ''; 4938 var $ruler = $('<div class="rangeslider__ruler" />'); 4939 var step = 1; 4940 // var i = 0; 4941 var i = this.min; 4942 while (i <= this.max) { 4943 range += i + ' '; 4944 i = i + step; 4945 } 4946 // $ruler[0].innerHTML = getRulerRange(this.min, this.max, 1); 4947 $ruler[0].innerHTML = range; 4948 this.$range.prepend($ruler); 4949 }, 4950 onSlide: function onSlide(position, value) { 4951 // console.log(position); 4952 //console.log(value); 4953 contentManage(priceContainer, items, value); 4954 } 4955 }); 4956 } 4957 var $style_3 = priceContainer.find('.ha-adv-pricing-table-slider-container.style-3'); 4958 if (0 < $style_3.length) { 4959 $style_3.find('input[type="range"]').on('input', function (e) { 4960 var value = parseInt($(this).val()); 4961 contentManage(priceContainer, items, value); 4962 simpleSliderControl($style_3, items, value); 4963 }); 4964 } 4965 var $style_4 = priceContainer.find('.ha-adv-pricing-table-slider-container.style-4'); 4966 if (0 < $style_4.length) { 4967 $style_4.find('input[type="range"]').on('input', function (e) { 4968 var value = parseInt($(this).val()); 4969 contentManage(priceContainer, items, value); 4970 simpleSliderControl($style_4, items, value); 4971 }); 4972 } 4973 var $style_5 = priceContainer.find('.ha-adv-pricing-table-slider-container.style-5'); 4974 if (0 < $style_5.length) { 4975 $style_5.find('input[type="range"]').on('input', function (e) { 4976 var value = parseInt($(this).val()); 4977 contentManage(priceContainer, items, value); 4978 simpleSliderControl($style_5, items, value); 4979 }); 4980 } 4981 } 4982 function contentManage(priceContainer, items, index) { 4983 var tier = items[index]; 4984 //console.log('Selected Tier:', tier); 4985 // Update text content 4986 priceContainer.find('[data-plan-name]').text(tier.plan_name); 4987 var priceDisplay = priceContainer.find('.ha-adv-pricing-table-price-display');
4988 priceDisplay.find('[data-currency]').text(tier.symbol); 4989 var price = priceDisplay.find('.ha-adv-pricing-table-current-price'); 4990 price.find('[data-price]').text(tier.price); 4991 // price.addClass('hm-super-btn-st-9'); 4992 4993 // currentIndex > index 4994 // price.css('animation', `haAdvPricingTableLetterroll cubic-bezier(0.4, 0, 0.2, 1) 0.5s`); 4995 // currentIndex > index ? price.css('animation', 'haAdvPricingTableLetterroll cubic-bezier(0.4, 0, 0.2, 1) 0.5s') : price.css('animation', 'haAdvPricingTableBackroll cubic-bezier(0.4, 0, 0.2, 1) 0.5s'); ha-adv-pricing-table-price-display 4996 4997 if (index > currentIndex) { 4998 priceDisplay.css('animation', "haAdvPricingTableLetterroll cubic-bezier(0.4, 0, 0.2, 1) 0.5s"); 4999 currentIndex = index; 5000 } 5001 if (index < currentIndex) { 5002 priceDisplay.css('animation', 'haAdvPricingTableBackroll cubic-bezier(0.4, 0, 0.2, 1) 0.5s'); 5003 currentIndex = index; 5004 } 5005 var t = setTimeout(function () { 5006 priceDisplay.removeAttr('style'); 5007 // .css('animation', ''); 5008 clearTimeout(t); 5009 }, 500); 5010 priceContainer.find('[data-price-period]').text(tier.period); 5011 //console.log(tier.plan_related_text); 5012 5013 if (tier.plan_related_text) { 5014 var plan_related = "<span>".concat(tier.plan_related_text, "</span>"); 5015 if (tier.plan_related_icon) { 5016 plan_related = "<i class=\"".concat(tier.plan_related_icon, "\"></i>") + plan_related; 5017 } 5018 priceContainer.find('[data-savings]').html(plan_related); 5019 priceContainer.find('[data-savings]').css('display', ''); 5020 } else { 5021 priceContainer.find('[data-savings]').css('display', 'none'); 5022 } 5023 // priceContainer.find('[data-savings]').text(tier.plan_related_text + '<i class="fas fa-check"></i>'); 5024 5025 priceContainer.find('[data-cta-button]').text(tier.button_text); 5026 // priceContainer.find('[data-cta-button]').attr('class', `ha-adv-pricing-table-btn ${tier.buttonClass}`); 5027 priceContainer.find('[data-cta-button]').attr(tier.button_attr); 5028 5029 // Update original price visibility .ha-adv-pricing-table-original-price 5030 var originalPriceEl = priceContainer.find('.ha-adv-pricing-table-original-price'); 5031 // const originalPriceEl = priceContainer.find('[data-original-price]'); 5032 if (tier.original_price) { 5033 originalPriceEl.css('display', ''); 5034 originalPriceEl.find('[data-original-price]').text("".concat(tier.original_price)); 5035 } else { 5036 originalPriceEl.css('display', 'none'); 5037 } 5038 5039 // Update features 5040 var featuresEle = priceContainer.find('[data-features]'); 5041 var features_list = ''; 5042 //featuresEle.html(`${tier.features_desc}`); 5043 5044 tier.features_desc.forEach(function (element) { 5045 features_list += "<li>"; 5046 if (element.icon) { 5047 features_list += "<i class=\"".concat(element.icon, "\"></i>"); 5048 } 5049 if (element.feature && !element.tooltip) { 5050 features_list += "<div class=\"ha-adv-pricing-table-feature-text\">".concat(element.feature, "</div>"); 5051 } 5052 if (element.tooltip) { 5053 features_list += "<div class=\"ha-adv-pricing-table-feature-text ha-adv-pricing-table-feature-tooltip\">".concat(element.feature, "<span class=\"ha-adv-pricing-table-feature-tooltip-text\">").concat(element.tooltip, "</span></div>"); 5054 } 5055 features_list += "</li>"; 5056 }); 5057 featuresEle.html("<ul>".concat(features_list, "</ul>")); 5058 } 5059 function sliderControl(sliderContainer, items, index) { 5060 var sliderTrack = sliderContainer.find('.ha-adv-pricing-table-slider-track'); 5061 var sliderThumb = sliderContainer.find('.ha-adv-pricing-table-slider-thumb'); 5062 var sliderDots = sliderContainer.find('.ha-adv-pricing-table-slider-dots-container'); 5063 5064 // Use the Pythagorean theorem to calculate the distance 5065 // const distance = Math.hypot(aX - bX, aY - bY); 5066 5067 var trackWidth = sliderTrack.outerWidth(); // 24 is thumb width 5068 var thumbWidth = sliderThumb.outerWidth(); 5069 var percentage = index / (items.length - 1) * 100; 5070 var position = percentage / 100 * (trackWidth - thumbWidth); 5071 // $sliderThumb.css('left', `${position}px`); 5072 5073 var withoutPointertrackWidth = trackWidth - 24; 5074 var width = withoutPointertrackWidth / (items.length - 1) * index; 5075 // const width = ((trackWidth / tiers.length) * (index + 1)); 5076 // $sliderThumb.css('left', `${position}px`); 5077 if (100 == percentage) { 5078 //$sliderThumb.css('width', `calc(${percentage}%`); 5079 // $sliderThumb.css('width', `calc(${width}%`); 5080 sliderThumb.css('width', "calc(".concat(width, "px + 24px")); 5081 } else if (0 == percentage) { 5082 //$sliderThumb.css('width', `calc(${percentage}% + 24px`); 5083 // $sliderThumb.css('width', `calc(${width}% + 24px`); 5084 sliderThumb.css('width', "calc(24px)"); 5085 } else { 5086 //$sliderThumb.css('width', `calc(${percentage}% + 12px`); 5087 // $sliderThumb.css('width', `calc(${width}% + 12px`); 5088 sliderThumb.css('width', "calc(".concat(width, "px + 24px")); 5089 // $sliderThumb.css('width', `calc(${width}px + 12px`); 5090 } 5091 // $sliderThumb.css('width', `${width}%`); 5092 5093 //console.log('value', index); 5094 //console.log('length', items.length); 5095 //console.log('percentage',percentage); 5096 //console.log('width',width); 5097 //console.log('trackWidth',trackWidth); 5098 //console.log('trackWidth',(trackWidth / 6)); 5099 //console.log('================='); 5100 5101 // Update slider dots 5102 sliderDots.find('.ha-adv-pricing-table-slider-dot').each(function (i) { 5103 $(this).toggleClass('active', i === index); 5104 }); 5105 } 5106 5107 // this is for simple slider style 3, 4, 5 5108 function simpleSliderControl(sliderContainer, items, index) { 5109 var rangeWrap = sliderContainer.find('.ha-adv-pricing-table-slider-range-wrap'); 5110 var sliderThumb = sliderContainer.find('.ha-adv-pricing-table-slider-range-thumb'); 5111 var dotsContainer = sliderContainer.find('.ha-adv-pricing-table-slider-dots-container'); 5112 // const textContainer = sliderContainer.find('.text-container'); 5113 5114 var rangerThumb = 20; 5115 if (sliderContainer.hasClass('style-4')) { 5116 rangerThumb = 24; 5117 } 5118 var rangeWrapWidth = rangeWrap.outerWidth(); // 24 is thumb width 5119 var thumbWidth = sliderThumb.outerWidth(); 5120 var percentage = index / (items.length - 1) * 100; 5121 5122 // const withoutPointertrackWidth = ( rangeWrapWidth - 24 ); 5123 var withoutPointertrackWidth = rangeWrapWidth - rangerThumb; 5124 var width = withoutPointertrackWidth / (items.length - 1) * index; 5125 if (100 == percentage) { 5126 sliderThumb.css('width', "calc(".concat(width, "px + ").concat(rangerThumb, "px")); 5127 } else if (0 == percentage) { 5128 sliderThumb.css('width', "calc(".concat(rangerThumb, "px)")); 5129 } else { 5130 sliderThumb.css('width', "calc(".concat(width, "px + ").concat(rangerThumb, "px")); 5131 } 5132 5133 // console.log('value', index); 5134 // console.log('length', items.length); 5135 // console.log('percentage',percentage); 5136 // console.log('width',width); 5137 // console.log('rangeWrapWidth',rangeWrapWidth); 5138 // console.log('rangeWrapWidth',(rangeWrapWidth / 6)); 5139 // console.log('================='); 5140 5141 // Update slider dots 5142 dotsContainer.find('div').each(function (i) { 5143 $(this).toggleClass('active', i === index); 5144 }); 5145 5146 // textContainer.find('div').each(function (i) { 5147 // $(this).toggleClass('active', i === index); 5148 // }); 5149 5150 // return; 5151 } 5152 advancePrice(table, tiers); 5153 }; 5154 elementorFrontend.hooks.addAction('frontend/element_ready/ha-advanced-pricing-table.default', advancedPricingTable); 5155 var SuperButton = function SuperButton($scope) { 5156 if (elementorFrontend.isEditMode()) { 5157 return; 5158 } 5159 var $btn_wrap = $scope.find('.ha-super-btn-stl-10'); 5160 if ($btn_wrap.length > 0) { 5161 var $btn = $btn_wrap.find('button'); 5162 $btn.on('click', function (e) { 5163 e.preventDefault(); 5164 $btn_wrap.toggleClass("open"); 5165 }); 5166 $(document).on('click', function (e) { 5167 if (e.target.closest(".ha-super-btn-stl-10")) { 5168 return; 5169 } 5170 if ($btn_wrap.hasClass("open")) { 5171 $btn_wrap.removeClass("open"); 5172 } 5173 }); 5174 $(window).on('scroll', function () { 5175 if ($btn_wrap.hasClass("open")) { 5176 $btn_wrap.removeClass("open"); 5177 } 5178 }); 5179 } 5180 }; 5181 elementorFrontend.hooks.addAction('frontend/element_ready/ha-super-button.default', SuperButton); 5182 var AdvancedSearchWidget = function AdvancedSearchWidget($scope) { 5183 var $wrap = $scope.find(".ha-advanced-search-advanced-search-wrap"); 5184 if (!$wrap.length) return; 5185 5186 // ------------------------ 5187 // Init guard + namespacing 5188 // ------------------------ 5189 var widgetId = $wrap.attr("id") || "ha-advanced-search-advanced-search-" + Math.random().toString(16).slice(2); 5190 5191 // ensure wrap has an id (layout-3 close logic relies on this) 5192 if (!$wrap.attr("id")) { 5193 $wrap.attr("id", widgetId); 5194 } 5195 var ns = ".haAdvSearch." + widgetId; 5196 5197 // Prevent double init (Elementor can re-run element_ready) 5198 if ($wrap.data("haAdvSearchInit")) return; 5199 $wrap.data("haAdvSearchInit", true); 5200 5201 // Elements (scoped inside this widget) 5202 var $searchBox = $scope.find(".ha_advanced_search_search_box"); 5203 var $input = $scope.find(".ha_advanced_search_search_input"); 5204 var $button = $scope.find(".ha_advanced_search_search_button"); 5205 var $clearButton = $scope.find(".ha_advanced_search_clear_button"); 5206 var $clearButtonL4 = $scope.find(".ha_advanced_search_clear_button_l4"); 5207 var $resultsContainer = $scope.find(".ha_advanced_search_results_container"); 5208 var $resultsList = $scope.find(".ha_advanced_search_results_list"); 5209 var $resultsFooter = $scope.find(".ha_advanced_search_results_footer"); 5210 5211 // Layout detect 5212 var $layout3Root = $scope.closest(".ha-advanced-search-search-layout-layout-3"); 5213 if (!$layout3Root.length && $scope.hasClass("ha-advanced-search-search-layout-layout-3")) { 5214 $layout3Root = $scope; 5215 } 5216 var isLayout3 = $layout3Root.length > 0 || $scope.find(".ha_advanced_search_layout3_shell").length > 0; 5217 var $layout4Root = $scope.closest(".ha-advanced-search-search-layout-layout-4"); 5218 if (!$layout4Root.length && $scope.hasClass("ha-advanced-search-search-layout-layout-4")) { 5219 $layout4Root = $scope; 5220 } 5221 var isLayout4 = !isLayout3 && ($layout4Root.length > 0 || $scope.find(".ha_advanced_search_layout4_shell").length > 0); 5222 var isLayout2 = !isLayout3 && !isLayout4 && $scope.find(".ha_advanced_search_results-container").length > 0; 5223 var $searchTermDisplay = $scope.find('[id^="ha-advanced-search-search-term-display-"]'); 5224 var $categorySelect = $scope.find(".ha_advanced_search_category_select"); // cat:* and page:* 5225 var $tagSelect = $scope.find(".ha_advanced_search_tag_select"); 5226 var $popularKeywords = $scope.find(".ha-advanced-search-keyword, .ha_advanced_search_layout3_popular_item"); 5227 5228 // Layout-3 specific elements 5229 var $layout3Shell = $scope.find(".ha_advanced_search_layout3_shell"); 5230 var $layout3Trigger = $scope.find(".ha_advanced_search_search-trigger"); 5231 var $layout3InitialInput = $scope.find(".ha_advanced_search_search-input-initial"); 5232 var $layout3Close = $scope.find(".ha_advanced_search_search-close"); 5233 var $layout3Curtain = $scope.find(".ha_advanced_search_curtain"); 5234 var $layout3ResultsBlock = $scope.find(".ha_advanced_search_layout3_results_block"); 5235 var $layout3PopularBlock = $scope.find(".ha_advanced_search_layout3_popular_search"); 5236 var layout3ClosedAt = 0; 5237 var $layout4Shell = $scope.find(".ha_advanced_search_layout4_shell"); 5238 var $layout4Trigger = $layout4Shell.find(".ha_advanced_search_search-trigger"); 5239 var $layout4InitialInput = $layout4Shell.find(".ha_advanced_search_search-input-initial"); 5240 var $layout4Panel = $layout4Shell.find(".ha_advanced_search_search-panel"); 5241 var $layout4Close = $layout4Shell.find(".ha_advanced_search_search-close"); 5242 var $layout4InputHolder = $layout4Shell.find(".ha_advanced_search_search-input-holder"); 5243 var $layout4ResultCount = $layout4Shell.find('[id^="ha-advanced-search-result-count-"]'); 5244 5245 // Date elements 5246 var $dateSelect = $scope.find(".ha_advanced_search_date_select"); 5247 var $dateRangeWrap = $scope.find(".ha_advanced_search_date_range"); 5248 var $dateFrom = $scope.find(".ha_advanced_search_date_from"); 5249 var $dateTo = $scope.find(".ha_advanced_search_date_to"); 5250 var $dateIcons = $scope.find(".ha_advanced_search_date_icon"); 5251 var dateMode = "all"; // all | today | this_month | custom 5252 var dateFromVal = ""; // YYYY-MM-DD 5253 var dateToVal = ""; // YYYY-MM-DD 5254 5255 // ------------------------ 5256 // Layout-3 suppress-close (native select safety) 5257 // ------------------------ 5258 var layout3SuppressCloseUntil = 0; 5259 function suppressLayout3Close(ms) { 5260 layout3SuppressCloseUntil = Date.now() + (ms || 800); 5261 } 5262 function isLayout3CloseSuppressed() { 5263 return Date.now() < layout3SuppressCloseUntil; 5264 } 5265 5266 // ------------------------ 5267 // Clear any previous handlers for this widget instance (safe) 5268 // ------------------------ 5269 $(document).off(ns); 5270 $scope.off(ns); 5271 $resultsContainer.off(ns); 5272 $input.off(ns); 5273 $button.off(ns); 5274 $clearButton.off(ns); 5275 $clearButtonL4.off(ns); 5276 $categorySelect.off(ns); 5277 $tagSelect.off(ns); 5278 $popularKeywords.off(ns); 5279 $searchBox.off(ns); 5280 $dateSelect.off(ns); 5281 $dateFrom.off(ns); 5282 $dateTo.off(ns); 5283 $dateRangeWrap.off(ns); 5284 $dateIcons.off(ns); 5285 5286 // ------------------------ 5287 // State 5288 // ------------------------ 5289 var searchTerm = ""; 5290 var currentPage = 1; 5291 var totalPages = 1; 5292 var searchTimeout = null; 5293 var isLoadingAll = false;
5294 5295 // Filters 5296 var selectedCategory = ""; // slug 5297 var selectedTag = ""; // slug 5298 var selectedPageId = ""; // string 5299 5300 // keyword tracking state (per widget) 5301 var lastTrackedTerm = ""; 5302 var lastTrackedAt = 0; 5303 var justCleared = false; 5304 var justClearedTimer = null; 5305 5306 // Settings (from data attributes) 5307 var settings = { 5308 postTypes: JSON.parse($wrap.attr("data-post-types") || '["post","page"]'), 5309 initialResultsCount: parseInt($wrap.attr("data-initial-results-count"), 10) || 5, 5310 showContentImage: $wrap.attr("data-show-content-image") === "true", 5311 notFoundText: $wrap.attr("data-not-found-text") || "No results found", 5312 loadMoreText: $wrap.attr("data-load-more-text") || "Load More" 5313 }; 5314 var pageHasTags = $wrap.attr("data-page-has-tags") === "true"; 5315 var showDateFilter = $wrap.attr("data-show-date-filter") === "true"; 5316 5317 // ------------------------ 5318 // UI helpers 5319 // ------------------------ 5320 function showResults() { 5321 // If results show, date range must hide 5322 if ($dateRangeWrap.length) $dateRangeWrap.hide(); 5323 $resultsContainer.addClass("ha_advanced_search_visible"); 5324 } 5325 function hideResults() { 5326 $resultsContainer.removeClass("ha_advanced_search_visible"); 5327 } 5328 function showLayout3Popular() { 5329 if (!isLayout3) return; 5330 if (!$layout3PopularBlock.length) return; 5331 $resultsContainer.addClass("ha_advanced_search_visible"); 5332 $layout3PopularBlock.show(); 5333 $layout3ResultsBlock.hide(); 5334 $resultsFooter.hide(); 5335 } 5336 function showLayout3ResultsPanel() { 5337 if (!isLayout3) return; 5338 if (!$layout3ResultsBlock.length) return; 5339 $resultsContainer.addClass("ha_advanced_search_visible"); 5340 $layout3PopularBlock.hide(); 5341 $layout3ResultsBlock.show(); 5342 $resultsFooter.show(); 5343 } 5344 function openLayout3Search() { 5345 if (!isLayout3 || !$layout3Shell.length) return; 5346 var $container = $layout3Shell.find('.ha_advanced_search_search-container'); 5347 var rect = $layout3Shell.get(0).getBoundingClientRect(); 5348 var offsetTop = rect.top; 5349 $container.css({ 5350 position: 'fixed', 5351 top: offsetTop + 'px', 5352 width: '100vw', 5353 left: '0', 5354 'z-index': '9999' 5355 }); 5356 document.body.style.overflow = 'hidden'; 5357 $layout3Root.addClass("ha_advanced_search_search-active"); 5358 $scope.addClass("ha_advanced_search_search-active"); 5359 5360 // Safe autofocus (only if not already focused) 5361 if (document.activeElement !== $input.get(0)) { 5362 setTimeout(function () { 5363 var _$input$get; 5364 (_$input$get = $input.get(0)) === null || _$input$get === void 0 || _$input$get.focus(); 5365 5366 // â trigger instant search when opening (if input already has text) 5367 searchTerm = ($input.val() || "").trim(); 5368 if (searchTimeout) clearTimeout(searchTimeout); 5369 searchTimeout = setTimeout(function () { 5370 if (searchTerm.length >= 2) performSearch();else resetResultsUI(); 5371 }, 300); 5372 }, 120); 5373 } else { 5374 // â already focused, still run the same logic 5375 searchTerm = ($input.val() || "").trim(); 5376 if (searchTimeout) clearTimeout(searchTimeout); 5377 searchTimeout = setTimeout(function () { 5378 if (searchTerm.length >= 2) performSearch();else resetResultsUI(); 5379 }, 300); 5380 } 5381 } 5382 function closeLayout3Search() { 5383 if (!isLayout3 || !$layout3Shell.length) return; 5384 document.body.style.overflow = 'visible'; 5385 $layout3Root.removeClass("ha_advanced_search_search-active"); 5386 $scope.removeClass("ha_advanced_search_search-active"); 5387 } 5388 function openLayout4Search() { 5389 if (!isLayout4 || !$layout4Panel.length) return; 5390 $layout4Panel.addClass("opened"); 5391 $layout4Root.addClass("ha_advanced_search_search-active"); 5392 $scope.addClass("ha_advanced_search_search-active"); 5393 setTimeout(function () { 5394 $input.trigger("focus"); 5395 }, 80); 5396 } 5397 function closeLayout4Search() { 5398 if (!isLayout4 || !$layout4Panel.length) return; 5399 $layout4Panel.removeClass("opened"); 5400 $layout4Root.removeClass("ha_advanced_search_search-active"); 5401 $scope.removeClass("ha_advanced_search_search-active"); 5402 $layout4InputHolder.removeClass("has-value"); 5403 $input.val(""); 5404 resetResultsUI(); 5405 } 5406 function updateLayout4ResultCount(count) { 5407 if (!isLayout4 || !$layout4ResultCount.length) return; 5408 var safeCount = parseInt(count, 10); 5409 if (isNaN(safeCount) || safeCount < 0) safeCount = 0; 5410 $layout4ResultCount.text(String(safeCount)); 5411 } 5412 function showDateRange() { 5413 // If date range shows, results must hide 5414 hideResults(); 5415 $dateRangeWrap.show(); 5416 } 5417 function hideDateRange() { 5418 $dateRangeWrap.hide(); 5419 } 5420 function updateViewAllVisibility() { 5421 var $viewAll = $scope.find(".ha_advanced_search_results_footer"); 5422 if (!$viewAll.length) return; 5423 var shouldShow = totalPages > 1 && currentPage < totalPages && !isLoadingAll; 5424 if (shouldShow) $viewAll.show();else $viewAll.hide(); 5425 } 5426 function clearResultsList() { 5427 if (isLayout2) { 5428 $resultsContainer.find(".ha_advanced_search_result-item, .ha_advanced_search_result_item, .ha_advanced_search_no_results").remove(); 5429 } else { 5430 $resultsList.empty(); 5431 } 5432 } 5433 function resetResultsUI() { 5434 hideResults(); 5435 clearResultsList(); 5436 totalPages = 1; 5437 currentPage = 1; 5438 isLoadingAll = false;
5439 updateLayout4ResultCount(0); 5440 updateViewAllVisibility(); 5441 if (isLayout3 && ($layout3Root.hasClass("ha_advanced_search_search-active") || $scope.hasClass("ha_advanced_search_search-active"))) { 5442 showLayout3Popular(); 5443 } 5444 } 5445 function toggleLayout3ResultsHeading(showHeading) { 5446 if (!isLayout3) return; 5447 var $heading = $resultsContainer.find(".ha_advanced_search_search-results > h3").first(); 5448 if (!$heading.length) return; 5449 if (showHeading) $heading.show();else $heading.hide(); 5450 } 5451 function searchIfReady() { 5452 // Search only if user has a term 5453 if (searchTerm && searchTerm.length >= 2) { 5454 resetResultsUI(); 5455 performSearch(); 5456 } else { 5457 resetResultsUI(); 5458 } 5459 } 5460 function trackKeyword(keyword) { 5461 keyword = (keyword || "").trim(); 5462 if (!keyword) return; 5463 if (keyword.length < 2) return; 5464 var now = Date.now(); 5465 if (keyword === lastTrackedTerm && now - lastTrackedAt < 15000) return; // 15s cooldown 5466 5467 lastTrackedTerm = keyword; 5468 lastTrackedAt = now; 5469 $.ajax({ 5470 url: HappyProLocalize.ajax_url, 5471 type: "POST", 5472 dataType: "json", 5473 data: { 5474 action: "ha_advanced_search_track_keyword", 5475 nonce: HappyProLocalize.nonce, 5476 keyword: keyword 5477 } 5478 }); 5479 } 5480 5481 // ------------------------ 5482 // AJAX helpers 5483 // ------------------------ 5484 function buildAjaxData(page) { 5485 var data = { 5486 action: "ha_advanced_search", 5487 nonce: HappyProLocalize.nonce, 5488 search_term: searchTerm, 5489 post_types: settings.postTypes, 5490 page: page, 5491 initial_results_count: settings.initialResultsCount, 5492 show_content_image: settings.showContentImage, 5493 date_mode: dateMode 5494 }; 5495 if (dateMode === "custom") { 5496 data.date_from = dateFromVal; 5497 data.date_to = dateToVal; 5498 } 5499 5500 // Page selection is exclusive 5501 if (selectedPageId) { 5502 data.page_id = selectedPageId; 5503 return data; 5504 } 5505 5506 // Category + Tag combined 5507 if (selectedCategory) data.category = selectedCategory; 5508 if (selectedTag) data.tag = selectedTag; 5509 return data; 5510 } 5511 function fetchResults(page) { 5512 return $.ajax({ 5513 url: HappyProLocalize.ajax_url, 5514 type: "POST", 5515 dataType: "json", 5516 data: buildAjaxData(page) 5517 }); 5518 } 5519 function renderResultItem(result) { 5520 var isMedia = result.post_type && String(result.post_type).toLowerCase() === "media" || result.mime_type || result.media_url; 5521 var displayTitle = isMedia ? result.media_name || result.media_url || result.title : result.title; 5522 var linkUrl = isMedia && result.media_url ? result.media_url : result.permalink; 5523 var itemHtml = ""; 5524 if (isLayout2) { 5525 var excerptText = !isMedia && result.excerpt ? result.excerpt : ""; 5526 var iconHtml = result.image ? "<img src=\"".concat(result.image, "\" alt=\"").concat(displayTitle, "\" style=\"width: 100%; height: 100%; object-fit: cover; border-radius: 0.5rem;\" />") : "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"></circle><polyline points=\"21 15 16 10 5 21\"></polyline></svg>"; 5527 itemHtml = "\n\t\t\t\t<div class=\"ha_advanced_search_result_item ha_advanced_search_result-item\" data-url=\"".concat(linkUrl, "\" data-target=\"").concat(isMedia ? "_blank" : "_self", "\">\n\t\t\t\t\t<div class=\"ha_advanced_search_result-img\">").concat(iconHtml, "</div>\n\t\t\t\t\t<div class=\"ha_advanced_search_result-info\">\n\t\t\t\t\t\t<h3>").concat(displayTitle, "</h3>\n\t\t\t\t\t\t").concat(excerptText ? "<p>".concat(excerptText, "</p>") : "", "\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t"); 5528 } else if (isLayout3) { 5529 itemHtml = "\n\t\t\t\t<a href=\"".concat(linkUrl, "\" class=\"ha_advanced_search_result_item ha_advanced_search_result-item\" ").concat(isMedia ? 'target="_blank"' : "", ">\n\t\t\t\t\t<h3 class=\"ha_advanced_search_result-title\">").concat(displayTitle, "</h3>\n\t\t\t\t</a>\n\t\t\t"); 5530 } else if (isLayout4) { 5531 var imageHtml = result.image ? "<img src=\"".concat(result.image, "\" alt=\"").concat(displayTitle, "\" />") : "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"></circle><polyline points=\"21 15 16 10 5 21\"></polyline></svg>"; 5532 itemHtml = "\n\t\t\t\t<a href=\"".concat(linkUrl, "\" class=\"ha_advanced_search_search-panel-item ha_advanced_search_result_item\" ").concat(isMedia ? 'target="_blank"' : "", ">\n\t\t\t\t\t<div class=\"ha_advanced_search_image-box\">").concat(imageHtml, "</div>\n\t\t\t\t\t<div class=\"ha_advanced_search_text-holder\">\n\t\t\t\t\t\t<strong class=\"ha_advanced_search_result-title\">").concat(displayTitle, "</strong>\n\t\t\t\t\t\t<span class=\"ha_advanced_search_result-subtitle\">").concat(isMedia ? "Media File" : result.post_type || "", "</span>\n\t\t\t\t\t</div>\n\t\t\t\t</a>\n\t\t\t"); 5533 } else { 5534 itemHtml = "\n\t\t\t\t<a href=\"".concat(linkUrl, "\" class=\"ha_advanced_search_result_item\" ").concat(isMedia ? 'target="_blank"' : "", ">\n\t\t\t\t\t").concat(result.image ? "<div class=\"ha_advanced_search_result_icon_wrapper\"><img src=\"".concat(result.image, "\" alt=\"").concat(displayTitle, "\" style=\"width: 100%; height: 100%; object-fit: cover; border-radius: 0.5rem;\" /></div>") : "<div class=\"ha_advanced_search_result_icon_wrapper\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"></rect><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"></circle><polyline points=\"21 15 16 10 5 21\"></polyline></svg></div>", "\n\t\t\t\t\t<div class=\"ha_advanced_search_result_content\">\n\t\t\t\t\t\t<div class=\"ha_advanced_search_result_name\" title=\"").concat(displayTitle, "\">").concat(displayTitle, "</div>\n\t\t\t\t\t\t<div class=\"ha_advanced_search_result_category\">").concat(isMedia ? "Media File" : result.post_type || "", "</div>\n\t\t\t\t\t\t").concat(!isMedia && result.excerpt ? "<div class=\"ha_advanced_search_result_excerpt\">".concat(result.excerpt, "</div>") : "", "\n\t\t\t\t\t</div>\n\t\t\t\t</a>\n\t\t\t"); 5535 } 5536 $resultsList.append(itemHtml); 5537 } 5538 function onSearchSuccess(response) { 5539 if (!response || !response.success) return; 5540 var results = response.data && response.data.results ? response.data.results : []; 5541 var pages = response.data && typeof response.data.pages !== "undefined" ? response.data.pages : 1; 5542 5543 // IMPORTANT: parseInt so totalPages comparisons work 5544 totalPages = parseInt(pages, 10) || 1; 5545 currentPage = 1; 5546 isLoadingAll = false;
5547 clearResultsList(); 5548 if (results.length > 0) { 5549 results.forEach(function (result) { 5550 renderResultItem(result); 5551 }); 5552 updateLayout4ResultCount(response.data.found); 5553 showLayout3ResultsPanel(); 5554 toggleLayout3ResultsHeading(true); 5555 if (isLayout2 && $resultsFooter.length) { 5556 $resultsFooter.appendTo($resultsContainer); 5557 } 5558 showResults(); 5559 5560 // update view-all link (keep, even though layout-3 uses loadAllPages) 5561 var $viewAllLink = $scope.find(".ha_advanced_search_view_all_link"); 5562 if ($viewAllLink.length) { 5563 var searchUrl = new URL(window.location.href); 5564 searchUrl.searchParams.set("s", searchTerm); 5565 if (selectedPageId) { 5566 searchUrl.searchParams.set("page_id", selectedPageId); 5567 searchUrl.searchParams["delete"]("category"); 5568 searchUrl.searchParams["delete"]("tag"); 5569 } else { 5570 if (selectedCategory) searchUrl.searchParams.set("category", selectedCategory);else searchUrl.searchParams["delete"]("category"); 5571 if (selectedTag) searchUrl.searchParams.set("tag", selectedTag);else searchUrl.searchParams["delete"]("tag"); 5572 searchUrl.searchParams["delete"]("page_id"); 5573 } 5574 searchUrl.searchParams.set("date_mode", dateMode); 5575 if (dateMode === "custom") { 5576 if (dateFromVal) searchUrl.searchParams.set("date_from", dateFromVal);else searchUrl.searchParams["delete"]("date_from"); 5577 if (dateToVal) searchUrl.searchParams.set("date_to", dateToVal);else searchUrl.searchParams["delete"]("date_to"); 5578 } else { 5579 searchUrl.searchParams["delete"]("date_from"); 5580 searchUrl.searchParams["delete"]("date_to"); 5581 } 5582 $viewAllLink.attr("href", searchUrl.toString()); 5583 } 5584 updateViewAllVisibility(); 5585 } else { 5586 if (isLayout2) { 5587 $resultsFooter.before("<div class=\"ha_advanced_search_no_results\">".concat(settings.notFoundText, "</div>")); 5588 } else { 5589 $resultsList.html("<div class=\"ha_advanced_search_no_results\">".concat(settings.notFoundText, "</div>")); 5590 } 5591 showLayout3ResultsPanel(); 5592 toggleLayout3ResultsHeading(false); 5593 updateLayout4ResultCount(0); 5594 showResults(); 5595 totalPages = 1; 5596 updateViewAllVisibility(); 5597 } 5598 } 5599 function onSearchError(xhr, status, error) { 5600 console.error("Search error:", error); 5601 $resultsList.html("<div class=\"ha_advanced_search_no_results\">".concat(HappyProLocalize.strings && HappyProLocalize.strings.no_results ? HappyProLocalize.strings.no_results : "No results found", "</div>")); 5602 showLayout3ResultsPanel(); 5603 toggleLayout3ResultsHeading(false); 5604 updateLayout4ResultCount(0); 5605 totalPages = 1; 5606 updateViewAllVisibility(); 5607 } 5608 function onSearchComplete() { 5609 $button.prop("disabled", false); 5610 if (document.activeElement !== $input.get(0) && $input.is(":visible")) { 5611 setTimeout(function () { 5612 var _$input$get2; 5613 (_$input$get2 = $input.get(0)) === null || _$input$get2 === void 0 || _$input$get2.focus(); 5614 5615 // Restore cursor at end 5616 var val = $input.val(); 5617 if ($input.get(0).setSelectionRange) { 5618 $input.get(0).setSelectionRange(val.length, val.length); 5619 } 5620 }, 50); 5621 } 5622 } 5623 function performSearch() { 5624 if (!searchTerm) return; 5625 $button.prop("disabled", true); 5626 $searchTermDisplay.text(searchTerm); 5627 currentPage = 1; 5628 isLoadingAll = false; 5629 fetchResults(currentPage).done(onSearchSuccess).fail(onSearchError).always(onSearchComplete); 5630 trackKeyword(searchTerm); 5631 } 5632 function loadAllPages($link) { 5633 // Make it resilient if term not in state (eg. re-render) 5634 if (!searchTerm) { 5635 searchTerm = ($input.val() || "").trim(); 5636 } 5637 if (!searchTerm && $link && $link.length) { 5638 try { 5639 var linkUrl = new URL($link.attr("href"), window.location.href); 5640 searchTerm = (linkUrl.searchParams.get("s") || "").trim(); 5641 } catch (err) {} 5642 } 5643 if (!searchTerm) return; 5644 if (totalPages <= 1) return; 5645 if (isLoadingAll) return; 5646 isLoadingAll = true; 5647 if ($link && $link.length) { 5648 $link.addClass("ha_advanced_search_is_loading").attr("aria-disabled", "true"); 5649 } 5650 var _loadNext = function loadNext() { 5651 var nextPage = currentPage + 1; 5652 if (nextPage > totalPages) { 5653 isLoadingAll = false;
5654 if ($link && $link.length) { 5655 $link.removeClass("ha_advanced_search_is_loading").removeAttr("aria-disabled"); 5656 } 5657 updateViewAllVisibility(); 5658 return; 5659 } 5660 fetchResults(nextPage).done(function (response) { 5661 if (response && response.success && response.data && Array.isArray(response.data.results)) { 5662 response.data.results.forEach(function (result) { 5663 renderResultItem(result); 5664 }); 5665 if (isLayout4) { 5666 updateLayout4ResultCount($resultsList.find(".ha_advanced_search_result_item").length); 5667 } 5668 if (typeof response.data.pages !== "undefined") { 5669 totalPages = parseInt(response.data.pages, 10) || totalPages; 5670 } 5671 } 5672 }).always(function () { 5673 currentPage = nextPage; 5674 _loadNext(); 5675 }); 5676 }; 5677 _loadNext(); 5678 } 5679 function setJustCleared() { 5680 justCleared = true; 5681 if (justClearedTimer) clearTimeout(justClearedTimer); 5682 justClearedTimer = setTimeout(function () { 5683 justCleared = false; 5684 }, 300); 5685 } 5686 5687 // ------------------------ 5688 // Input handlers 5689 // ------------------------ 5690 $input.on("input" + ns, function (e) { 5691 searchTerm = $(e.currentTarget).val().trim(); 5692 if (searchTerm.length > 0) { 5693 if (isLayout4) { 5694 $clearButtonL4.addClass("ha_advanced_search_visible is-visible").css("display", "flex"); 5695 } else { 5696 $clearButton.show(); 5697 } 5698 } else { 5699 if (isLayout4) { 5700 $clearButtonL4.removeClass("ha_advanced_search_visible is-visible").hide(); 5701 updateLayout4ResultCount(0); 5702 } else { 5703 $clearButton.hide(); 5704 } 5705 } 5706 if (searchTimeout) clearTimeout(searchTimeout); 5707 if (isLayout4) { 5708 $layout4InputHolder.toggleClass("has-value", searchTerm.length > 0); 5709 } 5710 searchTimeout = setTimeout(function () { 5711 if (searchTerm.length >= 2) performSearch();else resetResultsUI(); 5712 }, 300); 5713 }); 5714 $input.on("keypress" + ns, function (e) { 5715 if (e.which === 13) { 5716 e.preventDefault(); 5717 // Layout 1/2: use the same redirect flow as search button click. 5718 if (!isLayout3 && !isLayout4) { 5719 $scope.find(".ha_advanced_search_search_button").first().trigger("click"); 5720 return; 5721 } 5722 // Layout 3/4: keep instant/AJAX behavior. 5723 performSearch(); 5724 } 5725 }); 5726 5727 // ------------------------ 5728 // Layout 3 open/close 5729 // ------------------------ 5730 if (isLayout3) { 5731 $layout3Trigger.on("click" + ns, function (e) { 5732 if (Date.now() - layout3ClosedAt < 250) return; 5733 e.preventDefault(); 5734 e.stopPropagation(); 5735 openLayout3Search(); 5736 console.log("trigger 3 clicked"); 5737 }); 5738 $layout3InitialInput.on("focus" + ns + " click" + ns, function (e) { 5739 if (Date.now() - layout3ClosedAt < 250) return; 5740 e.preventDefault(); 5741 e.stopPropagation(); 5742 openLayout3Search(); 5743 }); 5744 $layout3Close.on("click" + ns, function (e) { 5745 e.preventDefault(); 5746 e.stopPropagation(); 5747 layout3ClosedAt = Date.now(); 5748 closeLayout3Search(); 5749 hideResults(); 5750 if (document.activeElement) $(document.activeElement).trigger("blur"); 5751 }); 5752 $layout3Curtain.on("click" + ns, function () { 5753 // If you keep curtain clickable, keep this. 5754 // If you later set curtain pointer-events:none in CSS, this wonât fire (which is OK). 5755 layout3ClosedAt = Date.now(); 5756 closeLayout3Search(); 5757 hideResults(); 5758 }); 5759 $input.on("focus" + ns, function () { 5760 if (Date.now() - layout3ClosedAt < 250) return; 5761 openLayout3Search(); 5762 }); 5763 if (!searchTerm || searchTerm.length < 2) { 5764 showLayout3Popular(); 5765 } 5766 $(document).on("keydown" + ns, function (e) { 5767 if (e.key === "Escape" || e.keyCode === 27) { 5768 layout3ClosedAt = Date.now(); 5769 closeLayout3Search(); 5770 hideResults(); 5771 hideDateRange(); 5772 } 5773 }); 5774 5775 // ------------------------ 5776 // Layout-3 category select protection (native dropdown) 5777 // ------------------------ 5778 $categorySelect.off("pointerdown" + ns + " mousedown" + ns + " touchstart" + ns + " focus" + ns + " click" + ns).on("pointerdown" + ns + " mousedown" + ns + " touchstart" + ns + " focus" + ns + " click" + ns, function (e) { 5779 suppressLayout3Close(1200); 5780 e.stopPropagation(); 5781 }); 5782 $categorySelect.off("blur" + ns).on("blur" + ns, function () { 5783 suppressLayout3Close(250); 5784 }); 5785 $scope.find(".ha_advanced_search_search-category-container").off("pointerdown" + ns + " mousedown" + ns + " click" + ns).on("pointerdown" + ns + " mousedown" + ns + " click" + ns, function (e) { 5786 suppressLayout3Close(1200); 5787 e.stopPropagation(); 5788 }); 5789 } 5790 if (isLayout4) { 5791 $layout4Trigger.on("click" + ns, function (e) { 5792 e.preventDefault(); 5793 e.stopPropagation(); 5794 openLayout4Search(); 5795 }); 5796 $layout4InitialInput.on("focus" + ns + " click" + ns, function (e) { 5797 e.preventDefault(); 5798 e.stopPropagation(); 5799 openLayout4Search(); 5800 }); 5801 $layout4Close.on("click" + ns, function (e) { 5802 e.preventDefault(); 5803 e.stopPropagation(); 5804 closeLayout4Search(); 5805 hideResults(); 5806 }); 5807 $(document).on("keydown" + ns, function (e) { 5808 if (e.key === "Escape" || e.keyCode === 27) { 5809 closeLayout4Search(); 5810 hideResults(); 5811 } 5812 }); 5813 } 5814 5815 // ------------------------ 5816 // Clear button (pointerdown) 5817 // ------------------------ 5818 var clearEvt = window.PointerEvent ? "pointerdown" : "mousedown touchstart"; 5819 var clearEvtNs = clearEvt.split(" ").map(function (ev) { 5820 return ev + ns; 5821 }).join(" "); 5822 function handleClearButton($btn) { 5823 var isLayout4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5824 $btn.off(clearEvtNs).on(clearEvtNs, function (e) { 5825 e.preventDefault(); 5826 e.stopPropagation(); 5827 e.stopImmediatePropagation(); 5828 setJustCleared(); 5829 5830 // search 5831 $input.val(""); 5832 searchTerm = ""; 5833 5834 // paging 5835 currentPage = 1; 5836 totalPages = 1; 5837 isLoadingAll = false; 5838 5839 // category/page/tag 5840 selectedCategory = ""; 5841 selectedTag = ""; 5842 selectedPageId = ""; 5843 if ($categorySelect.length) $categorySelect.val("all"); 5844 if ($tagSelect && $tagSelect.length) $tagSelect.val("all"); 5845 5846 // date 5847 dateMode = "all"; 5848 dateFromVal = ""; 5849 dateToVal = ""; 5850 if ($dateSelect.length) $dateSelect.val("all"); 5851 hideDateRange(); 5852 if ($dateFrom.length) $dateFrom.val(""); 5853 if ($dateTo.length) $dateTo.val(""); 5854 5855 // UI 5856 resetResultsUI(); 5857 if (isLayout4) { 5858 $btn.removeClass("ha_advanced_search_visible is-visible").hide(); 5859 updateLayout4ResultCount(0); 5860 } else { 5861 $btn.hide(); 5862 } 5863 }); 5864 } 5865 5866 // Bind both buttons 5867 handleClearButton($clearButton, false); 5868 handleClearButton($clearButtonL4, true); 5869 5870 // ------------------------ 5871 // Category/Page dropdown 5872 // ------------------------ 5873 $categorySelect.on("change" + ns, function (e) { 5874 var val = $(e.currentTarget).val() || "all"; 5875 selectedCategory = ""; 5876 selectedPageId = ""; 5877 if (val === "all") { 5878 // none 5879 } else if (val.indexOf("cat:") === 0) { 5880 selectedCategory = val.replace("cat:", ""); 5881 } else if (val.indexOf("page:") === 0) { 5882 selectedPageId = val.replace("page:", ""); 5883 if (!pageHasTags) { 5884 selectedTag = ""; 5885 if ($tagSelect.length) $tagSelect.val("all"); 5886 } 5887 } 5888 searchIfReady(); 5889 }); 5890 5891 // ------------------------ 5892 // Tag dropdown 5893 // ------------------------ 5894 $tagSelect.on("change" + ns, function () { 5895 var val = $(this).val() || "all"; 5896 selectedTag = val !== "all" ? val : ""; 5897 searchIfReady(); 5898 }); 5899 5900 // ------------------------ 5901 // Popular keyword click 5902 // ------------------------ 5903 $popularKeywords.on("click" + ns, function (e) { 5904 e.preventDefault(); 5905 var keyword = $(e.currentTarget).attr("data-keyword") || $(e.currentTarget).text().trim(); 5906 if (!keyword) return; 5907 $input.val(keyword); 5908 searchTerm = keyword; 5909 $clearButton.show(); 5910 searchIfReady(); 5911 }); 5912 5913 // ------------------------ 5914 // Focus behavior (non layout-3) 5915 // ------------------------ 5916 $input.on("focusin" + ns, function () { 5917 if (isLayout3) return; 5918 if (justCleared) return; 5919 if ($dateRangeWrap.length && $dateRangeWrap.is(":visible")) return; 5920 if (searchTerm && searchTerm.length >= 2 && $resultsList.children().length > 0) { 5921 showResults(); 5922 } 5923 }); 5924 5925 // ------------------------ 5926 // View all (load all results instead of navigation) 5927 // ------------------------ 5928 $scope.on("click" + ns, ".ha_advanced_search_view_all_link", function (e) { 5929 if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return; 5930 e.preventDefault(); 5931 console.log("View all clicked - loading all pages"); 5932 loadAllPages($(this)); 5933 }); 5934 5935 // layout-3: pointerdown is more reliable than click 5936 // $scope 5937 // .off("pointerdown" + ns, ".ha_advanced_search_view_all_link") 5938 // .on("pointerdown" + ns, ".ha_advanced_search_view_all_link", function (e) { 5939 // if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) 5940 // return; 5941 5942 // e.preventDefault(); 5943 // e.stopPropagation(); 5944 // e.stopImmediatePropagation(); 5945 // console.log("View all clicked - loading all pages pointerdown"); 5946 // loadAllPages($(this)); 5947 // }); 5948 5949 if (isLayout2) { 5950 $resultsContainer.on("click" + ns, ".ha_advanced_search_result-item", function () { 5951 var url = $(this).attr("data-url"); 5952 var target = $(this).attr("data-target") || "_self"; 5953 if (!url) return; 5954 if (target === "_blank") window.open(url, "_blank");else window.location.href = url; 5955 }); 5956 } 5957 5958 // ------------------------ 5959 // Date select behavior 5960 // ------------------------ 5961 function isCustomDateReady() { 5962 return dateMode !== "custom" || dateFromVal && dateToVal; 5963 } 5964 if (showDateFilter) { 5965 $dateSelect.off("change" + ns).on("change" + ns, function () { 5966 dateMode = $(this).val() || "all"; 5967 hideResults(); 5968 if (dateMode === "custom") { 5969 dateFromVal = ""; 5970 dateToVal = ""; 5971 if ($dateFrom.length) $dateFrom.val(""); 5972 if ($dateTo.length) $dateTo.val(""); 5973 showDateRange(); 5974 return; 5975 } 5976 hideDateRange(); 5977 dateFromVal = ""; 5978 dateToVal = ""; 5979 if ($dateFrom.length) $dateFrom.val(""); 5980 if ($dateTo.length) $dateTo.val(""); 5981 searchIfReady(); 5982 }); 5983 $dateFrom.off("change" + ns).on("change" + ns, function () { 5984 dateFromVal = $(this).val() || ""; 5985 if (dateMode === "custom") { 5986 hideResults(); 5987 if (isCustomDateReady()) { 5988 hideDateRange(); 5989 searchIfReady(); 5990 } 5991 return; 5992 } 5993 searchIfReady(); 5994 });
5995 $dateTo.off("change" + ns).on("change" + ns, function () { 5996 dateToVal = $(this).val() || ""; 5997 if (dateMode === "custom") { 5998 hideResults(); 5999 if (isCustomDateReady()) { 6000 hideDateRange(); 6001 searchIfReady(); 6002 } 6003 return; 6004 } 6005 searchIfReady(); 6006 }); 6007 $dateSelect.off("click" + ns + " focus" + ns).on("click" + ns + " focus" + ns, function (e) { 6008 e.stopPropagation(); 6009 var v = $(this).val() || "all"; 6010 if (v === "custom") showDateRange(); 6011 }); 6012 $dateRangeWrap.on("click" + ns, function (e) { 6013 e.stopPropagation(); 6014 }); 6015 $dateSelect.on("click" + ns, function (e) { 6016 e.stopPropagation(); 6017 }); 6018 } 6019 6020 // â Close date range on outside click (pointerdown) 6021 $(document).off("pointerdown" + ns + ".dateRange").on("pointerdown" + ns + ".dateRange", function (e) { 6022 var $t = $(e.target); 6023 6024 // layout-3: don't close anything during native select open 6025 //if (isLayout3 && isLayout3CloseSuppressed()) return; 6026 6027 var insideDateUi = $t.closest("#" + widgetId).length && ($t.closest($dateRangeWrap).length || $t.closest($dateSelect).length || $t.closest(".ha_advanced_search_date_input_wrap").length || $t.closest(".ha_advanced_search_date_icon").length || $t.is(".ha_advanced_search_date_from, .ha_advanced_search_date_to")); 6028 var insideWidget = $t.closest("#" + widgetId).length; 6029 if (insideWidget && !insideDateUi && $dateRangeWrap.is(":visible")) { 6030 hideDateRange(); 6031 } 6032 }); 6033 6034 // ------------------------ 6035 // Results close on outside click 6036 // ------------------------ 6037 $(document).on("click" + ns, function (e) { 6038 var $t = $(e.target); 6039 if (isLayout3) { 6040 // If select is opening/open, do nothing (prevents instant-close of native dropdown) 6041 //if (isLayout3CloseSuppressed()) return; 6042 // If clicking inside the active layout-3 UI, do NOT close 6043 if ($t.closest("#" + widgetId + " .ha_advanced_search_search-container").length || $t.closest("#" + widgetId + " .ha_advanced_search_results_container").length || $t.closest("#" + widgetId + " .ha_advanced_search_results_footer").length || $t.closest("#" + widgetId + " .ha_advanced_search_search-category-container").length || $t.is(".ha_advanced_search_category_select, .ha_advanced_search_search-category-select") || $categorySelect.length && document.activeElement === $categorySelect[0]) { 6044 return; 6045 } 6046 6047 // Only close when clicking truly outside this widget 6048 if (!$t.closest("#" + widgetId).length) { 6049 layout3ClosedAt = Date.now(); 6050 closeLayout3Search(); 6051 hideResults(); 6052 hideDateRange(); 6053 } 6054 return; 6055 } 6056 if (!$t.closest("#" + widgetId).length) { 6057 if (isLayout4) { 6058 closeLayout4Search(); 6059 } 6060 hideResults(); 6061 hideDateRange(); 6062 } 6063 }); 6064 6065 // ------------------------ 6066 // showPicker (best-effort) 6067 // ------------------------ 6068 $dateFrom.on("pointerdown" + ns, function () { 6069 if (this.showPicker) { 6070 try { 6071 this.showPicker(); 6072 } catch (e) {} 6073 } 6074 }); 6075 $dateTo.on("pointerdown" + ns, function () { 6076 if (this.showPicker) { 6077 try { 6078 this.showPicker(); 6079 } catch (e) {} 6080 } 6081 }); 6082 $dateIcons.on("pointerdown" + ns, function (e) { 6083 e.preventDefault(); 6084 e.stopPropagation(); 6085 var $inp = $(this).siblings("input")[0]; 6086 if (!$inp) return; 6087 $inp.focus(); 6088 if ($inp.showPicker) { 6089 try { 6090 $inp.showPicker(); 6091 } catch (err) {} 6092 } else { 6093 $inp.click(); 6094 } 6095 }); 6096 $(document).off("click" + ns, "#" + widgetId + " .ha_advanced_search_search_button").on("click" + ns, "#" + widgetId + " .ha_advanced_search_search_button", function (e) { 6097 e.preventDefault(); 6098 var $widget = $(this).closest(".ha-advanced-search-advanced-search-wrap"); 6099 var s = ($widget.find(".ha_advanced_search_search_input").val() || "").trim(); 6100 var emptySearchText = $widget.data("empty-search-text") || "Please enter a search term"; 6101 if (!s) { 6102 $widget.find(".ha_advanced_search_search_input").focus().addClass("ha_advanced_search_input_error"); 6103 showButtonTooltip($widget.find(".ha_advanced_search_search_button"), emptySearchText); 6104 return; 6105 } 6106 var rawCategory = $widget.find(".ha_advanced_search_category_select").val() || "all"; 6107 var pageId = ""; 6108 if (rawCategory.indexOf("page:") === 0) { 6109 pageId = rawCategory.replace("page:", ""); 6110 } 6111 var date_mode = $widget.find(".ha_advanced_search_date_select").val() || "all"; 6112 var date_from = ""; 6113 var date_to = ""; 6114 if (date_mode === "custom") { 6115 date_from = $widget.find(".ha_advanced_search_date_from").val() || ""; 6116 date_to = $widget.find(".ha_advanced_search_date_to").val() || ""; 6117 } 6118 var post_types = $widget.data("post-types") || ["post", "page"]; 6119 if (!Array.isArray(post_types)) { 6120 try { 6121 post_types = JSON.parse(post_types); 6122 } catch (err) { 6123 post_types = ["post", "page"]; 6124 } 6125 } 6126 var initialResultsCount = parseInt($widget.data("initial-results-count"), 10) || 6; 6127 // var resultTemplateId = 6128 // $widget.data("result-template-id") || ""; 6129 6130 var params = []; 6131 params.push("s=" + encodeURIComponent(s)); 6132 params.push("advs=" + encodeURIComponent(s)); 6133 params.push("post_type=" + post_types.map(function (pt) { 6134 return encodeURIComponent(pt); 6135 }).join(",")); 6136 params.push("initial_results_count=" + encodeURIComponent(initialResultsCount)); 6137 // Backward-compat with older custom handlers. 6138 params.push("per_page=" + encodeURIComponent(initialResultsCount)); 6139 if (rawCategory && rawCategory !== "all") { 6140 params.push("category=" + encodeURIComponent(rawCategory)); 6141 } 6142 if (pageId) { 6143 params.push("page_id=" + encodeURIComponent(pageId)); 6144 } 6145 if (date_mode) { 6146 params.push("date_mode=" + encodeURIComponent(date_mode)); 6147 } 6148 if (date_from) { 6149 params.push("date_from=" + encodeURIComponent(date_from)); 6150 } 6151 if (date_to) { 6152 params.push("date_to=" + encodeURIComponent(date_to)); 6153 } 6154 // if (resultTemplateId) { 6155 // params.push( 6156 // "result_template_id=" + 6157 // encodeURIComponent(resultTemplateId), 6158 // ); 6159 // } 6160 6161 var siteBase = "/"; 6162 if (typeof HappyProLocalize !== "undefined" && HappyProLocalize.ajax_url) { 6163 siteBase = HappyProLocalize.ajax_url.replace(/\/wp-admin\/admin-ajax\.php.*$/, "/"); 6164 } 6165 var url = siteBase + "?" + params.join("&"); 6166 //window.location.href = url; 6167 window.open(url, "_blank"); 6168 }); 6169 function showButtonTooltip($button, text) { 6170 // Remove existing tooltip 6171 $button.find(".ha_advanced_search_btn_tooltip").remove(); 6172 var tooltip = $('<span class="ha_advanced_search_btn_tooltip">
6172' + text + "</span>"); 6173 $button.append(tooltip); 6174 6175 // Trigger animation 6176 setTimeout(function () { 6177 tooltip.addClass("ha_advanced_search_show_tooltip"); 6178 }, 10); 6179 6180 // Auto remove after 2.5s 6181 setTimeout(function () { 6182 tooltip.removeClass("ha_advanced_search_show_tooltip"); 6183 setTimeout(function () { 6184 tooltip.remove(); 6185 }, 200); 6186 }, 2500); 6187 } 6188 }; 6189 elementorFrontend.hooks.addAction("frontend/element_ready/ha-advanced-search.default", AdvancedSearchWidget); 6190 }); 6191})(jQuery, Happy, window);
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.