mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +00:00
Fix: bind pjax event on document instead of window
This commit is contained in:
parent
cd5e54193b
commit
75695df76a
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
fetchData();
|
fetchData();
|
||||||
var fetchDataTimer = setInterval(fetchData, 60000);
|
var fetchDataTimer = setInterval(fetchData, 60000);
|
||||||
window.addEventListener('pjax:send', () => {
|
document.addEventListener('pjax:send', () => {
|
||||||
clearInterval(fetchDataTimer);
|
clearInterval(fetchDataTimer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ var pjax = new Pjax({
|
|||||||
scrollTo : !CONFIG.bookmark.enable
|
scrollTo : !CONFIG.bookmark.enable
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('pjax:success', () => {
|
document.addEventListener('pjax:success', () => {
|
||||||
document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
|
document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
|
||||||
var code = element.text || element.textContent || element.innerHTML || '';
|
var code = element.text || element.textContent || element.innerHTML || '';
|
||||||
var parent = element.parentNode;
|
var parent = element.parentNode;
|
||||||
|
|||||||
@ -115,7 +115,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
|
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
|
||||||
window.addEventListener('pjax:success', onPopupClose);
|
document.addEventListener('pjax:success', onPopupClose);
|
||||||
window.addEventListener('keyup', event => {
|
window.addEventListener('keyup', event => {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
onPopupClose();
|
onPopupClose();
|
||||||
|
|||||||
@ -31,7 +31,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (trigger === 'auto') {
|
if (trigger === 'auto') {
|
||||||
// Register beforeunload event
|
// Register beforeunload event
|
||||||
window.addEventListener('beforeunload', doSaveScroll);
|
window.addEventListener('beforeunload', doSaveScroll);
|
||||||
window.addEventListener('pjax:send', doSaveScroll);
|
document.addEventListener('pjax:send', doSaveScroll);
|
||||||
}
|
}
|
||||||
// Save the position by clicking the icon
|
// Save the position by clicking the icon
|
||||||
link.addEventListener('click', () => {
|
link.addEventListener('click', () => {
|
||||||
@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
scrollToMark();
|
scrollToMark();
|
||||||
window.addEventListener('pjax:success', scrollToMark);
|
document.addEventListener('pjax:success', scrollToMark);
|
||||||
};
|
};
|
||||||
|
|
||||||
init(CONFIG.bookmark.save);
|
init(CONFIG.bookmark.save);
|
||||||
|
|||||||
@ -269,7 +269,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
|
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
|
||||||
window.addEventListener('pjax:success', onPopupClose);
|
document.addEventListener('pjax:success', onPopupClose);
|
||||||
window.addEventListener('keyup', event => {
|
window.addEventListener('keyup', event => {
|
||||||
if (event.key === 'Escape') {
|
if (event.key === 'Escape') {
|
||||||
onPopupClose();
|
onPopupClose();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user