]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/tags.dev.js
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / js / tags.dev.js
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                                 } else if ( '-1' == r ) {
14                                         $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
15                                         tr.children().css('backgroundColor', '');
16                                 } else {
17                                         $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
18                                         tr.children().css('backgroundColor', '');
19                                 }
20                         });
21                         tr.children().css('backgroundColor', '#f33');
22                 }
23                 return false;
24         });
25
26         $('#submit').click(function(){
27                 var form = $(this).parents('form');
28
29                 if ( !validateForm( form ) )
30                         return false;
31
32                 $.post(ajaxurl, $('#addtag').serialize(), function(r){
33                         if ( r.indexOf('<div class="error"') === 0 ) {
34                                 $('#ajax-response').append(r);
35                         } else {
36                                 $('#ajax-response').empty();
37                                 $('#the-list').prepend(r);
38                                 $('input[type="text"]:visible, textarea:visible', form).val('');
39                         }
40                 });
41
42                 return false;
43         });
44
45 });