diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js index c403ad8c24..333a2eb563 100644 --- a/wp-admin/js/tags.js +++ b/wp-admin/js/tags.js @@ -1,6 +1,8 @@ +/* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */ + jQuery(document).ready(function($) { - $('#the-list').on('click', '.delete-tag', function(e){ + $( '#the-list' ).on( 'click', '.delete-tag', function() { var t = $(this), tr = t.parents('tr'), r = true, data; if ( 'undefined' != showNotice ) r = showNotice.warn(); @@ -29,34 +31,36 @@ jQuery(document).ready(function($) { $('#submit').click(function(){ var form = $(this).parents('form'); - if ( !validateForm( form ) ) + if ( ! validateForm( form ) ) return false; $.post(ajaxurl, $('#addtag').serialize(), function(r){ + var res, parent, term, indent, i; + $('#ajax-response').empty(); - var res = wpAjax.parseAjaxResponse(r, 'ajax-response'); + res = wpAjax.parseAjaxResponse( r, 'ajax-response' ); if ( ! res || res.errors ) return; - var parent = form.find('select#parent').val(); + parent = form.find( 'select#parent' ).val(); if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list. - $('.tags #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed + $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed else - $('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm + $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm $('.tags .no-items').remove(); if ( form.find('select#parent') ) { // Parents field exists, Add new term to the list. - var term = res.responses[1].supplemental; + term = res.responses[1].supplemental; // Create an indent for the Parent field - var indent = ''; - for ( var i = 0; i < res.responses[1].position; i++ ) + indent = ''; + for ( i = 0; i < res.responses[1].position; i++ ) indent += '   '; - form.find('select#parent option:selected').after(''); + form.find( 'select#parent option:selected' ).after( '' ); } $('input[type="text"]:visible, textarea:visible', form).val(''); diff --git a/wp-admin/js/tags.min.js b/wp-admin/js/tags.min.js index 505dc3eb0c..23b9133c5c 100644 --- a/wp-admin/js/tags.min.js +++ b/wp-admin/js/tags.min.js @@ -1 +1 @@ -jQuery(document).ready(function(a){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('

'+tagsl10n.noPerm+"

"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('

'+tagsl10n.broken+"

"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#submit").click(function(){var b=a(this).parents("form");return validateForm(b)?(a.post(ajaxurl,a("#addtag").serialize(),function(c){a("#ajax-response").empty();var d=wpAjax.parseAjaxResponse(c,"ajax-response");if(d&&!d.errors){var e=b.find("select#parent").val();if(e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(var f=d.responses[1].supplemental,g="",h=0;h'+g+f.name+"")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1):!1})}); \ No newline at end of file +jQuery(document).ready(function(a){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('

'+tagsl10n.noPerm+"

"),d.children().css("backgroundColor","")):(a("#ajax-response").empty().append('

'+tagsl10n.broken+"

"),d.children().css("backgroundColor",""))}),d.children().css("backgroundColor","#f33")),!1}),a("#submit").click(function(){var b=a(this).parents("form");return validateForm(b)?(a.post(ajaxurl,a("#addtag").serialize(),function(c){var d,e,f,g,h;if(a("#ajax-response").empty(),d=wpAjax.parseAjaxResponse(c,"ajax-response"),d&&!d.errors){if(e=b.find("select#parent").val(),e>0&&a("#tag-"+e).length>0?a(".tags #tag-"+e).after(d.responses[0].supplemental.noparents):a(".tags").prepend(d.responses[0].supplemental.parents),a(".tags .no-items").remove(),b.find("select#parent")){for(f=d.responses[1].supplemental,g="",h=0;h'+g+f.name+"")}a('input[type="text"]:visible, textarea:visible',b).val("")}}),!1):!1})}); \ No newline at end of file