tbfine(function(){return{init:function(){!function(e){function t(){$new_comm.show(),$new_sucs.show(),e("textarea").each(function(){this.value=""}),o=""}function m(){i>0?($submit.val(i),i--,setTimeout(m,1e3)):($submit.val(r).attr("disabled",!1).fadeTo("slow",1),i=15)}e(".commentlist .url").attr("target","_blank"),e(".comment-user-change").on("click",function(){e(this).hide(),e("#comment-author-info").slideDown(300)});var o,a=1,c=[];c.push(""),$comments=e("#comments-title"),$cancel=e("#cancel-comment-reply-link"),cancel_text=$cancel.text(),$submit=e("#commentform #submit"),$submit.attr("disabled",!1),e(".comt-tips").append('<div class="comt-tip comt-loading">评论提交中...</div><div class="comt-tip comt-error">#</div>'),e(".comt-loading").hide(),e(".comt-error").hide(),$body=e(window.opera?"CSS1Compat"==document.compatMode?"html":"body":"html,body"),e("#commentform").submit(function(){return e(".comt-loading").slideDown(300),$submit.attr("disabled",!0).fadeTo("slow",.5),o&&e("#comment").after('<input type="text" name="edit_id" id="edit_id" value="'+o+'" style="display:none;" />'),e.ajax({url:TBUI.uri+"/action/comment.php",data:e(this).serialize(),type:e(this).attr("method"),error:function(t){e(".comt-loading").slideUp(300),e(".comt-error").slideDown(300).html(t.responseText),setTimeout(function(){$submit.attr("disabled",!1).fadeTo("slow",1),e(".comt-error").slideUp(300)},3e3)},success:function(t){e(".comt-loading").slideUp(300),c.push(e("#comment").val()),e("textarea").each(function(){this.value=""});var i=addComment,r=i.I("cancel-comment-reply-link"),s=i.I("wp-temp-form-div"),l=i.I(i.respondId),d=(i.I("comment_post_ID").value,i.I("comment_parent").value);!o&&$comments.length&&(n=parseInt($comments.text().match(/\d+/)),$comments.text($comments.text().replace(n,n+1))),new_htm='" id="new_comm_'+a+'"></',new_htm="0"==d?'\n<ol style="clear:both;" class="commentlist commentnew'+new_htm+"ol>":'\n<ul class="children'+new_htm+"ul>",ok_htm='\n<span id="success_'+a+'">',ok_htm+="</span><span></span>\n","0"==d&&e("#postcomments .commentlist").length?e("#postcomments .commentlist").before(new_htm):e("#respond").after(new_htm),e(".comment-user-change").show(),e("#comment-author-info").slideUp(),e(".comment-user-avatar-name").length||e(".comt-title img").after('<p class="comment-user-avatar-name"></p>'),e(".comment-user-avatar-name").text(e("#commentform #author").val()),e("#new_comm_"+a).hide().append(t),e("#new_comm_"+a+" li").append(ok_htm),e("#new_comm_"+a).fadeIn(1e3),e("#new_comm_"+a).find(".comt-avatar .avatar").attr("src",e(".commentnew .avatar:last").attr("src")),m(),a++,o="",e("*").remove("#edit_id"),r.style.display="none",r.onclick=null,i.I("comment_parent").value="0",s&&l&&(s.parentNode.insertBefore(l,s),s.parentNode.removeChild(s))}}),!1}),addComment={moveForm:function(n,m,a,i,r){var s,l=this,d=l.I(n),p=l.I(a),u=l.I("cancel-comment-reply-link"),h=l.I("comment_parent"),_=l.I("comment_post_ID");o&&t(),r?(l.I("comment").value=c[r],o=l.I("new_comm_"+r).innerHTML.match(/(comment-)(\d+)/)[2],$new_sucs=e("#success_"+r),$new_sucs.hide(),$new_comm=e("#new_comm_"+r),$new_comm.hide(),$cancel.text("取消编辑")):$cancel.text(cancel_text),l.respondId=a,i=i||!1,l.I("wp-temp-form-div")||((s=document.createElement("div")).id="wp-temp-form-div",s.style.display="none",p.parentNode.insertBefore(s,p)),d?d.parentNode.insertBefore(p,d.nextSibling):(temp=l.I("wp-temp-form-div"),l.I("comment_parent").value="0",temp.parentNode.insertBefore(p,temp),temp.parentNode.removeChild(temp)),$body.animate({scrollTop:e("#respond").offset().top-180},400),_&&i&&(_.value=i),h.value=m,u.style.display="",u.onclick=function(){o&&t();var e=addComment,n=e.I("wp-temp-form-div"),m=e.I(e.respondId);return e.I("comment_parent").value="0",n&&m&&(n.parentNode.insertBefore(m,n),n.parentNode.removeChild(n)),this.style.display="none",this.onclick=null,!1};try{l.I("comment").focus()}catch(e){}return!1},I:function(e){return document.getElementById(e)}},e(".comment-reply-link").on("click",function(){var t=e(this);if(!t.attr("onclick")&&t.data("belowelement")&&t.data("commentid")&&t.data("respondelement")&&t.data("postid"))return addComment.moveForm(t.data("belowelement"),t.data("commentid"),t.data("respondelement"),t.data("postid"))});var i=15,r=$submit.val()}(jQuery)}}});