mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 完全移除 jquery feat: 清除配置文件的CDN, 默認 CDN 不再顯示在 config feat: 切換夜間模式後, mermaid 也會切換夜間主題 feat: 移除騰訊分析 feat: 移除右下角字體調整按鈕 feat: 本地搜索可處理 json feat: 右下角按鈕自定義順序 feat: 右小角按鈕 UI 微調 improvement: 手機端更改閲讀模式退出按鈕到右下角 improvement: photofigcaption 和 fancybox 的 figcaption 優先顯示 圖片的title屬性,然後是 alt 屬性 improvement: 首頁ui微調 improvement: 禁止一些瀏覽器會出現點擊左下角按鈕出現放大網頁的行為 improvement: js 優化 fix: 修復窗口大小改變時,導航欄的ui 可能會錯亂的 bug fix: 修復 pjax 下, twikoo 評論獲取是上一篇評論的 bug fix: 壓縮 html 代碼後, mermaid 顯示正常
88 lines
2.7 KiB
Plaintext
88 lines
2.7 KiB
Plaintext
- var pjaxExclude = 'a:not([target="_blank"])'
|
|
if theme.pjax.exclude
|
|
each val in theme.pjax.exclude
|
|
- pjaxExclude = pjaxExclude + `:not([href="${val}"])`
|
|
|
|
script(src=url_for(theme.CDN.pjax))
|
|
script.
|
|
let pjaxSelectors = [
|
|
'title',
|
|
'#config-diff',
|
|
'#body-wrap',
|
|
'#rightside-config-hide',
|
|
'#rightside-config-show',
|
|
'.js-pjax'
|
|
]
|
|
|
|
if (!{Boolean(theme.Open_Graph_meta && theme.comments.use && theme.comments.use.includes('Livere'))}) {
|
|
pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
|
|
}
|
|
|
|
var pjax = new Pjax({
|
|
elements: '!{pjaxExclude}',
|
|
selectors: pjaxSelectors,
|
|
cacheBust: false,
|
|
analytics: !{theme.google_analytics ? true : false},
|
|
scrollRestoration: false
|
|
})
|
|
|
|
document.addEventListener('pjax:send', function () {
|
|
|
|
// removeEventListener scroll
|
|
window.removeEventListener('scroll', window.tocScrollFn)
|
|
window.removeEventListener('scroll', scrollCollect)
|
|
|
|
typeof preloader === 'object' && preloader.initLoading()
|
|
|
|
if (window.aplayers) {
|
|
for (let i = 0; i < window.aplayers.length; i++) {
|
|
if (!window.aplayers[i].options.fixed) {
|
|
window.aplayers[i].destroy()
|
|
}
|
|
}
|
|
}
|
|
|
|
typeof typed === 'object' && typed.destroy()
|
|
|
|
//reset readmode
|
|
const $bodyClassList = document.body.classList
|
|
$bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')
|
|
|
|
})
|
|
|
|
document.addEventListener('pjax:complete', function () {
|
|
window.refreshFn()
|
|
|
|
document.querySelectorAll('script[data-pjax]').forEach(item => {
|
|
const newScript = document.createElement('script')
|
|
const content = item.text || item.textContent || item.innerHTML || ""
|
|
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
|
|
newScript.appendChild(document.createTextNode(content))
|
|
item.parentNode.replaceChild(newScript, item)
|
|
})
|
|
|
|
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
|
|
|
|
typeof chatBtnFn === 'function' && chatBtnFn()
|
|
typeof panguInit === 'function' && panguInit()
|
|
|
|
// google analytics
|
|
typeof gtag === 'function' && gtag('config', '!{theme.google_analytics}', {'page_path': window.location.pathname});
|
|
|
|
// baidu analytics
|
|
typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);
|
|
|
|
typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()
|
|
|
|
// prismjs
|
|
typeof Prism === 'object' && Prism.highlightAll()
|
|
|
|
typeof preloader === 'object' && preloader.endLoading()
|
|
})
|
|
|
|
document.addEventListener('pjax:error', (e) => {
|
|
if (e.request.status === 404) {
|
|
pjax.loadUrl('/404.html')
|
|
}
|
|
})
|