X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d3b1ea255664edd2deef17f900a655613d20820d..refs/tags/wordpress-4.7-scripts:/wp-admin/js/tags.js diff --git a/wp-admin/js/tags.js b/wp-admin/js/tags.js index 7f0ea0be..333a2eb5 100644 --- a/wp-admin/js/tags.js +++ b/wp-admin/js/tags.js @@ -1 +1,72 @@ -jQuery(document).ready(function(d){var b=false,f,e,c,a;f=function(i,h){var g=d(""+d("name",i).text()+"").html(),j=d("tag",i).attr("id");b[b.length]=new Option(g,j)};e=function(g,i){var h=d(i.parsed.responses[0].data);if(h.length==1){inlineEditTax.addEvents(d(h.id))}};a=function(h,g){var j=d("tag",h).attr("id"),i;for(i=0;i

' + tagsl10n.noPerm + '

'); + tr.children().css('backgroundColor', ''); + } else { + $('#ajax-response').empty().append('

' + tagsl10n.broken + '

'); + tr.children().css('backgroundColor', ''); + } + }); + tr.children().css('backgroundColor', '#f33'); + } + return false; + }); + + $('#submit').click(function(){ + var form = $(this).parents('form'); + + if ( ! validateForm( form ) ) + return false; + + $.post(ajaxurl, $('#addtag').serialize(), function(r){ + var res, parent, term, indent, i; + + $('#ajax-response').empty(); + res = wpAjax.parseAjaxResponse( r, 'ajax-response' ); + if ( ! res || res.errors ) + return; + + 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 + else + $( '.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. + term = res.responses[1].supplemental; + + // Create an indent for the Parent field + indent = ''; + for ( i = 0; i < res.responses[1].position; i++ ) + indent += '   '; + + form.find( 'select#parent option:selected' ).after( '' ); + } + + $('input[type="text"]:visible, textarea:visible', form).val(''); + }); + + return false; + }); + +});