From 9ce8d0f70eba50d4b2e8eb9b929bcb53c006710e Mon Sep 17 00:00:00 2001 From: azaozz Date: Thu, 9 Oct 2008 20:27:39 +0000 Subject: [PATCH] Use no-js reply on error in comment-reply.js, see #7635 git-svn-id: http://svn.automattic.com/wordpress/trunk@9114 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 2 +- wp-includes/js/comment-reply.js | 35 ++++++++++++++++++++------------ wp-includes/script-loader.php | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 427164efcd..96abd111f4 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -910,7 +910,7 @@ function comment_reply_link($args = array(), $comment = null, $post = null) { if ( get_option('comment_registration') && !$user_ID ) $link = '' . $login_text . ''; else - $link = "comment_ID ) ) . "#respond' onclick='addComment.moveForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text"; + $link = "comment_ID ) ) . "#respond' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\")'>$reply_text"; return $before . $link . $after; } diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js index f1945a6ec5..ff992d5258 100644 --- a/wp-includes/js/comment-reply.js +++ b/wp-includes/js/comment-reply.js @@ -1,10 +1,13 @@ addComment = { moveForm : function(commId, parentId, respondId) { - var t = this, div, comm = t.I(commId), respond = t.I(respondId); - + var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'); + + if ( ! comm || ! respond || ! cancel || ! parent ) + return; + t.respondId = respondId; - + if ( ! t.I('wp-temp-form-div') ) { div = document.createElement('div'); div.id = 'wp-temp-form-div'; @@ -13,23 +16,29 @@ addComment = { } comm.parentNode.insertBefore(respond, comm.nextSibling); - - t.I('comment_parent').value = parentId; - - t.I('cancel-comment-reply-link').style.display = ''; - t.I('cancel-comment-reply-link').onclick = function() { + parent.value = parentId; + cancel.style.display = ''; + + cancel.onclick = function() { var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId); - + + if ( ! temp || ! respond ) + return; + t.I('comment_parent').value = '0'; temp.parentNode.insertBefore(respond, temp); temp.parentNode.removeChild(temp); - t.I('cancel-comment-reply-link').style.display = 'none'; - t.I('cancel-comment-reply-link').onclick = null; + this.style.display = 'none'; + this.onclick = null; return false; } - t.I('comment').focus(); + + try { t.I('comment').focus(); } + catch(e) {} + + return false; }, - + I : function(e) { return document.getElementById(e); } diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index ce74e3b180..bb84b67d14 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -139,7 +139,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); - $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081008'); + $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081009'); if ( is_admin() ) { $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );