]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/edit-comments.js
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-admin / js / edit-comments.js
1 var theList; var theExtraList;
2 jQuery(function($) {
3
4 var dimAfter = function( r, settings ) {
5         $('li span.comment-count').each( function() {
6                 var a = $(this);
7                 var n = parseInt(a.html(),10);
8                 n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
9                 if ( n < 0 ) { n = 0; }
10                 a.html( n.toString() );
11                 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
12         });
13         $('.post-com-count span.comment-count').each( function() {
14                 var a = $(this);
15                 var n = parseInt(a.html(),10);
16                 var t = parseInt(a.parent().attr('title'), 10);
17                 if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
18                         n = n - 1;
19                         t = t + 1;
20                 } else { // we approved a formerly unapproved comment
21                         n = n + 1;
22                         t = t - 1;
23                 }
24                 if ( n < 0 ) { n = 0; }
25                 if ( t < 0 ) { t = 0; }
26                 if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
27                 if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
28                 a.html( n.toString() );
29         });
30 }
31
32 var delAfter = function( r, settings ) {
33         $('li span.comment-count').each( function() {
34                 var a = $(this);
35                 var n = parseInt(a.html(),10);
36                 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
37                         n = n - 1;
38                 } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
39                         n = n + 1;
40                 }
41                 if ( n < 0 ) { n = 0; }
42                 a.html( n.toString() );
43                 $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
44         });
45         $('.post-com-count span.comment-count').each( function() {
46                 var a = $(this);
47                 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
48                         var t = parseInt(a.parent().attr('title'), 10);
49                         if ( t < 1 ) { return; }
50                         t = t - 1;
51                         a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
52                         if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
53                         return;
54                 }
55                 var n = parseInt(a.html(),10) - 1;
56                 a.html( n.toString() );
57         });
58
59         if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
60                 return;
61         }
62
63         theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
64         $('#get-extra-comments').submit();
65 }
66
67 theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
68 theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
69
70 } );