From 73b4b6055ec88615f2a24ca65d47b54a089347a3 Mon Sep 17 00:00:00 2001
From: ryan
Date: Tue, 6 Jun 2006 04:14:04 +0000
Subject: [PATCH] List manipulation improvements from mdawaffe. fixes #2786
git-svn-id: http://svn.automattic.com/wordpress/trunk@3847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-admin/edit-comments.js | 28 +++++++++++++++++++++++-----
wp-admin/edit-comments.php | 12 ++++++------
wp-admin/edit.php | 10 +++++-----
wp-admin/list-manipulation-js.php | 6 +++---
wp-admin/moderation.php | 12 ++++++------
wp-includes/script-loader.php | 4 ++--
6 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/wp-admin/edit-comments.js b/wp-admin/edit-comments.js
index 193dd48c2..4dfe755e4 100644
--- a/wp-admin/edit-comments.js
+++ b/wp-admin/edit-comments.js
@@ -1,5 +1,23 @@
-addLoadEvent(function() {theList.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;
-}});
+addLoadEvent(function() {
+ theCommentList = new listMan('the-comment-list');
+ if ( !theCommentList )
+ return false;
+ 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;
+ }
+ theCommentList.delComplete = function(what,id) {
+ var m = document.getElementById('awaitmod');
+ if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ }
+ 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);
+ }
+});
+
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index a8d401a75..db8ad1239 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -99,7 +99,7 @@ if ('view' == $mode) {
else
$start = '';
- echo "
diff --git a/wp-admin/list-manipulation-js.php b/wp-admin/list-manipulation-js.php
index bfca4be92..ef094676a 100644
--- a/wp-admin/list-manipulation-js.php
+++ b/wp-admin/list-manipulation-js.php
@@ -3,8 +3,8 @@ require_once('admin.php');
header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
?>
addLoadEvent(function(){theList=new listMan();});
-function deleteSomething(what,id,message){if(!message)message="";if(confirm(message))return theList.ajaxDelete(what,id);else return false;}
-function dimSomething(what,id,dimClass){return theList.ajaxDimmer(what,id,dimClass);}
+function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="";if(confirm(message))return obj.ajaxDelete(what,id);else return false;}
+function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);}
function WPAjax(file, responseEl){//class WPAjax extends sack
this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p; }
@@ -74,7 +74,7 @@ function listMan(theListId){
this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
if(this.ajaxDel.failed)return true;
var tempObj=this;
- this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id);this.myResponseElement.innerHTML='';if(tempObj.delComplete&&typeof tempObj.delComplete=='function')tempObj.delComplete(what,where);tempObj.recolorList(tempObj.recolorPos,1000)}};
+ this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id);this.myResponseElement.innerHTML='';if(tempObj.delComplete&&typeof tempObj.delComplete=='function')tempObj.delComplete(what,id);tempObj.recolorList(tempObj.recolorPos,1000)}};
this.ajaxDel.runAJAX('action=delete-'+what+'&id='+id);
return false;
}
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index 77a2ae56b..5839e6f37 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -3,7 +3,7 @@ require_once('admin.php');
$title = __('Moderate comments');
$parent_file = 'edit.php';
-wp_enqueue_script( 'listman' );
+wp_enqueue_script( 'admin-comments' );
$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
for ($i=0; $i
-
+
comment_post_ID) ) { echo " " . __('Edit') . ''; - echo ' | comment_author)) . "' );\">" . __('Delete') . ' '; + echo ' | comment_author)) . "', theCommentList );\">" . __('Delete') . ' '; if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - echo ' | ' . __('Unapprove') . ' '; - echo ' | ' . __('Approve') . ' '; + echo ' | ' . __('Unapprove') . ' '; + echo ' | ' . __('Approve') . ' '; } - echo " | comment_post_ID."&comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by "%s".\\n"Cancel" to stop, "OK" to mark as spam."), js_escape( $comment->comment_author)) . "' );\">" . __('Spam') . " ]"; + echo " | comment_post_ID."&comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by "%s".\\n"Cancel" to stop, "OK" to mark as spam."), js_escape( $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . " ]"; } // end if any comments to show ?>