Changeset 26198
- Timestamp:
- 11/15/2013 05:01:34 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/tags.js
r23444 r26198 1 /* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */ 2 1 3 jQuery(document).ready(function($) { 2 4 3 $( '#the-list').on('click', '.delete-tag', function(e){5 $( '#the-list' ).on( 'click', '.delete-tag', function() { 4 6 var t = $(this), tr = t.parents('tr'), r = true, data; 5 7 if ( 'undefined' != showNotice ) … … 30 32 var form = $(this).parents('form'); 31 33 32 if ( ! validateForm( form ) )34 if ( ! validateForm( form ) ) 33 35 return false; 34 36 35 37 $.post(ajaxurl, $('#addtag').serialize(), function(r){ 38 var res, parent, term, indent, i; 39 36 40 $('#ajax-response').empty(); 37 var res = wpAjax.parseAjaxResponse(r, 'ajax-response');41 res = wpAjax.parseAjaxResponse( r, 'ajax-response' ); 38 42 if ( ! res || res.errors ) 39 43 return; 40 44 41 var parent = form.find('select#parent').val();45 parent = form.find( 'select#parent' ).val(); 42 46 43 47 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. 44 $( '.tags #tag-' + parent).after( res.responses[0].supplemental['noparents']); // As the parent exists, Insert the version with - - - prefixed48 $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed 45 49 else 46 $( '.tags').prepend( res.responses[0].supplemental['parents']); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm50 $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm 47 51 48 52 $('.tags .no-items').remove(); … … 50 54 if ( form.find('select#parent') ) { 51 55 // Parents field exists, Add new term to the list. 52 varterm = res.responses[1].supplemental;56 term = res.responses[1].supplemental; 53 57 54 58 // Create an indent for the Parent field 55 varindent = '';56 for ( vari = 0; i < res.responses[1].position; i++ )59 indent = ''; 60 for ( i = 0; i < res.responses[1].position; i++ ) 57 61 indent += ' '; 58 62 59 form.find( 'select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>');63 form.find( 'select#parent option:selected' ).after( '<option value="' + term.term_id + '">' + indent + term.name + '</option>' ); 60 64 } 61 65
Note: See TracChangeset
for help on using the changeset viewer.