-addLoadEvent(function() {
- theCommentList = new listMan('the-comment-list');
- if ( !theCommentList )
- return false;
+var theList; var theExtraList;
+jQuery(function($) {
- theExtraCommentList = new listMan('the-extra-comment-list');
- if ( theExtraCommentList ) {
- theExtraCommentList.showLink = 0;
- theExtraCommentList.altOffset = 1;
- if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes )
- var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
- else
- var commentNum = 0;
- var urlQ = document.location.href.split('?');
- var params = urlQ[1] ? urlQ[1].toQueryParams() : [];
- var search = params['s'] ? params['s'] : '';
- var page = params['apage'] ? params['apage'] : 1;
- }
-
- theCommentList.dimComplete = function(what,id,dimClass) {
- var m = document.getElementById('awaitmod');
- if ( document.getElementById(what + '-' + id).className.match(dimClass) )
- m.innerHTML = parseInt(m.innerHTML,10) + 1;
- else
- m.innerHTML = parseInt(m.innerHTML,10) - 1;
- }
+var dimAfter = function( r, settings ) {
+ $('li span.comment-count').each( function() {
+ var a = $(this);
+ var n = parseInt(a.html(),10);
+ n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
+ if ( n < 0 ) { n = 0; }
+ a.html( n.toString() );
+ $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+ });
+ $('.post-com-count span.comment-count').each( function() {
+ var a = $(this);
+ var n = parseInt(a.html(),10);
+ var t = parseInt(a.parent().attr('title'), 10);
+ if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
+ n = n - 1;
+ t = t + 1;
+ } else { // we approved a formerly unapproved comment
+ n = n + 1;
+ t = t - 1;
+ }
+ if ( n < 0 ) { n = 0; }
+ if ( t < 0 ) { t = 0; }
+ if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
+ if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
+ a.html( n.toString() );
+ });
+}
- theCommentList.delComplete = function(what,id) {
- var m = document.getElementById('awaitmod');
- what = what.split('-')[0];
- if ( document.getElementById(what + '-' + id).className.match('unapproved') )
- m.innerHTML = parseInt(m.innerHTML,10) - 1;
- if ( theExtraCommentList && commentNum ) {
- var theMover = theExtraCommentList.theList.childNodes[0];
- Element.removeClassName(theMover,'alternate');
- theCommentList.theList.appendChild(theMover);
- theExtraCommentList.inputData += '&page=' + page;
- if ( search )
- theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box
- theExtraCommentList.addComplete = function() {
- if ( theExtraCommentList.theList.childNodes )
- var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
- else
- var commentNum = 0;
- }
- theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request
+var delAfter = function( r, settings ) {
+ $('li span.comment-count').each( function() {
+ var a = $(this);
+ var n = parseInt(a.html(),10);
+ if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
+ n = n - 1;
+ } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
+ n = n + 1;
}
+ if ( n < 0 ) { n = 0; }
+ a.html( n.toString() );
+ $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+ });
+ $('.post-com-count span.comment-count').each( function() {
+ var a = $(this);
+ if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
+ var t = parseInt(a.parent().attr('title'), 10);
+ if ( t < 1 ) { return; }
+ t = t - 1;
+ a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
+ if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
+ return;
+ }
+ var n = parseInt(a.html(),10) - 1;
+ a.html( n.toString() );
+ });
+
+ if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
+ return;
}
- if ( theList ) // the post list: edit.php
- theList.delComplete = function() {
- var comments = document.getElementById('comments');
- var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments);
- var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList);
- setTimeout(commdel,705);
- setTimeout(listdel,705);
- }
-});
+ theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
+ $('#get-extra-comments').submit();
+}
+
+theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
+theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } );
+} );