function mediaLibraryOrganizerSelectizeInit(e){var i=typeof e!="undefined"?e:"body";(function(e){e(media_library_organizer_selectize.selectors.simple.join(", "),e(i)).each(function(){var i=",";if(typeof e(this).data("delimiter")!=="undefined"){i=e(this).data("delimiter")}e(this).selectize({delimiter:i})});e(media_library_organizer_selectize.selectors.multiple.join(", "),e(i)).each(function(){var i=typeof e(this).data("delimiter")!=="undefined"?e(this).data("delimiter"):",";e(this).selectize({plugins:["drag_drop","remove_button"],delimiter:i,persist:false,create:function(e){return{value:e,text:e}}})});e(media_library_organizer_selectize.selectors.ajax.join(", "),e(i)).each(function(){var i=e(this).data("action"),t=e(this).data("nonce"),n=e(this).data("args"),a=e(this).attr("name"),r=e(this).data("name-field"),s=e(this).data("value-field"),l=e(this).data("method"),d=e(this).data("output-fields").split(","),o=e(this).data("plugins").split(",");e(this).selectize({plugins:o,delimiter:",",valueField:s,labelField:r,searchField:r,options:[],create:false,render:{option:function(e,i){var t=[],n=d.length;for(var a=0;a<n;a++){t.push(e[d[a]])}return"<div>"+t.join(", ")+"</div>"}},load:function(a,r){if(!a.length||a.length<3){return r()}e.ajax({url:ajaxurl,type:l,dataType:"json",data:{action:i,nonce:t,query:a,args:n},error:function(){r()},success:function(e){if(!e.success){alert(e.data)}r(e.data)}})},onChange:function(i){if(!e("input[type=hidden]",this.$input.parent()).length){return}if(i===null||!i.length){e("input[type=hidden]",this.$input.parent()).val("");return}e("input[type=hidden]",this.$input.parent()).val(i.join())}})})})(jQuery)}function mediaLibraryOrganizerSelectizeDestroy(e){var i=typeof e!="undefined"?e:"body";(function(e){e(media_library_organizer_selectize.selectors.simple.join(", "),e(i)).each(function(){if(typeof this.selectize!=="undefined"){this.selectize.destroy()}});e(media_library_organizer_selectize.selectors.multiple.join(", "),e(i)).each(function(){if(typeof this.selectize!=="undefined"){this.selectize.destroy()}});e(media_library_organizer_selectize.selectors.ajax.join(", "),e(i)).each(function(){if(typeof this.selectize!=="undefined"){this.selectize.destroy()}})})(jQuery)}