var TF_Ajaxify_Field=function(){function e(){this.init()}return e.prototype.init=function(){var e,t;window.IntersectionObserver&&(e=document.querySelectorAll(".tf-ajaxify-wrapper:not(.loaded)"))&&(t=new IntersectionObserver(function(e,a){e.forEach(function(t){var e;t.isIntersecting&&(t.target.classList.add("loaded"),e=t.target.querySelector(".tf-select-ajaxify"),"function"==typeof jQuery(e).chosen&&jQuery(e).chosen("destroy"),jQuery(e).select2({templateResult:function(e){if(e.id)return e.text},placeholder:t.target.dataset.placeholder,ajax:{url:t.target.dataset.ajaxEndpoint,dataType:"json",error:function(e,t,a){"abort"!=e.statusText&&alert(e.responseText)}},allowClear:!0,multiple:"false"===t.target.dataset.singleValue,cache:!0}),""!==t.target.dataset.searchPlaceholder&&jQuery(e).one("select2:open",function(e){jQuery("input.select2-search__field").prop("placeholder",t.target.dataset.searchPlaceholder)}),a.unobserve(e))})},{rootMargin:"0px 0px 0px 0px"}),e.forEach(function(e){t.observe(e)}))},e}();document.addEventListener("DOMContentLoaded",function(){new TF_Ajaxify_Field});

