| 1 |
function wp_zinc_autocomplete_setup(){wpzinc_autocompleters=[],wpzinc_autocomplete.forEach((function(e,t){var n=[];e.triggers.forEach((function(e,t){e.selectTemplate=function(e){return e.original.value},"url"in e&&(e.values=function(t,n){data=new FormData,data.append("action",e.action),data.append("nonce",e.nonce),data.append("search",t),fetch(e.url,{method:e.method,credentials:"same-origin",body:data}).then((function(e){return e.json()})).then((function(e){n(e.data)})).catch((function(e){console.error(e)}))}),n.push(e)}));var c=new Tribute({collection:n});wpzinc_autocompleters.push({fields:e.fields,instance:c})}))}function wp_zinc_autocomplete_initialize(e){wpzinc_autocompleters.forEach((function(t,n){t.fields.forEach((function(n,c){void 0!==e&&(n=e+" "+n);const o=document.querySelectorAll(n);t.instance.attach(o),o.forEach((function(e){const t=function(e){"undefined"!=typeof jQuery&&jQuery(e.target).trigger("input")};e.addEventListener("tribute-replaced",t),wpzinc_autocomplete_listeners.set(e,t)}))}))}))}function wp_zinc_autocomplete_destroy(){wpzinc_autocompleters.forEach((function(e,t){e.fields.forEach((function(t,n){const c=document.querySelectorAll(t);e.instance.detach(c),c.forEach((function(e){const t=wpzinc_autocomplete_listeners.get(e);t&&(e.removeEventListener("tribute-replaced",t),wpzinc_autocomplete_listeners.delete(e))}))}))})),wpzinc_autocompleters=[]}var wpzinc_autocompleters=[],wpzinc_autocomplete_listeners=new Map;wp_zinc_autocomplete_setup(),wp_zinc_autocomplete_initialize(); |