2 lines
6.8 KiB
JavaScript
2 lines
6.8 KiB
JavaScript
function htmlEscapes(t){var e={"&":"&","<":"<",">":">",'"':""","'":"'"},n=t.replace(/[&<>"']/g,function(t){return e[t]});return n}function htmlUnescapes(t){var e={"&":"&","<":"<",">":">",""":'"',"'":"'"},n=t.replace(/&(amp|lt|gt|quot|#039);/g,function(t){return e[t]});return n}function wait_for(t){function e(){n>0?($submit.html('<div style="width:55px;"><i class="loading mr10"></i>'+n+"</div>").attr("disabled",!0),n--,setTimeout(e,1e3)):($submit.html(o).attr("disabled",!1),n=15)}var n=t||15,o=$submit.html();e()}jQuery.fn.FixedInput=function(t){var e=jQuery(this);switch(e.attr("on-start")||e.on("click",".fixed-body",function(){e.FixedInput("hide")}).attr("on-start",!0),t){case"show":return e.addClass("show"),setTimeout(()=>{jQuery(e.find("textarea,input")[0]).focus()},100);case"hide":return e.find("#cancel-comment-reply-link").click(),e.find("input,textarea").blur(),e.find(".dropup").removeClass("open"),e.removeClass("show")}},_win.bd.on("click","[fixed-input]",function(){var t=jQuery(this),e=jQuery(t.attr("fixed-input"));scrollTopTo("#comments"),e.FixedInput("show")});var $comments=jQuery("#comments-title"),$cancel=jQuery("#cancel-comment-reply-link"),$author=jQuery("#comment-user-info"),$submit=jQuery("#commentform #submit"),$com_ajax_url=_win.ajax_url,$com_list=jQuery("#postcomments .commentlist");_win.bd.on("click",".commentlist .pagenav a,.comment-orderby",function(){var t=jQuery(this);if(jQuery("#cancel-comment-reply-link").click(),!t.hasClass("pag-jump")){var e=!t.attr("no-replace");return post_ajax(jQuery(this),".commentlist",".commentlist",".comment","",".pagenav","","",e)}t.addClass("ajax-next")}),_win.bd.on("click",".comment-edit-link,.comment-reply-link",function(){var t=jQuery(this),e=t.attr("data-commentid"),n=t.hasClass("comment-edit-link");return addComment.moveForm(t,"div-comment-"+e,e,"respond",t.attr("data-postid"),n),scrollTopTo(jQuery("#div-comment-"+e),-10),!1}),_win.bd.on("keydown","#comment",function(t){var e=t.which||t.keyCode;(t.metaKey||t.ctrlKey)&&13==e&&jQuery(this).closest("#commentform").find("#submit").click()}),_win.bd.on("click",".comment-trash-link",function(){var t=jQuery(this),e=t.attr("data-commentid"),n={action:"trash_comment",comment_id:e,_wpnonce:t.attr("data-nonce")};1==confirm(aksrt__("comment_confirm_delete"))&&aksrt_ajax(t,n,function(t){t.error||jQuery("#comment-"+e).slideUp().delay(1e3,function(){jQuery(this).remove()})},aksrt__("processing"))}),_win.bd.on("click",".comment-approve-link",function(){var t=jQuery(this),e=t.attr("data-commentid"),n={action:"approve_comment",comment_id:e,_wpnonce:t.attr("data-nonce")},o=jQuery("#div-comment-"+e).find(".reply-link");aksrt_ajax(t,n,function(n){if(!n.error){var m="hold"==n.status?aksrt__("comment_approve"):aksrt__("comment_reject"),a="hold"==n.status?"approve":"unapprove",i="hold"==n.status?'<span class="badg c-red badg-sm">'+aksrt__("comment_pending_review")+"</span>":"";"hold"==n.status?o.remove():o.length||t.parents(".dropdown").before('<span class="reply-link"><a class="comment-reply-link" data-commentid="'+e+'" href="javascript:;">'+aksrt__("comment_reply")+"</a></span>"),jQuery("#div-comment-"+e).find(".badge-approve").html(i),t.removeClass("approve unapprove").addClass(a).find("text").html(m)}})}),_win.bd.on("click","#commentform #submit",function(){var t=jQuery(this),e=t.parents("#commentform"),n=e.serializeObject();if($author.length&&$author.attr("require_name_email")){if(n.author.length<2||n.email.length<4)return notyf(aksrt__("comment_enter_name_email"),"warning"),$author.addClass("open").find('[name="author"]').focus(),!1;if(!is_mail(n.email))return notyf(aksrt__("comment_email_invalid"),"warning"),$author.addClass("open").find('[name="email"]').focus(),!1}return n.comment.length<4?(notyf(aksrt__("comment_too_short"),"warning"),jQuery("#comment").focus(),!1):(n.comment=htmlEscapes(n.comment),n.action="submit_comment",aksrt_ajax(t,n,function(t){var e=t.html;if(!t.error&&e){if(n.edit_comment_ID)$cancel.click(),jQuery("#comment-content-"+n.edit_comment_ID).html(e);else{e=e.replace(/class="comment/,'style="display:none;" class="comment ajax-comment');var o=jQuery("#respond"),m=jQuery("#postcomments .commentlist"),a=o.parent().parent(".comment");if(a.length){var i=a.find(">.children");i.length?i.prepend(e):a.append('<ul class="children">'+e+"</ul>")}else if(m.length){var c=jQuery("#postcomments .commentlist>.comment-filter");c.length?c.after(e):m.prepend(e)}else o.after('<div id="postcomments"><ol class="commentlist list-unstyled">'+e+"</ol></div>");if(jQuery("[reply-show]").length&&t.comment)if(~~t.comment.comment_approved>0){var r=jQuery(jQuery("[reply-show]")[0]).attr("reload-hash");r&&(window.location.hash=r),window.location.reload()}else setTimeout(function(){notyf(aksrt__("comment_hidden_after_review"),"warning")},200);$cancel.click(),jQuery("#postcomments .ajax-comment").slideDown(200).removeClass("ajax-comment"),jQuery("#postcomments .comment-null").slideUp(200)}auto_fun(),wait_for(t.wait_time),jQuery("#comment").val(""),jQuery('[name="canvas_yz"]').val(""),jQuery(".imagecaptcha").click(),jQuery("#respond").FixedInput("hide")}}),!1)});var addComment={moveForm:function(t,e,n,o,m,a){var i,c=this,r=c.I(e),s=c.I(o),l=c.I("cancel-comment-reply-link"),d=c.I("comment_parent"),p=c.I("comment_post_ID"),u=jQuery("#"+o+" .action-text");if(jQuery(".comment-footer").show(),a){var _=$submit.html();u.html(aksrt__("comment_edit_content")),c.I("comment").value="",jQuery("#comment_parent").attr("name","edit_comment_ID"),$submit.attr("disabled",!0).html('<i class="loading mr6"></i><span>'+aksrt__("loading")+"</span>"),jQuery("#comment").attr("disabled",!0).val(aksrt__("comment_fetching_content")),jQuery("#"+e).find(".comment-footer").hide();var f={action:"get_comment",comment_id:n};aksrt_ajax(t,f,function(t){t.error&&$cancel.click(),$submit.html(_).attr("disabled",!1),jQuery("#comment").attr("disabled",!1).val(htmlUnescapes(t.comment_content)).focus()},"stop")}u.html(t.attr("data-replyto")),c.respondId=o,m=m||!1,c.I("wp-temp-form-div")||(i=document.createElement("div"),i.id="wp-temp-form-div",i.style.display="none",s.parentNode.insertBefore(i,s)),r?r.parentNode.insertBefore(s,r.nextSibling):(temp=c.I("wp-temp-form-div"),c.I("comment_parent").value="0",temp.parentNode.insertBefore(s,temp),temp.parentNode.removeChild(temp)),p&&m&&(p.value=m),d.value=n,l.style.display="",l.onclick=function(){var t=addComment,e=t.I("wp-temp-form-div"),n=t.I(t.respondId);return jQuery("#comment_parent").attr("name","comment_parent"),t.I("comment_parent").value="0",jQuery(".comment-footer").show(),jQuery("#comment").val("").trigger("input"),setTimeout(function(){jQuery("#"+o).removeClass("show")},10),u.html(""),e&&n&&(e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e)),this.style.display="none",this.onclick=null,!1};try{setTimeout(function(){jQuery("#"+o).FixedInput("show")},10)}catch(t){}return!1},I:function(t){return document.getElementById(t)}};
|