1jQuery(document).ready(function($) { 2 "use strict"; 3 4 var searchform = $('header form.search-form'); 5 var searchinput = $('header form.search-form input[type="search"]'); 6 var searchbutton = $('header form.search-form button'); 7 var timeout; 8 9 $(document).on('keyup', 'header form.search-form input[type="search"]', function(event){ 10 event.preventDefault(); 11 12 if($(event.target).val().length < 3){ 13 return false; 14 } 15 16 if(timeout) { 17 clearTimeout(timeout); 18 } 19 timeout = setTimeout(function() { 20 var data = { 21 cache: false, 22 type: 'POST', 23 action: 'ajax_search', 24 beforeSend: function() { 25 $(searchbutton).append('<svg class="loader-image preloader" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg></div>'); 26 $(searchform).addClass('search-loading'); 27 }, 28 keyword: $(event.target).val(), 29 30 }; 31 32 // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 33 $.post(bacolasearch.ajaxurl, data, function(response) { 34 35 $(".klb-search-results").remove(); 36 $(searchinput).after('<div class="klb-search-results">' + response + '</div>'); 37 38 $(searchform).removeClass('search-loading'); 39 $(".loader-image").remove(); 40 41 }); 42 }, 500); 43 44 }); 45 46 // hide search result box if click outside 47 $(document).on('click touch', function(e) { 48 // check if ajax is enabled 49 if ($('.klb-search-results').length) { 50 // show search result when click input 51 if($(e.target).is('[type="search"]')){ 52 $('.klb-search-results').show(); 53 return false; 54 } 55 56 // hide search result box if click outside 57 if ($(e.target).closest($('.klb-search-results')).length == 0) { 58 $('.klb-search-results').hide(); 59 } 60 } 61 }); 62 63 64});
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.