1;(function($){ 2"use strict"; 3 4 // key press event 5 $(document).ready(function(){ 6 7 $('.woolentor_widget_psa input').keyup( function(e) { 8 var $this = $(this); 9 clearTimeout( $.data( this, 'timer' ) ); 10 if ( e.keyCode == 13 ){ 11 doSearch( $this ); 12 } else { 13 doSearch( $this ); 14 $(this).data( 'timer', setTimeout( doSearch, 100 ) ); 15 } 16 }); 17 18 $('.woolentor_widget_psa_clear_icon').on('click', function(){ 19 $(this).closest(".woolentor_widget_psa").find('#woolentor_psa_results_wrapper').html(''); 20 $(this).parents('.woolentor_widget_psa').removeClass('woolentor_widget_psa_clear'); 21 $(this).siblings('input[type="search"]').val(''); 22 }); 23 24 // Click Outside 25 $(document).mouseup(function(e){ 26 var container = $(".woolentor_widget_psa"); 27 var hidecontainer = $('#woolentor_psa_results_wrapper'); 28 // if the target of the click isn't the container nor a descendant of the container 29 if (!container.is(e.target) && container.has(e.target).length === 0){ 30 hidecontainer.hide(); 31 }else{ 32 hidecontainer.show(); 33 } 34 }); 35 36 }); 37 38 function doSearch( $this = '' ) { 39 40 if ( $this.length > 0 ) { 41 var searchString = $this.val(), 42 catagoryValue = $this.closest(".woolentor_widget_psa").find(".woolentor_widget_psa_category select").find(':selected').attr('data-value'), 43 searchResultWrap = $this.closest(".woolentor_widget_psa").find("#woolentor_psa_results_wrapper"); 44 if( searchString == '' ){ 45 searchResultWrap.html(''); 46 $this.parents('.woolentor_widget_psa').removeClass('woolentor_widget_psa_clear'); 47 } 48 if ( searchString.length < 2 ) return; //wasn't enter, not > 2 char 49 var wrapper_width = $this.parents('.woolentor_widget_psa').width(), 50 settings = $this.parents('.woolentor_widget_psa form').data('settings'), 51 limit = settings.limit ? parseInt(settings.limit) : 10; 52 53 $.ajax({ 54 url: woolentor_addons.woolentorajaxurl, 55 data: { 56 'action': 'woolentor_ajax_search', 57 'category': catagoryValue, 58 's' : searchString, 59 'limit' : limit, 60 'nonce' : woolentor_addons.ajax_nonce 61 }, 62 beforeSend:function(){ 63 $this.parents('.woolentor_widget_psa').addClass('woolentor_widget_psa_loading'); 64 }, 65 success:function(response) { 66 searchResultWrap.css({'width': wrapper_width}); 67 searchResultWrap.html(response); 68 $this.parents('.woolentor_widget_psa').removeClass('woolentor_widget_psa_loading'); 69 }, 70 error: function(errorThrown){ 71 console.log(errorThrown); 72 } 73 }).done(function(response){ 74 $this.parents('.woolentor_widget_psa').addClass('woolentor_widget_psa_clear'); 75 }); 76 } 77 78 } 79 80})(jQuery);
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.