WordPress/wp-admin/js/inline-edit-tax.min.js

1 line
2.7 KiB
JavaScript
Raw Normal View History

var inlineEditTax;window.wp=window.wp||{},function(d,s){inlineEditTax={init:function(){var t=this,i=d("#inline-edit");t.type=d("#the-list").attr("data-wp-lists").substr(5),t.what="#"+t.type+"-",d("#the-list").on("click","a.editinline",function(){return inlineEditTax.edit(this),!1}),i.keyup(function(t){if(27===t.which)return inlineEditTax.revert()}),d(".cancel",i).click(function(){return inlineEditTax.revert()}),d(".save",i).click(function(){return inlineEditTax.save(this)}),d("input, select",i).keydown(function(t){if(13===t.which)return inlineEditTax.save(this)}),d('#posts-filter input[type="submit"]').mousedown(function(){t.revert()})},toggle:function(t){var i=this;"none"===d(i.what+i.getId(t)).css("display")?i.revert():i.edit(t)},edit:function(t){var i,e,n=this;return n.revert(),"object"==typeof t&&(t=n.getId(t)),i=d("#inline-edit").clone(!0),e=d("#inline_"+t),d("td",i).attr("colspan",d("th:visible, td:visible",".widefat:first thead").length),d(n.what+t).hide().after(i).after('<tr class="hidden"></tr>'),(n=d(".name",e)).find("img").replaceWith(function(){return this.alt}),n=n.text(),d(':input[name="name"]',i).val(n),(n=d(".slug",e)).find("img").replaceWith(function(){return this.alt}),n=n.text(),d(':input[name="slug"]',i).val(n),d(i).attr("id","edit-"+t).addClass("inline-editor").show(),d(".ptitle",i).eq(0).focus(),!1},save:function(r){var t=d('input[name="taxonomy"]').val()||"";return"object"==typeof r&&(r=this.getId(r)),d("table.widefat .spinner").addClass("is-active"),t={action:"inline-save-tax",tax_type:this.type,tax_ID:r,taxonomy:t},t=d("#edit-"+r).find(":input").serialize()+"&"+d.param(t),d.post(ajaxurl,t,function(t){var i,e,n,a=d("#edit-"+r+" .inline-edit-save .error");d("table.widefat .spinner").removeClass("is-active"),t?-1!==t.indexOf("<tr")?(d(inlineEditTax.what+r).siblings("tr.hidden").addBack().remove(),e=d(t).attr("id"),d("#edit-"+r).before(t).remove(),i=e?(n=e.replace(inlineEditTax.type+"-",""),d("#"+e)):(n=r,d(inlineEditTax.what+r)),d("#parent").find("option[value="+n+"]").text(i.find(".row-title").text()),i.hide().fadeIn(400,function(){i.find(".editinline").focus(),s.a11y.speak(inlineEditL10n.saved)})):(a.html(t).show(),s.a11y.speak(a.text())):(a.html(inlineEditL10n.error).show(),s.a11y.speak(inlineEditL10n.error))}),!1},revert:function(){var t=d("table.widefat tr.inline-editor").attr("id");t&&(d("table.widefat .spinner").removeClass("is-active"),d("#"+t).siblings("tr.hidden").addBack().remove(),t=t.substr(t.lastIndexOf("-")+1),d(this.what+t).show().find(".editinline").focus())},getId:function(t){t=("TR"===t.tagName?t.id:d(t).parents("tr").attr("id")).split("-");return t[t.length-1]}},d(document).ready(function(){inlineEditTax.init()})}(jQuery,window.wp);