!function(e,t){"object"==typeof module&&module.exports?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Spinner=t()}(this,function(){"use strict";function f(e,t){var s,i=document.createElement(e||"div");for(s in t)i[s]=t[s];return i}function g(e){for(var t=1,s=arguments.length;t>1)+"px"})}for(var i,r=0,n=(s.lines-1)*(1-s.direction)/2;r',t)}y.addRule(".spin-vml","behavior:url(#default#VML)"),s.prototype.lines=function(e,i){function r(){return v(c("group",{coordsize:a+" "+a,coordorigin:-n+" "+-n}),{width:a,height:a})}function t(e,t,s){g(l,g(v(r(),{rotation:360/i.lines*e+"deg",left:~~t}),g(v(c("roundrect",{arcsize:i.corners}),{width:n,height:i.scale*i.width,left:i.scale*i.radius,top:-i.scale*i.width>>1,filter:s}),c("fill",{color:m(i.color,e),opacity:i.opacity}),c("stroke",{opacity:0}))))}var s,n=i.scale*(i.length+i.width),a=2*i.scale*n,o=-(i.width+i.length)*i.scale*2+"px",l=v(r(),{position:"absolute",top:o,left:o});if(i.shadow)for(s=1;s<=i.lines;s++)t(s,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(s=1;s<=i.lines;s++)t(s);return g(e,l)},s.prototype.opacity=function(e,t,s,i){var r=e.firstChild;i=i.shadow&&i.lines||0,r&&t+i',c=e.data("swpparentel");c?(this.parent_el=h(c),this.parent_el.html(l)):this.config.parent_el?(this.parent_el=h(this.config.parent_el),this.parent_el.html(l)):h("body").append(h(l)),this.results_el=h("#"+this.results_id),this.position_results(),h(window).resize(function(){t.position_results()}),this.config.spinner&&(this.spinner=new Spinner(this.config.spinner)),void 0===this.config.abort_on_enter&&(this.config.abort_on_enter=!0),e.keyup(function(e){-1=t.config.input.min_chars?t.results_el.removeClass("searchwp-live-search-no-min-chars"):t.results_el.addClass("searchwp-live-search-no-min-chars"))}).keyup(h.proxy(this.maybe_search,this)),(this.config.results_destroy_on_blur||void 0===this.config.results_destroy_on_blur)&&h("html").click(function(){t.destroy_results()}),e.click(function(e){e.stopPropagation()}),this.results_el.click(function(e){e.stopPropagation()})}else alert(searchwp_live_search_params.msg_no_config_found)},keyboard_navigation:function(){var i=this,r=this.input_el,n=this.results_el,a="searchwp-live-search-result--focused",o=".searchwp-live-search-result",l=this.a11y_keys;h(document).off("keyup.searchwp_a11y").on("keyup.searchwp_a11y",function(e){if(n.hasClass("searchwp-live-search-results-showing")){if(-1!==h.inArray(e.keyCode,l)){if(e.preventDefault(),27===e.keyCode&&!r.is(":focus"))return i.destroy_results(),h(document).off("keyup.searchwp_a11y"),r.focus(),void h(document).trigger("searchwp_live_escape_results");if(40===e.keyCode){console.log("down!");var t=h(n[0]).find("."+a);1===t.length&&1===t.next().length?(t.removeClass(a).attr("aria-selected","false").next().addClass(a).attr("aria-selected","true").find("a").focus(),i.aria_activedescendant(!0)):(t.removeClass(a).attr("aria-selected","false"),n.find(o+":first").addClass(a).attr("aria-selected","true").find("a").focus(),0=this.config.input.min_chars&&(this.timer=setTimeout(h.proxy(this.search,this,e),this.config.input.delay)))},show_spinner:function(){this.config.spinner&&!this.spinner_showing&&(this.spinner.spin(document.getElementById(this.results_id)),this.spinner_showing=!0,h(document).trigger("searchwp_live_show_spinner"))},hide_spinner:function(){this.config.spinner&&(this.spinner.stop(),this.spinner_showing=!1,h(document).trigger("searchwp_live_hide_spinner"))},search:function(e){var t=this,s=this.form_el,i=s.serialize(),r=s.attr("action")?s.attr("action"):"",n=this.input_el,a=this.results_el;h(document).trigger("searchwp_live_search_start",[n,a,s,r,i]),this.aria_expanded(!1),i+="&action=searchwp_live_search&swpengine="+n.data("swpengine")+"&swpquery="+n.val(),-1!==r.indexOf("?")&&(r=r.split("?"),i+="&"+r[1]),this.last_string=n.val(),this.has_results=!0,this.current_request=h.ajax({url:searchwp_live_search_params.ajaxurl,type:"POST",data:i,complete:function(){h(document).trigger("searchwp_live_search_complete",[n,a,s,r,i]),t.spinner_showing=!1,t.hide_spinner(),this.current_request=!1},success:function(e){0===e&&(e=""),h(document).trigger("searchwp_live_search_success",[n,a,s,r,i]),t.position_results(),a.html(e),t.aria_expanded(!0),t.keyboard_navigation()}})},uniqid:function(e,t){void 0===e&&(e="");var s,i=function(e,t){return t<(e=parseInt(e,10).toString(16)).length?e.slice(e.length-t):t>e.length?new Array(t-e.length+1).join("0")+e:e};return this.php_js||(this.php_js={}),this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())),this.php_js.uniqidSeed++,s=e,s+=i(parseInt((new Date).getTime()/1e3,10),8),s+=i(this.php_js.uniqidSeed,5),t&&(s+=(10*Math.random()).toFixed(8).toString()),s}},h.fn[s]=function(e){return this.each(function(){h.data(this,"plugin_"+s)||h.data(this,"plugin_"+s,new t(h(this),e))}),this}}(jQuery),jQuery(document).ready(function(e){e('input[data-swplive="true"]').searchwp_live_search()});