// 定义pjax 预设pjax (function() { if (typeof Pjax === 'undefined') { console.error('Pjax library is not loaded.'); return; } var pjax = new Pjax({ // 这里填写页面中改变的部分(和 CSS 选择器用法一样) selectors: ["title", "#pjax-container"], cacheBust: false, elements: "a", // 拦截所有链接 switches: { "#pjax-container": Pjax.switches.default } }); // 将 pjax 实例挂载到 window 以便调试或外部访问 window.pjax = pjax; console.log("Pjax initialized:", pjax); })(); // pjax预先加载代码 function pjax_reload() { console.log("Pjax reload triggered"); // 给pjax容器加入css过渡动画 // var pjaxContainer = document.getElementById("pjax-container"); // if (pjaxContainer) pjaxContainer.classList.add("uk-animation-slide-bottom-small"); // 评论区过渡动画 var selectors = [ ".comment-meta", ".comment-author vcard", ".comment-metadata", ".comment-content", ".reply" ]; selectors.forEach(function(selector) { document.querySelectorAll(selector).forEach(function(el) { el.setAttribute("uk-scrollspy", "cls: uk-animation-fade; delay: 100"); }); }); // 说说页面过渡动画 var shuoshuoBody = document.getElementById("shuoshuo_body"); if (shuoshuoBody) { shuoshuoBody.setAttribute("uk-scrollspy", "target: > .shuoshuo; cls: uk-animation-fade; delay: 250"); } } // pjax发送时期 document.addEventListener("pjax:send", function () { // pjax动画减少圆圈动画 NProgress.configure({ showSpinner: false }); // pjax执行动画开始 NProgress.start(); //加载动画效果开始 }); // Pjax 成功后,重新加载下面的函数 document.addEventListener("pjax:success", function () { // 重载图片懒加载插件的js if (typeof lazyLoadInit === 'function') { lazyLoadInit({ // coverColor: "white", // coverDiv: "
优世界·一个记录生活点滴的小站
", offsetBottom: 800, offsetTopm: 800, showTime: 1100 }); } // 激活文章图片灯箱 if (window.ViewImage) { ViewImage.init('.post-content img'); } }); // pjax加载完成 document.addEventListener("pjax:complete", function () { // pjax完成动画 if (typeof NProgress !== 'undefined') { NProgress.done(); } // 重载一些js样式调整 pjax_reload(); // 初始化代码复制 if (typeof initCodeCopy === 'function') initCodeCopy(); // 初始化代码折叠 if (typeof initCodeFold === 'function') initCodeFold(); // 初始化友链状态 if (typeof window.initLinkStatus === 'function') { window.initLinkStatus(); } // 重载评论 if (typeof window.initArtalk === 'function') { window.initArtalk(); } // 重载不蒜子统计 if (typeof window.bsz_fetch === 'function') { window.bsz_fetch(); } // 重载 Search 和 Floating Tools (Moved from main.js) if (typeof window.initFloatingTools === 'function') window.initFloatingTools(); if (typeof window.initSearch === 'function') window.initSearch(); });