No jQuery requirement for comment-reply.js, see #7635

git-svn-id: http://svn.automattic.com/wordpress/trunk@9113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-10-09 11:11:56 +00:00
parent 2bd7d9960d
commit c506412ad6
3 changed files with 38 additions and 15 deletions

View File

@ -910,7 +910,7 @@ function comment_reply_link($args = array(), $comment = null, $post = null) {
if ( get_option('comment_registration') && !$user_ID ) if ( get_option('comment_registration') && !$user_ID )
$link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>';
else else
$link = "<a rel='nofollow' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#respond' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text</a>"; $link = "<a rel='nofollow' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#respond' onclick='addComment.moveForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text</a>";
return $before . $link . $after; return $before . $link . $after;
} }
@ -938,7 +938,7 @@ function cancel_comment_reply_link($text = '') {
*/ */
function comment_parent_field() { function comment_parent_field() {
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
echo "<input type='hidden' name='comment_parent' id='comment-parent' value='$replytoid' />\n"; echo "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
} }
/** /**

View File

@ -1,13 +1,36 @@
function moveAddCommentForm(commId, parentId, respondId) { addComment = {
var div = document.createElement('div'); moveForm : function(commId, parentId, respondId) {
jQuery("#"+respondId).before( jQuery(div).attr('id', 'wp-temp-form-div').hide() ).appendTo("#"+commId); var t = this, div, comm = t.I(commId), respond = t.I(respondId);
jQuery("#comment-parent").val(parentId);
jQuery("#cancel-comment-reply-link").show().click(function(){ t.respondId = respondId;
jQuery("#comment-parent").val("0");
jQuery('#wp-temp-form-div').after( jQuery("#"+respondId) ).remove(); if ( ! t.I('wp-temp-form-div') ) {
jQuery(this).hide(); div = document.createElement('div');
return false; div.id = 'wp-temp-form-div';
}); div.style.display = 'none';
jQuery("#comment").focus(); respond.parentNode.insertBefore(div, respond);
} }
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() {
var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
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;
return false;
}
t.I('comment').focus();
},
I : function(e) {
return document.getElementById(e);
}
}

View File

@ -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-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( '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', array('jquery'), '20081009'); $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20081008');
if ( is_admin() ) { if ( is_admin() ) {
$scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' ); $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );