text: !function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-autocomplete",function(t){var n=e(this),i=function(){var e=n.find("input.siteorigin-widget-input").val();return 0===e.length?[]:e.split(",")},s=function(){var t=i();n.find("ul.items > li").each(function(n,i){var s=e(this);t.indexOf(s.data("value"))>-1?s.addClass("selected"):s.removeClass("selected")})},a=null,l=function(){null!==a&&a.abort();var t=n.find(".content-text-search"),i=t.val(),s=t.data("source"),l=t.data("postTypes"),o={action:"so_widgets_search_"+s};"posts"===s?(o.query=i,o.postTypes=l):"terms"===s&&(o.term=i);var d=n.find("ul.items").empty().addClass("loading");return e.get(soWidgets.ajaxurl,o,function(t){t.forEach(function(t){""===t.label&&(t.label="&nbsp;"),d.append(e("<li>").html(t.label+"<span>("+t.type+")</span>").data(t))}),d.removeClass("loading")})};n.find(".siteorigin-widget-autocomplete-input").click(function(){var t=n.find(".existing-content-selector");t.show();var i=new e.Deferred;t.is(":visible")&&0===t.find("ul.items li").length?i=l():i.resolve(),i.done(s)});var o=function(){n.find(".existing-content-selector").hide()};e(window).mousedown(function(e){var t=0===n.find(e.target).length;t&&o()}),n.find(".button-close").click(o),n.on("click",".items li",function(t){t.preventDefault();var s=e(this),a=i(),l=s.data("value"),o=a.indexOf(l);o>-1?(a.splice(o,1),s.removeClass("selected")):(a.push(l),s.addClass("selected"));var d=n.find("input.siteorigin-widget-input");d.val(a.join(",")),d.change()});var d=null;n.find(".content-text-search").keyup(function(){null!==d&&clearTimeout(d),d=setTimeout(function(){l()},500)})})}(jQuery);