1jQuery( function( $ ) { 2 3 var body = $( document.body ), 4 overlay = $( '.codevz-plus-dropdown-overlay .inner_layout > .cz_overlay' ); 5 6 let typingTimer; 7 8 // Header search custom category selection list. 9 body.on( 'click', '.codevz-search-category > strong', function() { 10 11 $( '.codevz-search-category > div' ).slideToggle( 'fast' ); 12 13 }).on( 'click', '.codevz-search-category li', function() { 14 15 var $this = $( this ), 16 caty = $( '.codevz-search-category' ); 17 18 $this.addClass( 'codevz-active' ); 19 caty.find( 'li' ).not( $this ).removeClass( 'codevz-active' ); 20 21 caty.find( '> div' ).slideUp( 'fast' ); 22 23 caty.find( '> strong span' ).html( $this.text() ); 24 25 caty.find( '> input' ).val( $this.attr( 'data-cat' ) ).trigger( 'change' ); 26 27 // Trending search. 28 }).on( 'click', '.codevz-search-trending a', function() { 29 30 $( '[name="s"]' ).val( $( this ).text() ).trigger( 'change' ).closest( 'form' ).submit(); 31 32 // Header search input AJAX. 33 }).on( 'keyup', '.cz_ajax_search [name="s"]', function( e, time ) { 34 35 var $this = $( this ), 36 value = $this.val(), 37 form = $this.parent(), 38 results = form.next( '.ajax_search_results' ), 39 icon = $( 'button i', form ), 40 org = 'fa ' + icon.data('xtra-icon'), 41 iLoader = 'fa fa-superpowers fa-pulse', 42 trending= $( '.codevz-search-trending' ); 43 44 // Prevent duplicate requests for the same input 45 if ( value === $this.data( 'codevz-prev-search' ) ) { 46 return; 47 } 48 49 // Save the last searched value 50 $this.data( 'codevz-prev-search', value ); 51 52 // Hide results if they are visible before sending new request 53 if ( results.is( ':visible' ) ) { 54 results.stop(true, true).slideUp('fast'); 55 } 56 57 // Check input length before sending request 58 if ( value.length < 3 ) { 59 overlay.fadeOut(); 60 icon.removeClass(iLoader).addClass(org); 61 trending.slideDown('fast'); 62 return; 63 } else { 64 icon.removeClass(org).addClass(iLoader); 65 } 66 67 trending.slideUp('fast'); 68 69 // Clear the previous timeout to debounce 70 clearTimeout(typingTimer); 71 72 // Start a new timeout sending AJAX. 73 typingTimer = setTimeout(function() { 74 75 var tempForm = form.clone(); 76 tempForm.find('input[type="hidden"]').prop('disabled', false); 77 78 $.ajax({ 79 type: "GET", 80 url: body.data('ajax') || ajaxurl, 81 dataType: 'html', 82 data: "action=codevz_ajax_search&" + tempForm.serialize(), 83 success: function(data) { 84 overlay.css( 'z-index', '99' ).fadeIn(); 85 trending.slideUp('fast'); 86 87 var $html = $( '<div>' + data + '</div>' ); 88 89 if ( value ) { 90 var regex = new RegExp( '(' + value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + ')', 'gi' ); 91 92 $html.find( 'h3 a' ).each( function() { 93 var title = $( this ).html(); 94 $( this ).html( title.replace( regex, '<strong class="ajax_search_results_hightlight">$1</strong>' ) ); 95 }); 96 } 97 98 results.html( $html.html() ).stop(true, true).slideDown('fast'); 99 icon.removeClass(iLoader).addClass(org); 100 101 results.append( '<style>.ajax_search_results_hightlight{position:relative;display:inline-block;padding:0}.ajax_search_results_hightlight:before{position:absolute;content:"";opacity:.3;bottom:1px;z-index:-1;height:6px;width:100%;transform:scale(1.1);box-sizing:border-box;border-radius:100px}</style>' ); 102 }, 103 error: function(xhr, status, error) { 104 overlay.css( 'z-index', '99' ).fadeIn(); 105 trending.slideUp('fast'); 106 results.html('<b class="ajax_search_error">' + error + '</b>').stop(true, true).slideDown('fast'); 107 icon.removeClass(iLoader).addClass(org); 108 console.log(xhr, status, error); 109 } 110 }); 111 112 }, 1500 ); // Wait until user stops typing 113 114 // Search icon 115 }).on( 'click', '.search_with_icon', function( e ) { 116 117 e.stopPropagation(); 118 119 }).on( 'click', '.search_with_icon [name="s"]', function() { 120 121 if ( $( this ).val() ) { 122 123 overlay.css( 'z-index', '99' ).fadeIn(); 124 125 if ( $( '.ajax_search_results .item_small' ).length ) { 126 $( '.ajax_search_results' ).slideDown( 'fast' ); 127 } 128 129 } 130 131 // Search dropdown. 132 }).on( 'click', '.search_style_icon_dropdown .xtra-search-icon', function() { 133 134 var x = $( this ), 135 outer = x.parent().find('.outer_search'), 136 row = x.closest('.row').parent(); 137 138 if ( outer.is( ':visible' ) ) { 139 row.css( 'z-index', '' ); 140 outer.fadeOut( 'fast' ); 141 overlay.fadeOut(); 142 } else { 143 row.css( 'z-index', '99' ); 144 outer.fadeIn( 'fast' ).find('input').trigger( 'focus' ); 145 overlay.css( 'z-index', '99' ).fadeIn(); 146 } 147 148 // Auto x-position search in header. 149 }).on( 'click mouseenter', '.search_style_icon_dropdown', function() { 150 151 var x = $( this ), 152 iconX = x.find( '.xtra-search-icon' ), 153 iconWidth = iconX.outerWidth(), 154 dropdown = x.find( '.outer_search' ); 155 156 if ( ( $( window ).width() / 2 ) > ( x.offset().left + 100 ) ) { 157 158 x.addClass( 'inview_right' ); 159 160 var iconMl = parseFloat( iconX.css( 'marginLeft' ) ); 161 162 if ( body.hasClass( 'rtl' ) ) { 163 dropdown.css( 'left', ( ( iconWidth / 2 ) - 38 + iconMl ) ); 164 } else { 165 dropdown.css( 'left', -( ( iconWidth / 2 ) - 36 + iconMl ) ); 166 } 167 168 } else { 169 170 dropdown.css( 'right', ( ( iconWidth / 2 ) - 36 + parseFloat( iconX.css( 'marginRight' ) ) ) ); 171 172 } 173 174 // Search fullscreen. 175 }).on( 'click', '.search_style_icon_full .xtra-search-icon', function( e ) { 176 177 var x = $( this ), 178 o = $( '.inner_layout > .cz_overlay' ), 179 s = x.parent().find( '.outer_search' ); 180 181 o.css( 'z-index', '99' ).fadeIn(); 182 s.fadeIn( 'fast' ).find( 'input' ).trigger( 'focus' ); 183 184 if ( $( '#wpadminbar' ).length ) { 185 s.css( 'marginTop', '32px' ); 186 } 187 188 x.parent().find( '.xtra-close-icon' ).toggleClass( 'hide' ).off().on( 'click', function( e ) { 189 $( this ).addClass( 'hide' ); 190 o.fadeOut(); 191 s.fadeOut( 'fast' ); 192 }); 193 194 }).on( 'click', '.cz_overlay', function( e ) { 195 196 $( this ).css( 'z-index', '' ).fadeOut(); 197 198 }).on( 'click', function( e ) { 199 200 if ( $( e.target ).closest( '.outer_search .search, .sub-menu, .cz_cart_items, .icon_mobile_offcanvas_menu, .xtra-fixed-mobile-nav' ).length ) { 201 return; 202 } 203 204 overlay.css( 'z-index', '' ).fadeOut(); 205 body.find( '.page_header > div' ).css( 'z-index', '' ); 206 body.find( '.ajax_search_results' ).fadeOut( 'fast' ); 207 body.find( '.search_style_icon_dropdown, .search_style_icon_full' ).find( '.outer_search' ).fadeOut( 'fast' ); 208 body.find( '.search_style_icon_full' ).find( '.xtra-close-icon' ).addClass( 'hide' ); 209 210 $( '.codevz-search-category >
210 div' ).slideUp( 'fast' ); 211 212 }); 213 214});
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.