评论区硬切换实现

This commit is contained in:
kate522 committed 2026-08-30 17:34:29 +08:00
1 parent ed914d2eec
commit b8ef4d81a4
32 files changed
+946 -1008

No files matched your search

+10 -5
View File
@@ -273,20 +273,25 @@
// §10.10a — 拦截 vendor 评论脚本 & 解绑 vendor ajax 委托
// ══════════════════════════════════════════════════════════════
// vendor 链路:loader.js(tbquire,改造版 RequireJS)→ main.min.js 检测到
// #commentform/#postcomments 即 tbquire(["comment"]) 懒加载 comment.min.js。
// #commentform/#postcomments 即 tbquire(["comment"]) 懒加载 comment.min.js;
// 检测到 .dropdown-code/.dropdown-image 即 tbquire(["input-expand"])。
// AKSRT 自有评论脚本(comments/comment-tools/comment-fixed-input/
// comment-move-form/comment-ajax)已承担全部行为,vendor comment.min.js 的
// 7 条 body 委托会双路触发(提交 legacy action=submit_comment 无处理器,
// 即控制台「ajax请求错误」400 "0" 的来源;回复/排序/分页同理)。
// 即控制台「ajax请求错误」400 "0" 的来源;回复/排序/分页同理);
// vendor input-expand.min.js(表情/快捷回复旧链路,源文件已删除)同理不再下载。
//
// 双层防御:
// 1) tbfine 预注册空 'comment' 模块 → tbquire 不再下载 comment.min.js;
// 1) tbfine 预注册空 'comment'/'input-expand' 模块 → tbquire 不再下载;
// 2) 若模块抢在注册前加载,退化为对 7 条委托做幂等 .off。
function stubVendorCommentModule() {
if (!(window.tbfine && window.tbquire && window.tbquire.defined)) return false;
try {
if (window.tbquire.defined('comment')) return true;
window.tbfine('comment', [], function () { return {}; });
['comment', 'input-expand'].forEach(function (name) {
if (!window.tbquire.defined(name)) {
window.tbfine(name, [], function () { return {}; });
}
});
return true;
} catch (e) {
return false;
+10 -5
View File
@@ -547,20 +547,25 @@ tbquire.config({
// §10.10a — 拦截 vendor 评论脚本 & 解绑 vendor ajax 委托
// ══════════════════════════════════════════════════════════════
// vendor 链路:loader.js(tbquire,改造版 RequireJS)→ main.min.js 检测到
// #commentform/#postcomments 即 tbquire(["comment"]) 懒加载 comment.min.js。
// #commentform/#postcomments 即 tbquire(["comment"]) 懒加载 comment.min.js;
// 检测到 .dropdown-code/.dropdown-image 即 tbquire(["input-expand"])。
// AKSRT 自有评论脚本(comments/comment-tools/comment-fixed-input/
// comment-move-form/comment-ajax)已承担全部行为,vendor comment.min.js 的
// 7 条 body 委托会双路触发(提交 legacy action=submit_comment 无处理器,
// 即控制台「ajax请求错误」400 "0" 的来源;回复/排序/分页同理)。
// 即控制台「ajax请求错误」400 "0" 的来源;回复/排序/分页同理);
// vendor input-expand.min.js(表情/快捷回复旧链路,源文件已删除)同理不再下载。
//
// 双层防御:
// 1) tbfine 预注册空 'comment' 模块 → tbquire 不再下载 comment.min.js;
// 1) tbfine 预注册空 'comment'/'input-expand' 模块 → tbquire 不再下载;
// 2) 若模块抢在注册前加载,退化为对 7 条委托做幂等 .off。
function stubVendorCommentModule() {
if (!(window.tbfine && window.tbquire && window.tbquire.defined)) return false;
try {
if (window.tbquire.defined('comment')) return true;
window.tbfine('comment', [], function () { return {}; });
['comment', 'input-expand'].forEach(function (name) {
if (!window.tbquire.defined(name)) {
window.tbfine(name, [], function () { return {}; });
}
});
return true;
} catch (e) {
return false;
+21 -10
View File
@@ -1,5 +1,5 @@
/**
* Comment expand tools — legacy-style shortcode inserts ([code] [img=] quick).
* Comment expand tools — legacy-style shortcode inserts ([code] [img=]).
*/
(function () {
'use strict';
@@ -39,6 +39,26 @@
}
document.addEventListener('click', function (e) {
var linkBtn = e.target && e.target.closest ? e.target.closest('.input-link-submit') : null;
if (linkBtn) {
e.preventDefault();
var lbox = linkBtn.closest('.dropdown-link');
var lta = lbox ? lbox.querySelector('textarea.link-textarea') : null;
var url = lta ? (lta.value || '').trim() : '';
if (!/^https?:\/\/\S+$/i.test(url)) {
notyf('请输入有效链接地址', 'warning');
return;
}
var ltext = lbox ? (lbox.querySelector('.link-text') || {}).value || '' : '';
insertAtCursor(findTextarea(linkBtn), '[link=' + url + ']' + (ltext.trim() || url) + '[/link]');
if (lta) lta.value = '';
var lt = lbox ? lbox.querySelector('.link-text') : null;
if (lt) lt.value = '';
var lw = linkBtn.closest('span.dropup');
if (lw) lw.classList.remove('open');
return;
}
var codeBtn = e.target && e.target.closest ? e.target.closest('.input-code-submit') : null;
if (codeBtn) {
e.preventDefault();
@@ -96,15 +116,6 @@
fileInput.click();
return;
}
var q = e.target && e.target.closest ? e.target.closest('.quick-reply-item') : null;
if (q) {
e.preventDefault();
var phrase = q.getAttribute('data-text') || q.textContent || '';
insertAtCursor(findTextarea(q), phrase);
var qw = q.closest('span.dropup');
if (qw) qw.classList.remove('open');
}
});
document.addEventListener('keydown', function (e) {
-343
View File
@@ -1,343 +0,0 @@
jQuery.fn.FixedInput = function (action) {
var _this = jQuery(this);
if (!_this.attr('on-start')) {
_this
.on('click', '.fixed-body', function () {
_this.FixedInput('hide');
})
.attr('on-start', true);
}
switch (action) {
case 'show':
_this.addClass('show');
return setTimeout(() => {
jQuery(_this.find('textarea,input')[0]).focus();
}, 100);
case 'hide':
_this.find('#cancel-comment-reply-link').click();
_this.find('input,textarea').blur();
_this.find('.dropup').removeClass('open');
return _this.removeClass('show');
default:
}
};
//移动端浮动的input|暂时仅用在评论
_win.bd.on('click', '[fixed-input]', function () {
var _this = jQuery(this);
// var _input = jQuery(_this.attr('data-input'));
var _fixed = jQuery(_this.attr('fixed-input'));
scrollTopTo('#comments');
_fixed.FixedInput('show');
//_input.length && _input.focus();
});
var $comments = jQuery('#comments-title');
var $cancel = jQuery('#cancel-comment-reply-link');
var $author = jQuery('#comment-user-info');
var $submit = jQuery('#commentform #submit');
var $com_ajax_url = _win.ajax_url;
var $com_list = jQuery('#postcomments .commentlist');
//评论ajax翻页
_win.bd.on('click', '.commentlist .pagenav a,.comment-orderby', function () {
var _this = jQuery(this);
jQuery('#cancel-comment-reply-link').click();
if (_this.hasClass('pag-jump')) {
_this.addClass('ajax-next');
return;
}
var ajax_replace = !_this.attr('no-replace');
return post_ajax(jQuery(this), '.commentlist', '.commentlist', '.comment', '', '.pagenav', '', '', ajax_replace);
});
//编辑按钮,回复
_win.bd.on('click', '.comment-edit-link,.comment-reply-link', function () {
var _this = jQuery(this),
commentid = _this.attr('data-commentid');
var is_edit = _this.hasClass('comment-edit-link');
return addComment.moveForm(_this, 'div-comment-' + commentid, commentid, 'respond', _this.attr('data-postid'), is_edit), scrollTopTo(jQuery('#div-comment-' + commentid), -10), !1;
});
//回车提交
_win.bd.on('keydown', '#comment', function (e) {
var keycode = e.which || e.keyCode;
if ((e.metaKey || e.ctrlKey) && keycode == 13) {
jQuery(this).closest('#commentform').find('#submit').click();
}
});
//删除评论
_win.bd.on('click', '.comment-trash-link', function () {
var _this = jQuery(this);
var commentid = _this.attr('data-commentid');
var trash_data = {
action: 'trash_comment',
comment_id: commentid,
_wpnonce: _this.attr('data-nonce'),
};
if (confirm(aksrt__('comment_confirm_delete')) == 1) {
aksrt_ajax(
_this,
trash_data,
function (n) {
n.error ||
jQuery('#comment-' + commentid)
.slideUp()
.delay(1000, function () {
jQuery(this).remove();
});
},
aksrt__('processing')
);
}
});
//审核评论
_win.bd.on('click', '.comment-approve-link', function () {
var _this = jQuery(this);
var commentid = _this.attr('data-commentid');
var trash_data = {
action: 'approve_comment',
comment_id: commentid,
_wpnonce: _this.attr('data-nonce'),
};
var reply = jQuery('#div-comment-' + commentid).find('.reply-link');
aksrt_ajax(_this, trash_data, function (n) {
if (!n.error) {
var _text = n.status == 'hold' ? aksrt__('comment_approve') : aksrt__('comment_reject');
var _class = n.status == 'hold' ? 'approve' : 'unapprove';
var _badg = n.status == 'hold' ? '<span class="badg c-red badg-sm">' + aksrt__('comment_pending_review') + '</span>' : '';
if (n.status == 'hold') {
reply.remove();
} else {
reply.length || _this.parents('.dropdown').before('<span class="reply-link"><a class="comment-reply-link" data-commentid="' + commentid + '" href="javascript:;">' + aksrt__('comment_reply') + '</a></span>');
}
jQuery('#div-comment-' + commentid)
.find('.badge-approve')
.html(_badg);
_this.removeClass('approve unapprove').addClass(_class).find('text').html(_text);
}
});
});
function htmlEscapes(val) {
var htmlEscapes = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;',
};
var a = val.replace(/[&<>"']/g, function (match) {
return htmlEscapes[match];
});
return a;
}
function htmlUnescapes(val) {
var htmlUnescapes = {
'&amp;': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&#039;': "'",
};
var a = val.replace(/&(amp|lt|gt|quot|#039);/g, function (match) {
return htmlUnescapes[match];
});
return a;
}
//提交评论
_win.bd.on('click', '#commentform #submit', function () {
var _this = jQuery(this);
var _form = _this.parents('#commentform');
var inputs = _form.serializeObject();
if ($author.length && $author.attr('require_name_email')) {
if (inputs.author.length < 2 || inputs.email.length < 4) {
return notyf(aksrt__('comment_enter_name_email'), 'warning'), $author.addClass('open').find('[name="author"]').focus(), !1;
}
if (!is_mail(inputs.email)) {
return notyf(aksrt__('comment_email_invalid'), 'warning'), $author.addClass('open').find('[name="email"]').focus(), !1;
}
}
if (inputs.comment.length < 4) {
return notyf(aksrt__('comment_too_short'), 'warning'), jQuery('#comment').focus(), !1;
}
inputs.comment = htmlEscapes(inputs.comment);
inputs.action = 'submit_comment';
aksrt_ajax(_this, inputs, function (n) {
var data = n.html;
if (!n.error && data) {
if (inputs.edit_comment_ID) {
//编辑评论后提交
$cancel.click();
jQuery('#comment-content-' + inputs.edit_comment_ID).html(data);
} else {
//新建评论
var data = data.replace(/class="comment/, 'style="display:none;" class="comment ajax-comment');
var respond = jQuery('#respond');
var $com_list = jQuery('#postcomments .commentlist');
var is_comment_parent = respond.parent().parent('.comment');
if (is_comment_parent.length) {
var _children = is_comment_parent.find('>.children');
if (_children.length) {
_children.prepend(data);
} else {
is_comment_parent.append('<ul class="children">' + data + '</ul>');
}
} else {
if (!$com_list.length) {
respond.after('<div id="postcomments"><ol class="commentlist list-unstyled">' + data + '</ol></div>');
} else {
var $order = jQuery('#postcomments .commentlist>.comment-filter');
if ($order.length) {
$order.after(data);
} else {
$com_list.prepend(data);
}
}
}
if (jQuery('[reply-show]').length && n.comment) {
if (~~n.comment.comment_approved > 0) {
var hash = jQuery(jQuery('[reply-show]')[0]).attr('reload-hash'); //跳转
if (hash) {
window.location.hash = hash;
}
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(n.wait_time);
jQuery('#comment').val('');
jQuery('#respond').FixedInput('hide');
}
});
return false;
});
var addComment = {
moveForm: function (_this, commId, parentId, respondId, postId, num) {
var t = this,
div,
comm = t.I(commId),
respond = t.I(respondId),
cancel = t.I('cancel-comment-reply-link'),
parent = t.I('comment_parent'),
post = t.I('comment_post_ID');
var action_text_r = jQuery('#' + respondId + ' .action-text');
jQuery('.comment-footer').show();
if (num) {
var $submit_html = $submit.html();
action_text_r.html(aksrt__('comment_edit_content'));
t.I('comment').value = ''; //清空内容
jQuery('#comment_parent').attr('name', 'edit_comment_ID');
$submit.attr('disabled', true).html('<i class="loading mr6"></i><span>' + aksrt__('loading') + '</span>');
jQuery('#comment').attr('disabled', true).val(aksrt__('comment_fetching_content'));
jQuery('#' + commId)
.find('.comment-footer')
.hide();
var data = {
action: 'get_comment',
comment_id: parentId,
};
aksrt_ajax(
_this,
data,
function (n) {
n.error && $cancel.click();
$submit.html($submit_html).attr('disabled', false);
jQuery('#comment').attr('disabled', false).val(htmlUnescapes(n.comment_content)).focus();
},
'stop'
);
}
action_text_r.html(_this.attr('data-replyto'));
t.respondId = respondId;
postId = postId || false;
if (!t.I('wp-temp-form-div')) {
div = document.createElement('div');
div.id = 'wp-temp-form-div';
div.style.display = 'none';
respond.parentNode.insertBefore(div, respond);
}
!comm ? ((temp = t.I('wp-temp-form-div')), (t.I('comment_parent').value = '0'), temp.parentNode.insertBefore(respond, temp), temp.parentNode.removeChild(temp)) : comm.parentNode.insertBefore(respond, comm.nextSibling);
// pcsheight()
if (post && postId) post.value = postId;
parent.value = parentId;
cancel.style.display = '';
cancel.onclick = function () {
var t = addComment,
temp = t.I('wp-temp-form-div'),
respond = t.I(t.respondId);
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('#' + respondId).removeClass('show');
}, 10);
action_text_r.html('');
if (temp && respond) {
temp.parentNode.insertBefore(respond, temp);
temp.parentNode.removeChild(temp);
}
this.style.display = 'none';
this.onclick = null;
return false;
};
try {
setTimeout(function () {
jQuery('#' + respondId).FixedInput('show');
}, 10);
} catch (e) {}
return false;
},
I: function (e) {
return document.getElementById(e);
},
};
//等待
function wait_for($time) {
var wait = $time || 15;
var $submit_html = $submit.html();
function wait_ing() {
if (wait > 0) {
$submit.html('<div style="width:55px;"><i class="loading mr10"></i>' + wait + '</div>').attr('disabled', true);
wait--;
setTimeout(wait_ing, 1000);
} else {
$submit.html($submit_html).attr('disabled', false);
wait = 15;
}
}
wait_ing();
}
-1
View File
@@ -1 +0,0 @@
jQuery.fn.FixedInput=function(action){var _this=jQuery(this);switch(_this.attr("on-start")||_this.on("click",".fixed-body",function(){_this.FixedInput("hide")}).attr("on-start",!0),action){case"show":return _this.addClass("show"),setTimeout(()=>{jQuery(_this.find("textarea,input")[0]).focus()},100);case"hide":return _this.find("#cancel-comment-reply-link").click(),_this.find("input,textarea").blur(),_this.find(".dropup").removeClass("open"),_this.removeClass("show");default:}},_win.bd.on("click","[fixed-input]",function(){var _this=jQuery(this),_fixed=jQuery(_this.attr("fixed-input"));scrollTopTo("#comments"),_fixed.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 _this=jQuery(this);if(jQuery("#cancel-comment-reply-link").click(),_this.hasClass("pag-jump")){_this.addClass("ajax-next");return}var ajax_replace=!_this.attr("no-replace");return post_ajax(jQuery(this),".commentlist",".commentlist",".comment","",".pagenav","","",ajax_replace)}),_win.bd.on("click",".comment-edit-link,.comment-reply-link",function(){var _this=jQuery(this),commentid=_this.attr("data-commentid"),is_edit=_this.hasClass("comment-edit-link");return addComment.moveForm(_this,"div-comment-"+commentid,commentid,"respond",_this.attr("data-postid"),is_edit),scrollTopTo(jQuery("#div-comment-"+commentid),-10),!1}),_win.bd.on("keydown","#comment",function(e){var keycode=e.which||e.keyCode;(e.metaKey||e.ctrlKey)&&keycode==13&&jQuery(this).closest("#commentform").find("#submit").click()}),_win.bd.on("click",".comment-trash-link",function(){var _this=jQuery(this),commentid=_this.attr("data-commentid"),trash_data={action:"trash_comment",comment_id:commentid,_wpnonce:_this.attr("data-nonce")};confirm(aksrt__("comment_confirm_delete"))==1&&aksrt_ajax(_this,trash_data,function(n){n.error||jQuery("#comment-"+commentid).slideUp().delay(1e3,function(){jQuery(this).remove()})},aksrt__("processing"))}),_win.bd.on("click",".comment-approve-link",function(){var _this=jQuery(this),commentid=_this.attr("data-commentid"),trash_data={action:"approve_comment",comment_id:commentid,_wpnonce:_this.attr("data-nonce")},reply=jQuery("#div-comment-"+commentid).find(".reply-link");aksrt_ajax(_this,trash_data,function(n){if(!n.error){var _text=n.status=="hold"?aksrt__("comment_approve"):aksrt__("comment_reject"),_class=n.status=="hold"?"approve":"unapprove",_badg=n.status=="hold"?'<span class="badg c-red badg-sm">'+aksrt__("comment_pending_review")+"</span>":"";n.status=="hold"?reply.remove():reply.length||_this.parents(".dropdown").before('<span class="reply-link"><a class="comment-reply-link" data-commentid="'+commentid+'" href="javascript:;">'+aksrt__("comment_reply")+"</a></span>"),jQuery("#div-comment-"+commentid).find(".badge-approve").html(_badg),_this.removeClass("approve unapprove").addClass(_class).find("text").html(_text)}})});function htmlEscapes(val){var htmlEscapes2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"},a=val.replace(/[&<>"']/g,function(match){return htmlEscapes2[match]});return a}function htmlUnescapes(val){var htmlUnescapes2={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#039;":"'"},a=val.replace(/&(amp|lt|gt|quot|#039);/g,function(match){return htmlUnescapes2[match]});return a}_win.bd.on("click","#commentform #submit",function(){var _this=jQuery(this),_form=_this.parents("#commentform"),inputs=_form.serializeObject();if($author.length&&$author.attr("require_name_email")){if(inputs.author.length<2||inputs.email.length<4)return notyf(aksrt__("comment_enter_name_email"),"warning"),$author.addClass("open").find('[name="author"]').focus(),!1;if(!is_mail(inputs.email))return notyf(aksrt__("comment_email_invalid"),"warning"),$author.addClass("open").find('[name="email"]').focus(),!1}return inputs.comment.length<4?(notyf(aksrt__("comment_too_short"),"warning"),jQuery("#comment").focus(),!1):(inputs.comment=htmlEscapes(inputs.comment),inputs.action="submit_comment",aksrt_ajax(_this,inputs,function(n){var data=n.html;if(!n.error&&data){if(inputs.edit_comment_ID)$cancel.click(),jQuery("#comment-content-"+inputs.edit_comment_ID).html(data);else{var data=data.replace(/class="comment/,'style="display:none;" class="comment ajax-comment'),respond=jQuery("#respond"),$com_list2=jQuery("#postcomments .commentlist"),is_comment_parent=respond.parent().parent(".comment");if(is_comment_parent.length){var _children=is_comment_parent.find(">.children");_children.length?_children.prepend(data):is_comment_parent.append('<ul class="children">'+data+"</ul>")}else if(!$com_list2.length)respond.after('<div id="postcomments"><ol class="commentlist list-unstyled">'+data+"</ol></div>");else{var $order=jQuery("#postcomments .commentlist>.comment-filter");$order.length?$order.after(dLine truncated
-101
View File
@@ -1,101 +0,0 @@
//内容追加到编辑框
function grin(_this, val, fun) {
var textarea = _this.parents('form').find('textarea.grin');
var t_val = textarea.val();
textarea
.val(t_val + val)
.focus()
.click();
jQuery.isFunction(fun) && fun(_this, val);
}
//编辑框添加代码
_win.bd.on('click', '.dropdown-code [type="submit"]', function () {
var _this = jQuery(this);
var val = _this.parents('.dropdown-code').find('textarea').val();
if (val.length < 2) return void notyf(aksrt__('enter_code'), 'warning');
val = '[code]\n' + val + '\n[/code]\n';
return grin(_this, val);
});
//编辑框添加图片
_win.bd.on('click', '.dropdown-image [type="submit"]', function () {
var _this = jQuery(this);
var val = _this.parents('.dropdown-image').find('textarea').val();
if (val.length < 6) return void notyf(aksrt__('enter_valid_image_url'), 'warning');
val = '[img=' + val + ']\n';
return grin(_this, val);
});
//上传图片
_win.bd.on('miniuploaded', '.input-expand-upload', function (a, data) {
var img = '[img=' + data.img_url + ']\n';
return grin(jQuery(this), img);
});
//按钮展开
_win.bd.on('click', '.btn-input-expand', function () {
return jQuery(this).parent().toggleClass('open').trigger('toggleClass'), !1;
});
//编辑框添加链接
_win.bd.on('click', '.dropdown-link [type="submit"]', function () {
var _this = jQuery(this);
var val = _this.closest('.dropdown-link').find('textarea').val();
if (val.length < 6) return void notyf(aksrt__('enter_valid_link_url'), 'warning');
//判断URL合法性
if (!aksrt_is_url(val)) {
return void notyf(aksrt__('enter_valid_link_url'), 'warning');
}
var target = '';
if (_this.closest('.dropdown-link').find('input[name="target"]').is(':checked')) {
target = 'target=_blank';
}
var text = _this.closest('.dropdown-link').find('.link-text').val() || val;
var link_val = '[link=' + val + ' ' + target + ']' + text + '[/link]';
return grin(_this, link_val);
});
//保存我的快捷回复后,自动更新
_win.bd.on('aksrt_ajax.success', '.user-quick-often-save-btn', function (e, data) {
if (data.item) {
jQuery('.quick-reply-myitem-box').html(data.item);
}
});
//快捷回复;选择内容,弹出操作按钮
_win.bd.on('click', '.quick-reply-item', function () {
var _this = jQuery(this);
var quick_reply_action = 'quick-reply-action';
var quick_active = 'quick-active';
_this.siblings().removeClass(quick_active);
_this
.parent()
.find('.' + quick_reply_action)
.remove();
_this
.data('quick-reply', _this.text())
.addClass('quick-active')
.append('<div class="' + quick_reply_action + '"><div class="modal-buts but-average"><button type="button" class="but quick-reply-btn-insert" href="javascript:;">' + aksrt__('insert') + '</button><button type="button" class="but c-blue padding-lg quick-reply-btn-send">' + aksrt__('send') + '</button></div></div>');
});
//快捷回复:插入内容或发送
_win.bd.on('click', '.quick-reply-action button', function () {
var _this = jQuery(this);
var form = _this.closest('form'); //唯一的表单
var quick_reply = _this.parents('.quick-reply-item').data('quick-reply');
var textarea = form.find('textarea.grin');
textarea.val(quick_reply);
if (_this.hasClass('quick-reply-btn-send')) {
form.find('.input-expand-submit').click();
} else {
textarea.focus();
}
});
-6
View File
@@ -1,6 +0,0 @@
function grin(n,t,i){var e=n.parents("form").find("textarea.grin"),r=e.val();e.val(r+t).focus().click(),jQuery.isFunction(i)&&i(n,t)}_win.bd.on("click",'.dropdown-code [type="submit"]',function(){var n=jQuery(this),t=n.parents(".dropdown-code").find("textarea").val();return t.length<2?void notyf(aksrt__("enter_code"),"warning"):(t=`[code]
`+t+`
[/code]
`,grin(n,t))}),_win.bd.on("click",'.dropdown-image [type="submit"]',function(){var n=jQuery(this),t=n.parents(".dropdown-image").find("textarea").val();return t.length<6?void notyf(aksrt__("enter_valid_image_url"),"warning"):(t="[img="+t+`]
`,grin(n,t))}),_win.bd.on("miniuploaded",".input-expand-upload",function(n,t){var i="[img="+t.img_url+`]
`;return grin(jQuery(this),i)}),_win.bd.on("click",".btn-input-expand",function(){return jQuery(this).parent().toggleClass("open").trigger("toggleClass"),!1}),_win.bd.on("click",'.dropdown-link [type="submit"]',function(){var n=jQuery(this),t=n.closest(".dropdown-link").find("textarea").val();if(t.length<6||!aksrt_is_url(t))return void notyf(aksrt__("enter_valid_link_url"),"warning");var i="";n.closest(".dropdown-link").find('input[name="target"]').is(":checked")&&(i="target=_blank");var e=n.closest(".dropdown-link").find(".link-text").val()||t,r="[link="+t+" "+i+"]"+e+"[/link]";return grin(n,r)}),_win.bd.on("aksrt_ajax.success",".user-quick-often-save-btn",function(n,t){t.item&&jQuery(".quick-reply-myitem-box").html(t.item)}),_win.bd.on("click",".quick-reply-item",function(){var n=jQuery(this),t="quick-reply-action",i="quick-active";n.siblings().removeClass(i),n.parent().find("."+t).remove(),n.data("quick-reply",n.text()).addClass("quick-active").append('<div class="'+t+'"><div class="modal-buts but-average"><button type="button" class="but quick-reply-btn-insert" href="javascript:;">'+aksrt__("insert")+'</button><button type="button" class="but c-blue padding-lg quick-reply-btn-send">'+aksrt__("send")+"</button></div></div>")}),_win.bd.on("click",".quick-reply-action button",function(){var n=jQuery(this),t=n.closest("form"),i=n.parents(".quick-reply-item").data("quick-reply"),e=t.find("textarea.grin");e.val(i),n.hasClass("quick-reply-btn-send")?t.find(".input-expand-submit").click():e.focus()});