1/** 2 * File fronend-pro.js 3 * 4 * Handles toggling the navigation menu for Addon widget 5 * 6 * @package astra-addon 7 */ 8 9/** 10 * Canonical mobile menu state setter. 11 * 12 * Applies open/closed state to every mobile header on the page 13 * (original #masthead + sticky clone #ast-fixed-header), keeping the 14 * burger, nav container, and body class in lockstep. 15 * 16 * @since x.x.x 17 * @param {boolean} isOpen Desired open state. 18 */ 19astraSyncMobileMenuState = function( isOpen ) { 20 var containers = document.querySelectorAll( '#masthead #ast-mobile-header, #ast-fixed-header #ast-mobile-header' ); 21 for ( var i = 0; i < containers.length; i++ ) { 22 var nav = containers[i].querySelector( '.main-header-bar-navigation' ); 23 var btn = containers[i].querySelector( '.main-header-menu-toggle' ); 24 if ( nav ) { 25 nav.classList.toggle( 'toggle-on', isOpen ); 26 nav.style.display = isOpen ? 'block' : ''; 27 } 28 if ( btn ) { 29 btn.classList.toggle( 'toggled', isOpen ); 30 btn.setAttribute( 'aria-expanded', isOpen ? 'true' : 'false' ); 31 } 32 } 33 document.body.classList.toggle( 'ast-main-header-nav-open', isOpen ); 34}; 35 36astraToggleSetupPro = function( mobileHeaderType, body, menu_click_listeners ) { 37 38 var flag = false; 39 var menuToggleAllLength; 40 41 if ( 'off-canvas' === mobileHeaderType || 'full-width' === mobileHeaderType ) { 42 // comma separated selector added, if menu is outside of Off-Canvas then submenu is not clickable, it work only for Off-Canvas area with dropdown style. 43 var __main_header_all = document.querySelectorAll( '#ast-mobile-popup, #ast-mobile-header' ); 44 if ( body.classList.contains('ast-header-break-point') ) { 45 46 var menu_toggle_all = document.querySelectorAll( '#ast-mobile-header .main-header-menu-toggle' ); 47 } else { 48 menu_toggle_all = document.querySelectorAll( '#ast-desktop-header .main-header-menu-toggle' ); 49 } 50 menuToggleAllLength = menu_toggle_all.length; 51 } else { 52 53 if ( body.classList.contains('ast-header-break-point') ) { 54 55 var __main_header_all = document.querySelectorAll( '#ast-mobile-header' ), 56 menu_toggle_all = document.querySelectorAll( '#ast-mobile-header .main-header-menu-toggle' ); 57 menuToggleAllLength = menu_toggle_all.length; 58 flag = menuToggleAllLength > 0 ? false : true; 59 menuToggleAllLength = flag ? 1 : menuToggleAllLength; 60 } else { 61 62 var __main_header_all = document.querySelectorAll( '#ast-desktop-header' ), 63 menu_toggle_all = document.querySelectorAll('#ast-desktop-header .main-header-menu-toggle'); 64 menuToggleAllLength = menu_toggle_all.length; 65 } 66 } 67 68 if ( menuToggleAllLength > 0 || flag ) { 69 70 for (var i = 0; i < menuToggleAllLength; i++) { 71 72 if ( !flag ) { 73 menu_toggle_all[i].setAttribute('data-index', i); 74 75 if (!menu_click_listeners[i]) { 76 menu_click_listeners[i] = menu_toggle_all[i]; 77 menu_toggle_all[i].removeEventListener('click', astraNavMenuToggle); 78 menu_toggle_all[i].addEventListener('click', astraNavMenuToggle, false); 79 } 80 } 81 82 if ('undefined' !== typeof __main_header_all[i]) { 83 84 // To handle the comma seprated selector added above we need this loop. 85 for( var mainHeaderCount =0; mainHeaderCount < __main_header_all.length; mainHeaderCount++ ){ 86 87 if (document.querySelector('header.site-header').classList.contains('ast-builder-menu-toggle-link')) { 88 var astra_menu_toggle = __main_header_all[mainHeaderCount].querySelectorAll('ul.main-header-menu .menu-item-has-children > .menu-link, ul.main-header-menu .ast-menu-toggle'); 89 } else { 90 var astra_menu_toggle = __main_header_all[mainHeaderCount].querySelectorAll('ul.main-header-menu .ast-menu-toggle'); 91 } 92 // Add Eventlisteners for Submenu. 93 if (astra_menu_toggle.length > 0) { 94 95 for (var j = 0; j < astra_menu_toggle.length; j++) { 96 astra_menu_toggle[j].removeEventListener('click', AstraToggleSubMenu); 97 astra_menu_toggle[j].addEventListener('click', AstraToggleSubMenu, false); 98 } 99 } 100 } 101 } 102 } 103 } 104} 105 106astraNavMenuTogglePro = function ( event, body, mobileHeaderType, thisObj ) { 107 108 event.preventDefault(); 109 110 var desktop_header = event.target.closest('#ast-desktop-header'); 111 112 var desktop_header_content = document.querySelector('#masthead > #ast-desktop-header .ast-desktop-header-content'); 113 114 if ( null !== desktop_header && undefined !== desktop_header && '' !== desktop_header ) { 115 116 var desktop_toggle = desktop_header.querySelector( '.main-header-menu-toggle' ); 117 } else { 118 var desktop_toggle = document.querySelector('#masthead > #ast-desktop-header .main-header-menu-toggle'); 119 } 120 121 var desktop_menu = document.querySelector('#masthead > #ast-desktop-header .ast-desktop-header-content .main-header-bar-navigation'); 122 123 if ( 'desktop' === event.currentTarget.trigger_type ) { 124 125 if ( null !== desktop_menu && '' !== desktop_menu && undefined !== desktop_menu ) { 126 astraToggleClass(desktop_menu, 'toggle-on'); 127 if (desktop_menu.classList.contains('toggle-on')) { 128 desktop_menu.style.display = 'block'; 129 } else { 130 desktop_menu.style.display = ''; 131 } 132 } 133 astraToggleClass(desktop_toggle, 'toggled'); 134 if ( desktop_toggle.classList.contains( 'toggled' ) ) { 135 body.classList.add("ast-main-header-nav-open"); 136 if ( 'dropdown' === mobileHeaderType ) { 137 desktop_header_content.style.display = 'block'; 138 } 139 } else { 140 body.classList.remove("ast-main-header-nav-open"); 141 desktop_header_content.style.display = 'none'; 142 } 143 return; 144 } 145
146 // Collapse expanded submenus on the clicked header before toggling open/closed. 147 var clickedHeader = thisObj.closest( '#ast-fixed-header' ) || document.getElementById( 'masthead' ); 148 if ( clickedHeader ) { 149 var menuHasChildren = clickedHeader.querySelectorAll( '#ast-mobile-header .main-header-bar-navigation .menu-item-has-children' ); 150 for ( var i = 0; i < menuHasChildren.length; i++ ) { 151 menuHasChildren[i].classList.remove( 'ast-submenu-expanded' ); 152 var subMenus = menuHasChildren[i].querySelectorAll( '.sub-menu' ); 153 for ( var j = 0; j < subMenus.length; j++ ) { 154 subMenus[j].style.display = 'none'; 155 } 156 } 157 } 158 159 var menu_class = thisObj.getAttribute( 'class' ) || ''; 160 if ( menu_class.indexOf( 'main-header-menu-toggle' ) !== -1 ) { 161 // Flip state based on clicked button's current state, then sync across all mobile headers. 162 var nextOpen = ! thisObj.classList.contains( 'toggled' ); 163 astraSyncMobileMenuState( nextOpen ); 164 } 165} 166 167const accountMenuToggle = function () { 168 const checkAccountActionTypeCondition = astraAddon.hf_account_action_type && 'menu' === astraAddon.hf_account_action_type; 169 const accountMenuClickCondition = checkAccountActionTypeCondition && astraAddon.hf_account_show_menu_on && 'click' === astraAddon.hf_account_show_menu_on; 170 171 const headerAccountContainer = document.querySelectorAll('.ast-header-account-wrap'); 172 173 if( headerAccountContainer ) { 174 175 headerAccountContainer.forEach(element => { 176 177 const accountMenu = element.querySelector('.ast-account-nav-menu'); 178 179 const handlePointerUp = function( e ) { 180 const condition = ( accountMenuClickCondition ) || ( checkAccountActionTypeCondition && document.querySelector('body').classList.contains('ast-header-break-point')); 181 if( condition ) { 182 // if the target of the click isn't the container nor a descendant of the container 183 if ( accountMenu && !element.contains( e.target ) ) { 184 accountMenu.style.right = ''; 185 accountMenu.style.left = ''; 186 } 187 } 188 }; 189 190 // Attach pointerup event listener only once. 191 if ( ! element._accountPointerUpHandler ) { 192 element._accountPointerUpHandler = handlePointerUp; 193 document.addEventListener('pointerup', handlePointerUp); 194 } 195 196 const headerAccountTrigger = element.querySelector( '.ast-header-account-link' ); 197 if( headerAccountTrigger ) { 198 const handleAccountClick = function( e ) { 199 const condition = ( accountMenuClickCondition ) || ( checkAccountActionTypeCondition && document.querySelector('body').classList.contains('ast-header-break-point')); 200 if( condition ) { 201 202 headerSelectionPosition = e.target.closest('.site-header-section'); 203 204 if( headerSelectionPosition ) { 205 if( headerSelectionPosition.classList.contains('site-header-section-left') ) { 206 accountMenu.style.left = accountMenu.style.left === '' ? '-100%' : ''; 207 accountMenu.style.right = accountMenu.style.right === '' ? 'auto' : ''; 208 } else { 209 accountMenu.style.right = accountMenu.style.right === '' ? '-100%' : ''; 210 accountMenu.style.left = accountMenu.style.left === '' ? 'auto' : ''; 211 } 212 } 213 } 214 }; 215 216 // Attach click event listener only once. 217 if ( ! headerAccountTrigger._accountClickHandler ) { 218 headerAccountTrigger._accountClickHandler = handleAccountClick; 219 headerAccountTrigger.addEventListener( 'click', handleAccountClick); 220 } 221 } 222 }); 223 } 224} 225 226/** 227 * Color Switcher. 228 * 229 * @since 4.10.0 230 */ 231const astraColorSwitcher = { 232 ...astraAddon?.colorSwitcher, // Spreading Color Switcher options. 233 234 /** 235 * Initializes the Color Switcher Widget. 236 */ 237 init: function () { 238 if ( ! this?.isInit ) { 239 return; 240 } 241 242 this.switcherButtons = document.querySelectorAll( '.ast-builder
242-color-switcher .ast-switcher-button' ); 243 244 if ( ! this.switcherButtons?.length ) { 245 return; 246 } 247 248 this.switcherButtons?.forEach( ( switcherButton ) => { 249 switcherButton?.addEventListener( 'click', this.toggle ); // â `this` refers to astraColorSwitcher 250 } ); 251 252 if ( this.isDarkPalette && this.defaultMode === 'system' ) { 253 // Detect system preference and apply mode accordingly. 254 this.detectSystemColorScheme(); 255 } 256 257 // Set initial logo state if switched 258 if ( this.isSwitched ) { 259 this.switchLogo(); 260 } 261 }, 262 263 /** 264 * Detects the system's color scheme preference and sets the theme accordingly. 265 */ 266 detectSystemColorScheme: function () { 267 const storedPreference = this.getCookie( 'astraColorSwitcherState' ); 268 269 // Bail early, if user has previously chosen a theme. 270 if ( storedPreference !== null ) { 271 return; 272 } 273 274 // Detect system preference. 275 const prefersDark = window.matchMedia( '(prefers-color-scheme: dark)' ).matches; 276 277 if ( prefersDark && ! this.isSwitched ) { 278 // Apply the detected or stored theme. 279 this.toggle(); 280 } 281 }, 282 283 /** 284 * Toggle the palette. 285 * 286 * @param {Event} e Button click event object. 287 */ 288 toggle: function ( e ) { 289 e?.preventDefault(); 290 const switcher = astraColorSwitcher; 291 292 // Toggle the state 293 switcher.isSwitched = ! switcher.isSwitched; 294 295 // Store state in cookie (expires in 90 days). 296 switcher.setCookie( 'astraColorSwitcherState', switcher.isSwitched, 90 ); 297 298 if ( switcher?.forceReload ) { 299 window.location.reload(); 300 return; 301 } 302 303 switcher.switchPaletteColors(); 304 switcher.switchIcon(); 305 switcher.switchLogo(); 306 307 if ( switcher.isDarkPalette ) { 308 switcher.handleDarkModeCompatibility(); 309 } 310 }, 311 312 /** 313 * Switch Palette Colors. 314 */ 315 switchPaletteColors: function () { 316 // Choose the correct palette based on `isSwitched` state. 317 const currentPalette = this.isSwitched ? this?.palettes?.switched : this?.palettes?.default; 318 319 // Apply the colors to CSS variables. 320 currentPalette?.forEach( ( color, index ) => { 321 document.documentElement.style.setProperty( `--ast-global-color-${ index }`, color ); 322 if ( astraAddon?.is_elementor_active ) { 323 document.documentElement.style.setProperty( `--e-global-color-astglobalcolor${ index }`, color ); 324 } 325 } ); 326 }, 327 328 /** 329 * Switch Icon. 330 */ 331 switchIcon: function () { 332 this.switcherButtons?.forEach( ( switcherButton ) => { 333 const [ defaultIcon, switchedIcon ] = switcherButton?.querySelectorAll( '.ast-switcher-icon' ); 334 335 // Avoid icon switching if there is none or only one. 336 if ( defaultIcon && switchedIcon ) { 337 const [ first, second ] = this.isSwitched ? [ switchedIcon, defaultIcon ] : [ defaultIcon, switchedIcon ]; 338 339 // Animate icon. 340 switcherButton?.classList.add( 'ast-animate' ); 341 342 setTimeout( () => { 343 first?.classList.add( 'ast-current' ); 344 second?.classList.remove( 'ast-current' ); 345 }, 100 ); 346 347 setTimeout( () => switcherButton?.classList.remove( 'ast-animate' ), 200 ); 348 } 349 350 /// Switch aria attribute. 351 const ariaLabelTextKey = this.isSwitched ? 'defaultText' : 'switchedText'; 352 switcherButton?.setAttribute( 353 'aria-label', 354 switcherButton?.dataset?.[ ariaLabelTextKey ] || 'Switch color palette.' 355 ); 356 } ); 357 }, 358 359 /** 360 * Switch Logo. 361 */ 362 switchLogo: function () { 363 // Handle color switcher logo switching 364 if ( this.isDarkPalette && this?.logos?.switched && this?.logos?.default ) { 365 this.switchColorSwitcherLogo(); 366 } 367 }, 368 369 /** 370 * Switch Color Switcher Logo. 371 * Handles logo switching for dark/light palette modes. 372 */ 373 switchColorSwitcherLogo: function () { 374 // Target only main logo, exclude sticky header and transparent header logos 375 const logoSelectors = [ 376 '.custom-logo-link:not(.sticky-custom-logo):not(.transparent-custom-logo) .custom-logo', // Main logo only 377 '.site-branding .site-logo-img img:not(.ast-sticky-header-logo)', // Main site logo, not sticky 378 '.ast-site-identity .site-logo-img img:not(.ast-sticky-header-logo)', // Alternative main logo structure 379 ]; 380 381 let logoImages = []; 382 383 // Try each selector to find main logo images only 384 for ( const selector of logoSelectors ) { 385 const foundImages = document.querySelectorAll( selector ); 386 if ( foundImages.length > 0 ) { 387 // Filter out sticky and transparent header logos if they somehow get selected 388 logoImages = Array.from( foundImages).filter( ( img ) => { 389 // Exclude if parent contains sticky header or transparent header classes 390 return ! img.closest( '.ast-sticky-header-logo' ) && 391 ! img.closest( '.sticky-custom-logo' ) && 392 ! img.closest( '.transparent-custom-logo' ) && 393 ! img.classList.contains( 'ast-sticky-header-logo' ); 394 } ); 395 396 if ( logoImages.length > 0 ) { 397 break; 398 } 399 } 400 } 401 402 if ( ! logoImages.length ) { 403 return; 404 } 405 406 // Determine which logo to show based on current state 407 const targetSrc = this.isSwitched ? this.logos.switched : this.logos.default; 408 409 if ( ! targetSrc ) { 410 return; 411 } 412 413 // Update each logo image 414 this.updateLogoImages( logoImages, targetSrc ); 415 }, 416 417 /** 418 * Update Logo Images. 419 */ 420 updateLogoImages: function ( logoImages, targetSrc ) {
421 logoImages.forEach( ( logoImg ) => { 422 if ( logoImg && logoImg.src !== targetSrc ) { 423 // Preload image for smoother switching 424 const newImg = new Image(); 425 newImg.onload = function() { 426 logoImg.src = targetSrc; 427 if ( logoImg.hasAttribute ( 'srcset' ) ) { 428 logoImg.removeAttribute( 'srcset' ); 429 } 430 if ( logoImg.hasAttribute( 'data-src' ) ) { 431 logoImg.setAttribute( 'data-src', targetSrc ); 432 } 433 }; 434 newImg.onerror = function() { 435 logoImg.src = targetSrc; // Try anyway 436 }; 437 newImg.src = targetSrc; 438 } 439 } ); 440 }, 441 442 /** 443 * Handle Dark Mode Compatibility. 444 */ 445 handleDarkModeCompatibility: function () { 446 // Add the dark mode class. 447 document.body.classList.toggle( 'astra-dark-mode-enable' ); 448 449 // Todo: Handle dark compatibility CSS. 450 }, 451 452 /** 453 * Helper function to set a cookie. 454 */ 455 setCookie: ( name, value, days ) => { 456 const expires = new Date(); 457 expires.setTime( expires.getTime() + days * 24 * 60 * 60 * 1000 ); 458 document.cookie = `${ name }=${ value }; expires=${ expires.toUTCString() }; path=/`; 459 }, 460 461 /** 462 * Helper function to get a cookie. 463 */ 464 getCookie: ( name ) => { 465 const cookies = document.cookie.split( '; ' ); 466 for ( let cookie of cookies ) { 467 const [ key, val ] = cookie.split( '=' ); 468 if ( key === name ) return val; 469 } 470 return null; 471 }, 472}; 473 474/** 475 * Account Login Popup Trigger 476 * 477 * Moved from theme's JS to addon to ensure the login popup JS always loads with the account component. 478 * Fixes cases where the JS was missing when the widget was added due to theme script loading order. 479 * 480 * @since 4.11.5 Moved from theme to addon 481 */ 482var accountPopupTrigger = function () { 483 if ( typeof astraAddon === 'undefined' || 'login' !== astraAddon.hf_account_logout_action ) { 484 return; 485 } 486 487 // Account login form popup. 488 var header_account_trigger = document.querySelectorAll( '.ast-account-action-login' ); 489 490 if (!header_account_trigger.length) { 491 return; 492 } 493 494 const formWrapper = document.querySelector('#ast-hb-account-login-wrap'); 495 496 if (!formWrapper) { 497 return; 498 } 499 500 const formCloseBtn = document.querySelector('#ast-hb-login-close'); 501 502 header_account_trigger.forEach(function(_trigger) { 503 _trigger.addEventListener('click', function(e) { 504 e.preventDefault(); 505 506 formWrapper.classList.add('show'); 507 }); 508 }); 509 510 if (formCloseBtn) { 511 formCloseBtn.addEventListener('click', function(e) { 512 e.preventDefault(); 513 formWrapper.classList.remove('show'); 514 }); 515 } 516}; 517 518document.addEventListener( 'astPartialContentRendered', function() { 519 accountMenuToggle(); 520 accountPopupTrigger(); 521}); 522 523window.addEventListener( 'load', function() { 524 accountMenuToggle(); 525 accountPopupTrigger(); 526 astraColorSwitcher.init(); 527} ); 528 529document.addEventListener( 'astLayoutWidthChanged', function() { 530 accountMenuToggle(); 531 accountPopupTrigger(); 532} ); 533 534// Close mobile menu across both headers when anchor links inside a mobile header are clicked. 535document.addEventListener( 'click', function( e ) { 536 var target = e.target.closest( 'a' ); 537 if ( ! target ) { 538 return; 539 } 540 var href = target.getAttribute( 'href' ); 541 if ( ! href || href.indexOf( '#' ) === -1 ) { 542 return; 543 } 544 if ( ! target.closest( '#masthead #ast-mobile-header, #ast-fixed-header #ast-mobile-header' ) ) { 545 return; 546 } 547 setTimeout( function() { 548 astraSyncMobileMenuState( false ); 549 }, 20 ); 550} ); 551/** 552 * Advanced Search Styling 553 * 554 * @package Astra Addon 555 * @since 1.4.8 556 */ 557 558( function() { 559 560 function body_iphone_classes() { 561 var iphone = ( navigator.userAgent.match(/iPhone/i) == 'iPhone' ) ? 'iphone' : ''; 562 var ipod = ( navigator.userAgent.match(/iPod/i) == 'iPod' ) ? 'ipod' : ''; 563 564 document.body.className += ' ' + iphone; 565 document.body.className += ' ' + ipod; 566 } 567 body_iphone_classes(); 568 569 function remove_style_class( style ) { 570 var allClasses = document.body.className; 571 allClasses = allClasses.replace( style, '' ); 572 document.body.className = allClasses; 573 } 574 575 function add_style_class( style ) { 576 document.body.className += ' ' + style; 577 } 578 579 // Helper Function. 580 function fade_in( element ) { 581 582 element.style.display = 'block'; 583 setTimeout(function() { 584 element.style.opacity = 1; 585 }, 1); 586 } 587 588 function fade_out( element ) { 589 590 element.style.opacity = ''; 591 setTimeout(function() { 592 element.style.display = ''; 593 }, 200); 594 } 595 596 function header_cover_form_height( current_header_cover_form ) { 597 598 // Primary header cover search. 599 if ( document.body.classList.contains('ast-header-break-point') ) { 600 601 var site_navigation = document.querySelector( '.main-navigation' ); 602 var main_header_bar = document.querySelector( '.main-header-bar' ); 603 604 if( null !== main_header_bar && null !== site_navigation ) { 605 606 var site_navigation_outer_height = site_navigation.offsetHeight; 607 var main_header_outer_height = main_header_bar.offsetHeight; 608 609 // Have a navigation outer height. 610 // And primary header NOT have the `No Toggle` style. 611 if( site_navigation_outer_height && ( ! document.body.classList.contains('ast-no-toggle-menu-enable') ) ) { 612 var search_height = parseFloat(site_navigation_outer_height) - parseFloat(main_header_outer_height); 613 } else { 614 var search_height = parseFloat(main_header_outer_height); 615 } 616 current_header_cover_form.style.maxHeight = Math.abs( search_height ) + "px"; 617 } 618 } 619 } 620 621 function header_builder_cover_form_height( current_header_cover_form ) { 622 623 // Primary header cover search. 624 if ( document.body.classList.contains('ast-header-break-point') ) { 625 626 var site_navigation = document.querySelector( '.main-navigation' ); 627 var main_header_bar = document.querySelector( '.main-header-bar' ); 628 var mobile_header_bar = document.querySelector( '.ast-mobile-header-wrap' ); 629 630 if( null !== main_header_bar && null !== site_navigation ) { 631 632 var site_navigation_outer_height = site_navigation.offsetHeight; 633 var main_header_outer_height = main_header_bar.offsetHeight; 634 var mobile_header_outer_height = mobile_header_bar.offsetHeight; 635 636 // Have a navigation outer height. 637 // And primary header NOT have the `No Toggle` style. 638 if( site_navigation_outer_height && ( ! document.body.classList.contains('ast-no-toggle-menu-enable') ) ) { 639 var search_height = parseFloat(site_navigation_outer_height) - parseFloat(main_header_outer_height); 640 } else { 641 var search_height = parseFloat(main_header_outer_height); 642 } 643 if ( current_header_cover_form.parentNode.classList.contains( 'ast-mobile-header-wrap' ) ) { 644 var search_height = parseFloat(mobile_header_outer_height); 645 } 646 647 current_header_cover_form.style.maxHeight = Math.abs( search_height ) + "px"; 648 } 649 } 650 } 651 652 var searchIcons = document.querySelectorAll( 'a.astra-search-icon:not(.slide-search)' ); 653 654 for ( var i = 0; searchIcons.length > i; i++ ) { 655 656 searchIcons[i].onclick = function ( evt ) { 657 658 evt.preventDefault(); 659 660 if ( ! evt ) { 661 evt = window.event; 662 } 663 664 if ( this.classList.contains( 'header-cover' ) ) { 665 var header_cover = document.querySelectorAll( '.ast-search-box.header-cover' ), 666 header_builder_active = astraAddon.is_header_builder_active || false; 667 668 for (var j = 0; j < header_cover.length; j++) { 669 670 var header_cover_icon = header_cover[j].parentNode.querySelectorAll( 'a.astra-search-icon' ); 671 672 for (var k = 0; k < header_cover_icon.length; k++) { 673 if ( header_cover_icon[k] == this ) { 674 fade_in( header_cover[j] ); 675 header_cover[j].querySelector( 'input.search-field' ).focus(); 676 677 // Set header cover form height. 678 if ( header_builder_active ) { 679 header_builder_cover_form_height( header_cover[j] ); 680 } else { 681 header_cover_form_height( header_cover[j] ); 682 } 683 } 684 }; 685 }; 686 687 } else if ( this.classList.contains( 'full-screen' ) ) { 688 689 var fullScreen = document.getElementById( 'ast-seach-full-screen-form' ); 690 if ( fullScreen.classList.contains( 'full-screen' ) ) { 691 fade_in( fullScreen ); 692 add_style_class( 'full-screen' ); 693 fullScreen.querySelector( 'input.search-field' ).focus(); 694 } 695 } 696 }; 697 }; 698 699 /* Search Header Cover & Full Screen Close */ 700 var closes = document.querySelectorAll( '.ast-search-box .close' ); 701 for (var i = 0, len = closes.length; i < len; ++i) { 702 closes[i].onclick = function(evt){ 703 704 if ( ! evt) { evt = window.event; 705 } 706 var self = this; 707 while ( 1 ) { 708 if ( self.parentNode.classList.contains( 'ast-search-box' ) ) { 709 fade_out( self.parentNode ); 710 remove_style_class( 'full-screen' ); 711 break; 712 } else if ( self.parentNode.classList.contains( 'site-header' ) ) { 713 break; 714 } 715 self = self.parentNode; 716 } 717 }; 718 } 719 720 document.onkeydown = function ( evt ) { 721 if ( evt.keyCode == 27 ) { 722 var fullScreenForm = document.getElementById( 'ast-seach-full-screen-form' ); 723 724 if ( null != fullScreenForm ) { 725 fade_out( fullScreenForm ); 726 remove_style_class( 'full-screen' ); 727 } 728 729 var header_cover = document.querySelectorAll( '.ast-search-box.header-cover' ); 730 for (var j = 0; j < header_cover.length; j++) { 731 fade_out( header_cover[j] ); 732 } 733 } 734 } 735 736 window.addEventListener("resize", function() { 737 738 if( 'BODY' !== document.activeElement.tagName ) { 739 return; 740 } 741 742 // Skip resize event when keyboard display event triggers on devices. 743 if( 'INPUT' != document.activeElement.tagName ) { 744 var header_cover = document.querySelectorAll( '.ast-search-box.header-cover' ); 745 if ( ! document.body.classList.contains( 'ast-header-break-point' ) ) { 746 for (var j = 0; j < header_cover.length; j++) { 747 header_cover[j].style.maxHeight = ''; 748 header_cover[j].style.opacity = ''; 749 header_cover[j].style.display = ''; 750 } 751 } 752 } 753 }); 754 755 let closeIcon = document.getElementById("close"); 756 if ( closeIcon ) { 757 closeIcon.addEventListener("keydown", function (event) { 758 if (event.key === "Enter") { 759 event.preventDefault(); 760 this.click(); 761 } else if (event.key === "Tab") { 762 event.preventDefault(); 763 } 764 }); 765 } 766 767} )();
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.