1/* Debounce */ 2(function (b, c) { 3 var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a; 4 $.throttle = a = function (e, f, j, i) { 5 var h, d = 0; 6 if (typeof f !== "boolean") { 7 i = j; 8 j = f; 9 f = c 10 } 11 12 function g() { 13 var o = this, m = +new Date() - d, n = arguments; 14 15 function l() { 16 d = +new Date(); 17 j.apply(o, n) 18 } 19 20 function k() { 21 h = c 22 } 23 24 if (i && !h) { 25 l() 26 } 27 h && clearTimeout(h); 28 if (i === c && m > e) { 29 l() 30 } else { 31 if (f !== true) { 32 h = setTimeout(i ? k : l, i === c ? e - m : e) 33 } 34 } 35 } 36 37 if ($.guid) { 38 g.guid = j.guid = j.guid || $.guid++ 39 } 40 return g 41 }; 42 $.debounce = function (d, e, f) { 43 return f === c ? a(d, e, false) : a(d, f, e !== false) 44 } 45})(this); 46(function ($) { 47 "use strict"; 48 var PENCI = PENCI || {}; 49 PENCI.ajaxsearch = function () { 50 var escapeRegExChars = function (value) { 51 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 52 }; 53 54 $('form.penci-ajax-search').each( 55 function () { 56 var $this = $(this), 57 number = parseInt(penci_ajsr.maxitems), 58 thumbnail = parseInt(penci_ajsr.thumbnail), 59 date = parseInt(penci_ajsr.date), 60 $results = $this.parent().find('.penci-dropdown-results > .penci-search-results-wrapper'); 61 62 63 if ($this.data('count')) { 64 number = parseInt($this.data('count')); 65 } 66 67 if ($this.data('thumbnail')) { 68 thumbnail = parseInt($this.data('thumbnail')); 69 } 70 71 if ($('body').find('.header-search-style-showup').length) { 72 number = 3; 73 } 74 75 if ($('body').find('.header-search-style-default').length) { 76 number = 8; 77 } 78 79 if ($('body').find('.header-search-style-overlay').length) { 80 number = 6; 81 } 82 83 if (penci_ajsr.citems && penci_ajsr.maxitems) { 84 number = parseInt(penci_ajsr.maxitems); 85 } 86 87 $results.on( 88 'click', 89 '.view-all-results', 90 function () { 91 $this.submit(); 92 } 93 ); 94 95 $this.find('[type="text"]').on( 96 'focus keyup', 97 $.debounce(200, function () { 98 var $input = $(this), 99 $svalue = $input.val(), 100 data = { 101 action: 'penci_ajax_search', 102 number: number, 103 nonce: penci_ajsr.nonce, 104 query: $svalue, 105 }; 106 107 if ($svalue.length < 1) { 108 return; 109 } 110 111 $.ajax({ 112 type: "GET", 113 dataType: "html", 114 url: penci_ajsr.ajaxUrl, 115 data: data, 116 beforeSend: function () { 117 $this.addClass('search-loading'); 118 $this.closest('.show-search').addClass('pcajx-search-loading'); 119 $this.closest('.penci-search-form').addClass('pcajx-search-open'); 120 }, 121 success: function (data) { 122 $results.empty(); 123 $results.append('<div class="autocomplete-suggestions"></div>'); 124 var returnValue = ''; 125 126 data = JSON.parse(data); 127 128 $.each(data.suggestions, function (index, suggestion) { 129 130 returnValue += '<div class="autocomplete-suggestion" data-index="' + index + '">'; 131 132 if (thumbnail && suggestion.thumbnail) { 133 returnValue += ' <div class="suggestion-thumb">' + suggestion.thumbnail + '</div>'; 134 } 135 136 if (suggestion.value) { 137 returnValue += ' <div class="suggestion-content reset-last-child">'; 138 returnValue += '<h4 class="penci-post-title"><a title="' + suggestion.title + '" href="' + suggestion.permalink + '">' + suggestion.value + '</a></h4>'; 139 } 140 141 if (date && suggestion.date) { 142 returnValue += ' <span class="post-date">' + suggestion.date + '</span>'; 143 } 144 145 if (suggestion.value) { 146 returnValue += ' </div>'; 147 } 148 149 if (suggestion.no_found) { 150 returnValue = '<span class="no-found-msg">' + suggestion.value + '</span>'; 151 } 152 153 returnValue += ' </div>'; 154 155 }); 156 157 $results.find('.autocomplete-suggestions').append(returnValue); 158 159 160 $results.find('.view-all-results').remove(); 161 162 if ($results.find('.autocomplete-suggestion').length > 2 && penci_ajsr.allresults) { 163 $results.append('<div class="view-all-results"><span><a href="' + data.allsearch + '">' + penci_ajsr.allresults + '</a></span></div>'); 164 } 165 166 if ($results.find('.autocomplete-suggestion').length > 1) { 167 $results.closest('.penci-search-form').addClass('has-search-items'); 168 } 169 170 $results.parent().addClass('penci-opened'); 171 }, 172 complete: function () { 173 $this.removeClass('search-loading'); 174 $this.closest('.show-search').removeClass('pcajx-search-loading'); 175 $(document).trigger('penci-images-loaded');
176 var PenciLazy = new LazyLoad({ 177 elements_selector: '.penci-lazy', 178 data_bg: 'bgset', 179 class_loading: 'lazyloading', 180 class_entered: 'lazyloaded', 181 class_loaded: 'pcloaded', 182 unobserve_entered: true 183 }); 184 } 185 }); 186 } 187 )); 188 189 $(document).on( 190 'click', 191 function (e) { 192 var target = e.target; 193 194 if (!$(target).is('.penci-search-form') && !$(target).parents().is('.penci-search-form') && !$(target).is('.penci-search-full-screen') && !$(target).parents().is('.penci-search-full-screen')) { 195 //$('.show-search').removeClass('active'); 196 $results.parent().removeClass('penci-opened'); 197 $this.closest('.penci-search-form') 198 .removeClass('has-search-items') 199 .removeClass('pcajx-search-open'); 200 } 201 } 202 ); 203 204 $('.penci-dropdown-results > .penci-search-results-wrapper').on( 205 'click', 206 function (e) { 207 e.stopPropagation(); 208 } 209 ); 210 } 211 ); 212 } 213 214 $(document).ready(function () { 215 PENCI.ajaxsearch(); 216 }); 217})(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.