style: 优化页脚图片尺寸及垂直居中排版对齐
This commit is contained in:
@@ -2150,15 +2150,60 @@ $(document).on('click', '.comment-upvote', function () {
|
||||
function lazyloadStickers() {
|
||||
// 原生懒加载无需额外处理
|
||||
}
|
||||
$(document).on("click", "#comment_emotion_btn", function () {
|
||||
$("#comment_emotion_btn").toggleClass("comment-emotion-keyboard-open");
|
||||
|
||||
function positionEmotionKeyboard() {
|
||||
var btn = document.getElementById("comment_emotion_btn");
|
||||
var keyboard = document.getElementById("emotion_keyboard");
|
||||
if (!btn || !keyboard) return;
|
||||
|
||||
// Ensure keyboard is a child of body to avoid stacking context & clipping issues
|
||||
if (keyboard.parentElement !== document.body) {
|
||||
document.body.appendChild(keyboard);
|
||||
}
|
||||
|
||||
var btnRect = btn.getBoundingClientRect();
|
||||
var keyboardHeight = 300;
|
||||
var keyboardWidth = Math.min(500, window.innerWidth - 40);
|
||||
|
||||
var top = btnRect.top + window.scrollY - keyboardHeight - 10;
|
||||
var left = btnRect.right + window.scrollX - keyboardWidth;
|
||||
|
||||
if (top < window.scrollY + 10) {
|
||||
top = btnRect.bottom + window.scrollY + 10;
|
||||
}
|
||||
if (left < window.scrollX + 10) {
|
||||
left = window.scrollX + 10;
|
||||
}
|
||||
if (left + keyboardWidth > window.scrollX + window.innerWidth - 10) {
|
||||
left = window.scrollX + window.innerWidth - keyboardWidth - 10;
|
||||
}
|
||||
|
||||
keyboard.style.top = top + "px";
|
||||
keyboard.style.left = left + "px";
|
||||
}
|
||||
|
||||
$(document).on("click", "#comment_emotion_btn", function (e) {
|
||||
e.stopPropagation();
|
||||
var isOpen = $("#comment_emotion_btn").hasClass("comment-emotion-keyboard-open");
|
||||
if (!isOpen) {
|
||||
$("#comment_emotion_btn").addClass("comment-emotion-keyboard-open");
|
||||
$("#emotion_keyboard").addClass("comment-emotion-keyboard-open");
|
||||
setTimeout(function() {
|
||||
positionEmotionKeyboard();
|
||||
}, 10);
|
||||
} else {
|
||||
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
|
||||
$("#emotion_keyboard").removeClass("comment-emotion-keyboard-open");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".emotion-keyboard .emotion-group-name", function () {
|
||||
$(".emotion-keyboard .emotion-group-name.active").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$(".emotion-keyboard .emotion-group:not(d-none)").addClass("d-none");
|
||||
$(".emotion-keyboard .emotion-group[index='" + $(this).attr("index") + "']").removeClass("d-none");
|
||||
});
|
||||
|
||||
function inputInsertText(text, input) {
|
||||
$(input).focus();
|
||||
let isSuccess = document.execCommand("insertText", false, text);
|
||||
@@ -2180,25 +2225,36 @@ function inputInsertText(text, input) {
|
||||
}
|
||||
$(input).focus();
|
||||
}
|
||||
|
||||
$(document).on("click", ".emotion-keyboard .emotion-item", function () {
|
||||
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
|
||||
$("#emotion_keyboard").removeClass("comment-emotion-keyboard-open");
|
||||
if ($(this).hasClass("emotion-item-sticker")) {
|
||||
inputInsertText(" :" + $(this).attr("code") + ": ", document.getElementById("post_comment_content"));
|
||||
} else {
|
||||
inputInsertText($(this).attr("text"), document.getElementById("post_comment_content"));
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("dragstart", ".emotion-keyboard .emotion-item > img, .comment-sticker", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
document.addEventListener('click', (e) => {
|
||||
if (document.getElementById("comment_emotion_btn") == null) {
|
||||
if (document.getElementById("comment_emotion_btn") == null || document.getElementById("emotion_keyboard") == null) {
|
||||
return;
|
||||
}
|
||||
if (e.target.id != "comment_emotion_btn" && e.target.id != "emotion_keyboard" && !document.getElementById("comment_emotion_btn").contains(e.target) && !document.getElementById("emotion_keyboard").contains(e.target)) {
|
||||
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
|
||||
$("#emotion_keyboard").removeClass("comment-emotion-keyboard-open");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
window.addEventListener('resize', function() {
|
||||
if ($("#emotion_keyboard").hasClass("comment-emotion-keyboard-open")) {
|
||||
positionEmotionKeyboard();
|
||||
}
|
||||
});
|
||||
/*查看评论编辑记录*/
|
||||
function showCommentEditHistory(id) {
|
||||
let requestID = parseInt(new Date().getTime());
|
||||
|
||||
Reference in New Issue
Block a user