jquery for list manipulation. Round one, fight. Props mdawaffe. fixes #4805
git-svn-id: http://svn.automattic.com/wordpress/trunk@6213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1,59 +1,26 @@
|
||||
addLoadEvent(function() {
|
||||
theCommentList = new listMan('the-comment-list');
|
||||
if ( !theCommentList )
|
||||
return false;
|
||||
var list; var extra;
|
||||
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;
|
||||
var dimAfter = function( r, settings ) {
|
||||
var a = $('#awaitmod');
|
||||
a.html( parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ) );
|
||||
}
|
||||
|
||||
var delAfter = function( r, settings ) {
|
||||
var a = $('#awaitmod');
|
||||
if ( $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
|
||||
a.html( parseInt(a.html(),10) - 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;
|
||||
if ( extra.size() == 0 || extra.children().size() == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
|
||||
$('#get-extra-comments').submit();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
extra = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
|
||||
list = $('#the-comment-list').wpList( { dimAfter : dimAfter, delAfter : delAfter, addColor: 'none' } );
|
||||
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user