You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

69 lines
1.6 KiB

<script src="{{ theme.cdnurl }}/lib/pjax/pjax.min.js"></script>
<script>
{%- if theme.pjax.enable -%}
window.pjax = new Pjax({
elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"])',
selectors: ["head title, #main", "#footer"],
});
{%- endif -%}
/* 第一次载入页面加载的函数 */
pjax_ini = () => {
/* 关闭侧边栏 */
window.slideout.close();
if(page_obj.comments == "true"){
{%- if theme.valine.enable -%}
pjax_valine();
{%- endif -%}
}
{%- if theme.google_analytics -%}
pjax_google_analytics();
{%- endif -%}
{%- if theme.mermaid -%}
mermaid.init(undefined, $(".mermaid"));
{%-endif-%}
};
/* 第一次 执行 */
pjax_ini();
{%- if theme.pjax.enable -%}
{%- if theme.pjax.loadingbar -%}
{%- include "loading-bar.swig" -%}
{%- endif -%}
/* Pjax 开始时,重新加载的函数 */
document.addEventListener("pjax:send", function () {
{%- if theme.pjax.loadingbar -%}
loadingbarStart();
{%- endif -%}
});
/* Pjax 完成后,重新加载的函数 */
document.addEventListener("pjax:complete", function () {
/* 重载带data-pjax的script,或者.pjax-reload属性内容的script */
$("script[data-pjax], .pjax-reload script").each(function () {
$(this).parent().append($(this).remove());
});
pjax_ini();
{%- if theme.pjax.loadingbar -%}
loadingbarStop();
{%- endif -%}
page.tran.setLang();
});
/* Pjax 出错,执行的函数 */
document.addEventListener("pjax:error", function () {
});
{%- endif -%}
</script>