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 "
    "; + echo "
      "; $i = 0; foreach ($comments as $comment) { ++$i; $class = ''; @@ -119,12 +119,12 @@ if ('view' == $mode) { 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') . " "; } $post = get_post($comment->comment_post_ID); $post_title = wp_specialchars( $post->post_title, 'double' ); @@ -185,7 +185,7 @@ $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; comment_post_ID) ) { echo "" . __('Edit') . ""; } ?> comment_post_ID) ) { - echo "comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), js_escape( $comment->comment_author )) . "' );\" class='delete'>" . __('Delete') . " "; + echo "comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), js_escape( $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . " "; } ?>

      -
        +
          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 ?>

          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_date); $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'"); - if ($i % 2) $class = 'class="alternate"'; - else $class = ''; - echo "\n\t
            1. "; + if ($i % 2) $class = 'js-unapproved alternate'; + else $class = 'js-unapproved'; + echo "\n\t
            2. "; ?>

              comment_author_email) { ?>| comment_author_url && 'http://' != $comment->comment_author_url) { ?> | |

              — [ comment_ID.'">' . __('Edit') . ' | '; -echo " comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), js_escape($comment->comment_author)) . "' );\">" . __('Delete ') . " | "; ?> +echo " comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete ') . " | "; ?> comment_post_ID); $post_title = wp_specialchars( $post->post_title, 'double' ); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1d2339397..f7be9e0c7 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -19,11 +19,11 @@ class WP_Scripts { $this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '04162006' ); if ( is_admin() ) { $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' ); - $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3733' ); + $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3850' ); // Make changeset # the correct one $this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' ); $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); - $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3736' ); + $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3850' ); // Make changeset # the correct one $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' ); $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); }