v0.1.41 theme: 홈/사이드바/추천 모달 동작 정리
Made-with: Cursor
This commit is contained in:
@@ -153,28 +153,6 @@
|
||||
|
||||
syncLeftSidebarState();
|
||||
|
||||
var siteMain = document.querySelector(".site-main");
|
||||
var sidebarNodes = document.querySelectorAll(".sidebar--left, .sidebar--right");
|
||||
|
||||
function shouldProxySidebarWheel() {
|
||||
return !tabletMedia.matches && !!siteMain;
|
||||
}
|
||||
|
||||
sidebarNodes.forEach(function (sidebar) {
|
||||
sidebar.addEventListener("wheel", function (event) {
|
||||
if (!shouldProxySidebarWheel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
siteMain.scrollBy({
|
||||
top: event.deltaY,
|
||||
left: 0,
|
||||
behavior: "auto"
|
||||
});
|
||||
}, { passive: false });
|
||||
});
|
||||
|
||||
var tabRoot = document.querySelector("[data-tabs]");
|
||||
if (tabRoot) {
|
||||
var triggers = tabRoot.querySelectorAll("[data-tab-trigger]");
|
||||
@@ -371,6 +349,64 @@
|
||||
|
||||
syncUserMenuToggles();
|
||||
|
||||
var recommendationsPortalTrigger = document.querySelector("[data-portal='recommendations']");
|
||||
var recommendationsPortalTitle = recommendationsPortalTrigger ? recommendationsPortalTrigger.getAttribute("data-portal-title") : "";
|
||||
var recommendationsPortalDescription = recommendationsPortalTrigger ? recommendationsPortalTrigger.getAttribute("data-portal-description") : "";
|
||||
|
||||
function getPortalDocuments() {
|
||||
var docs = [document];
|
||||
|
||||
document.querySelectorAll("iframe").forEach(function (frame) {
|
||||
try {
|
||||
if (frame.contentDocument) {
|
||||
docs.push(frame.contentDocument);
|
||||
}
|
||||
} catch (error) {}
|
||||
});
|
||||
|
||||
return docs;
|
||||
}
|
||||
|
||||
function applyRecommendationsPortalCopy() {
|
||||
if (!recommendationsPortalTitle && !recommendationsPortalDescription) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var hasPatched = false;
|
||||
|
||||
getPortalDocuments().forEach(function (docRoot) {
|
||||
var portalTitle = docRoot.querySelector(".gh-portal-main-title");
|
||||
var portalDescription = docRoot.querySelector(".gh-portal-recommendations-description");
|
||||
|
||||
if (portalTitle && recommendationsPortalTitle) {
|
||||
portalTitle.textContent = recommendationsPortalTitle;
|
||||
hasPatched = true;
|
||||
}
|
||||
|
||||
if (portalDescription && recommendationsPortalDescription) {
|
||||
portalDescription.textContent = recommendationsPortalDescription;
|
||||
hasPatched = true;
|
||||
}
|
||||
});
|
||||
|
||||
return hasPatched;
|
||||
}
|
||||
|
||||
if (recommendationsPortalTrigger && (recommendationsPortalTitle || recommendationsPortalDescription)) {
|
||||
recommendationsPortalTrigger.addEventListener("click", function () {
|
||||
applyRecommendationsPortalCopy();
|
||||
var attempts = 0;
|
||||
var maxAttempts = 20;
|
||||
var retryTimer = window.setInterval(function () {
|
||||
attempts += 1;
|
||||
var done = applyRecommendationsPortalCopy();
|
||||
if (done || attempts >= maxAttempts) {
|
||||
window.clearInterval(retryTimer);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function updateLoadMoreState(pagination, nextUrl, loading) {
|
||||
var trigger = pagination.querySelector("[data-load-more-trigger]");
|
||||
if (!trigger) {
|
||||
|
||||
Reference in New Issue
Block a user