jQuery(document).ready(function(){var e=wp.media;e&&"undefined"!=typeof mediaTaxonomies&&jQuery.each(mediaTaxonomies,function(t,a){e.view.AttachmentFilters[t]=e.view.AttachmentFilters.extend({className:t,createFilters:function(){var e={};_.each(mediaTerms[t]||{},function(a){var i={};i[t]={taxonomy:t,term_id:parseInt(a.id,10),term_slug:a.slug},e[a.slug]={text:a.label,props:i}}),this.filters=e}});var i=e.view.AttachmentsBrowser;e.view.AttachmentsBrowser=e.view.AttachmentsBrowser.extend({createToolbar:function(){e.model.Query.defaultArgs.filterSource="filter-media-taxonomies",i.prototype.createToolbar.apply(this,arguments),this.toolbar.set(t,new e.view.AttachmentFilters[t]({controller:this.controller,model:this.collection.props,priority:-80}).render())}})}),jQuery("html").delegate(".media-terms input","change",function(){var e=jQuery(this),t=e.parents(".media-terms"),a=t.parent(),i={action:"save-media-terms",term_ids:[],attachment_id:t.data("id"),taxonomy:t.data("taxonomy")};t.find("input:checked").each(function(){i.term_ids.push(jQuery(this).val())}),a.addClass("media-save-terms"),t.find("input").prop("disabled","disabled"),jQuery.post(ajaxurl,i,function(e){a.removeClass("media-save-terms"),t.find("input").removeProp("disabled")})}),jQuery("html").delegate(".toggle-add-media-term","click",function(e){e.preventDefault(),jQuery(this).parent().find(".add-new-term").toggle()}),jQuery("html").delegate(".save-media-term","click",function(e){var t=jQuery(this),a=t.parent().find("input"),i=t.parent().find("select"),r={action:"add-media-term",attachment_id:t.data("id"),taxonomy:t.data("taxonomy"),parent:i.val(),term:a.val()};return""==r.term?void a.focus():void jQuery.post(ajaxurl,r,function(e){t.parents(".field").find(".media-terms ul:first").html(e.checkboxes),t.parents(".field").find("select").replaceWith(e.selectbox),a.val("")},"json")})});