1jQuery(document).ready(function($) { 2 "use strict"; 3 4 $('header form.search-form, .search-holder form.search-form ').addClass('klb-ajax-search'); 5 6 var searchform = $('form.klb-ajax-search'); 7 var searchselect = $('form.klb-ajax-search select'); 8 var searchinput = $('form.klb-ajax-search input[type="search"]'); 9 var searchbutton = $('form.klb-ajax-search button'); 10 var timeout; 11 12 $(document).on('change', 'form.klb-ajax-search select', function(){ 13 $(this).closest('form.klb-ajax-search').find('input[type="search"]').keyup(); 14 }); 15 16 $(document).on('keyup', searchinput, function(event){ 17 event.preventDefault(); 18 19 if($(event.target).val().length < 3){ 20 return false; 21 } 22 23 if(timeout) { 24 clearTimeout(timeout); 25 } 26 timeout = setTimeout(function() { 27 var data = { 28 cache: false, 29 type: 'POST', 30 action: 'ajax_search', 31 beforeSend: function() { 32 $(event.target).closest(searchform).find(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>'); 33 $(event.target).closest(searchform).addClass('search-loading'); 34 }, 35 keyword: $(event.target).val(), 36 selected_cat: $(event.target).closest(searchform).find('option:selected').val(), 37 38 }; 39 40 // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php 41 $.post(clotyasearch.ajaxurl, data, function(response) { 42 43 $(".klb-search-results").remove(); 44 $(event.target).closest(searchform).find(searchinput).after('<div class="klb-search-results">' + response + '</div>'); 45 46 $(searchform).removeClass('search-loading'); 47 $(".loader-image").remove(); 48 49 }); 50 }, 500); 51 52 }); 53 54 // hide search result box if click outside 55 $(document).on('click touch', function(e) { 56 // check if ajax is enabled 57 if ($('.klb-search-results').length) { 58 // show search result when click input 59 if($(e.target).is('select')){ 60 $('.klb-search-results').show(); 61 return false; 62 } 63 64 if($(e.target).is('[type="search"]')){ 65 $('.klb-search-results').show(); 66 return false; 67 } 68 69 // hide search result box if click outside 70 if ($(e.target).closest($('.klb-search-results')).length == 0) { 71 $('.klb-search-results').hide(); 72 } 73 } 74 }); 75 76 77});
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.