// 定义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: "