mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-12 15:48:34 +02:00
Props andg, afercia, guddu1315, SergeyBiryukov. Fixes #47607. Built from https://develop.svn.wordpress.org/trunk@45683 git-svn-id: http://core.svn.wordpress.org/trunk@45494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
1.8 KiB
JavaScript
1 line
1.8 KiB
JavaScript
jQuery(document).ready(function(a){var b=!1;a("#the-list").on("click",".delete-tag",function(){var b,c=a(this),d=c.parents("tr"),e=!0;return"undefined"!=showNotice&&(e=showNotice.warn()),e&&(b=c.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag"),a.post(ajaxurl,b,function(c){"1"==c?(a("#ajax-response").empty(),d.fadeOut("normal",function(){d.remove()}),a('select#parent option[value="'+b.match(/tag_ID=(\d+)/)[1]+'"]').remove(),a("a.tag-link-"+b.match(/tag_ID=(\d+)/)[1]).remove()):"-1"==c?(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#edittag").on("click",".delete",function(a){if("undefined"==typeof showNotice)return!0;var b=showNotice.warn();b||a.preventDefault()}),a("#submit").click(function(){var c=a(this).parents("form");return!!validateForm(c)&&(!b&&(b=!0,c.find(".submit .spinner").addClass("is-active"),a.post(ajaxurl,a("#addtag").serialize(),function(d){var e,f,g,h,i;if(b=!1,c.find(".submit .spinner").removeClass("is-active"),a("#ajax-response").empty(),e=wpAjax.parseAjaxResponse(d,"ajax-response"),e&&!e.errors){if(f=c.find("select#parent").val(),f>0&&a("#tag-"+f).length>0?a(".tags #tag-"+f).after(e.responses[0].supplemental.noparents):a(".tags").prepend(e.responses[0].supplemental.parents),a(".tags .no-items").remove(),c.find("select#parent")){for(g=e.responses[1].supplemental,h="",i=0;i<e.responses[1].position;i++)h+=" ";c.find("select#parent option:selected").after('<option value="'+g.term_id+'">'+h+g.name+"</option>")}a('input[type="text"]:visible, textarea:visible',c).val("")}}),!1))})}); |