1jQuery( function( $ ) { 2 3 'use strict'; 4 5 function getStyle( el ) { 6 var display = window.getComputedStyle( el ).getPropertyValue("display"); 7 el.style.display = "none"; 8 var width = window.getComputedStyle( el ).getPropertyValue("width"); 9 el.style.display = display; 10 return width; 11 } 12 13 // Open search box when button clicked 14 $( document ).on( 'click', '.gp-search-button:not(.gp-active)', function() { 15 16 var searchButton = $( this ), 17 searchBoxWrapper = searchButton.next( '.gp-search-popup-box-wrapper' ); 18 19 searchButton.addClass( 'gp-active' ); 20 searchBoxWrapper.fadeIn(); 21 searchBoxWrapper.find( 'input[type="text"]' ).focus(); 22 23 // Set search box width 24 var popupBox = searchBoxWrapper.find( '.gp-search-popup-box' )[0], 25 widthIsPercent = getStyle( popupBox ).indexOf( "%" ) > -1; 26 if ( widthIsPercent ) { 27 var searchBoxWidth = searchBoxWrapper.closest( '.elementor-section' ).innerWidth(); 28 searchBoxWrapper.outerWidth( searchBoxWidth ); 29 $( window ).on( 'resize', function() { 30 searchBoxWidth = searchBoxWrapper.closest( '.elementor-section' ).innerWidth(); 31 searchBoxWrapper.outerWidth( searchBoxWidth ); 32 }); 33 } 34 35 // Make search popup box relative to page 36 if ( searchBoxWrapper.hasClass( 'gp-search-box-position-type-page' ) ) { 37 38 var val1 = ( $( 'body' ).width() - searchButton.closest( '.elementor-section' ).outerWidth() ) / 2; 39 var val2 = val1 + searchButton.closest( '.elementor-section' ).outerWidth(); 40 var pos = val2 - searchButton.offset().left - searchButton.outerWidth(); 41 42 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-center' ) ) { 43 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 44 } 45 46 if ( ! $( 'body' ).hasClass( 'rtl' ) ) { 47 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-right' ) ) { 48 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 49 } else if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-left' ) ) { 50 searchBoxWrapper.css( 'left', '-' + pos + 'px' ); 51 } 52 } else if ( $( 'body' ).hasClass( 'rtl' ) ) { 53 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-right' ) ) { 54 searchBoxWrapper.css( 'left', '-' + pos + 'px' ); 55 } else if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-left' ) ) { 56 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 57 } 58 } 59 60 $( window ).on( 'resize', function() { 61 val1 = ( $( 'body' ).width() - searchButton.closest( '.elementor-section' ).outerWidth() ) / 2; 62 val2 = val1 + searchButton.closest( '.elementor-section' ).outerWidth(); 63 pos = val2 - searchButton.offset().left - searchButton.outerWidth(); 64 65 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-center' ) ) { 66 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 67 } 68 69 if ( ! $( 'body' ).hasClass( 'rtl' ) ) { 70 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-right' ) ) { 71 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 72 } else if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-left' ) ) { 73 searchBoxWrapper.css( 'left', '-' + pos + 'px' ); 74 } 75 } else if ( $( 'body' ).hasClass( 'rtl' ) ) { 76 if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-right' ) ) { 77 searchBoxWrapper.css( 'left', '-' + pos + 'px' ); 78 } else if ( searchBoxWrapper.hasClass( 'gp-popup-box-align-left' ) ) { 79 searchBoxWrapper.css( 'right', '-' + pos + 'px' ); 80 } 81 } 82 83 }); 84 85 } 86 87 }); 88 89 // Close search box when button clicked 90 $( document ).on( 'click', '.gp-search-button.gp-active', function() { 91 var searchButton = $( this ); 92 searchButton.removeClass( 'gp-active' ); 93 searchButton.next( '.gp-search-popup-box-wrapper' ).fadeOut(); 94 }); 95 96 // Close search box when page clicked 97 $( document ).mouseup( function( e ) { 98 var container = $( '.gp-search-button, .gp-search-popup-box' ); 99 if ( ( ! container.is( e.target ) && container.has( e.target ).length === 0 ) && $( '.gp-search-button' ).hasClass( 'gp-active' ) ) { 100 $( '.gp-search-popup-box-wrapper' ).fadeOut(); 101 $( '.gp-search-button' ).removeClass( 'gp-active' ); 102 } 103 }); 104 105});
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.