| [ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 jQuery(document).ready(function($) { 2 3 $('.delete-tag').live('click', function(e){ 4 var t = $(this), tr = t.parents('tr'), r = true, data; 5 if ( 'undefined' != showNotice ) 6 r = showNotice.warn(); 7 if ( r ) { 8 data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag'); 9 $.post(ajaxurl, data, function(r){ 10 if ( '1' == r ) { 11 $('#ajax-response').empty(); 12 tr.fadeOut('normal', function(){ tr.remove(); }); 13 // Remove the term from the parent box and tag cloud 14 $('select#parent option[value="' + data.match(/tag_ID=(\d+)/)[1] + '"]').remove(); 15 $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove(); 16 } else if ( '-1' == r ) { 17 $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>'); 18 tr.children().css('backgroundColor', ''); 19 } else { 20 $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>'); 21 tr.children().css('backgroundColor', ''); 22 } 23 }); 24 tr.children().css('backgroundColor', '#f33'); 25 } 26 return false; 27 }); 28 29 $('#submit').click(function(){ 30 var form = $(this).parents('form'); 31 32 if ( !validateForm( form ) ) 33 return false; 34 35 $.post(ajaxurl, $('#addtag').serialize(), function(r){ 36 $('#ajax-response').empty(); 37 var res = wpAjax.parseAjaxResponse(r, 'ajax-response'); 38 if ( ! res || res.errors ) 39 return; 40 41 var parent = form.find('select#parent').val(); 42 43 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 - - - prefixed 45 else 46 $('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm 47 48 $('.tags .no-items').remove(); 49 50 if ( form.find('select#parent') ) { 51 // Parents field exists, Add new term to the list. 52 var term = res.responses[1].supplemental; 53 54 // Create an indent for the Parent field 55 var indent = ''; 56 for ( var i = 0; i < res.responses[1].position; i++ ) 57 indent += ' '; 58 59 form.find('select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>'); 60 } 61 62 $('input[type="text"]:visible, textarea:visible', form).val(''); 63 }); 64 65 return false; 66 }); 67 68 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Aug 22 03:56:18 2012 | Hosted by follow the white rabbit. |