pjax.swig 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <script>
  2. var pjax = new Pjax({
  3. selectors: [
  4. 'head title',
  5. '#page-configurations',
  6. '.content-wrap',
  7. '.post-toc-wrap',
  8. '.languages',
  9. '#pjax'
  10. ],
  11. switches: {
  12. '.post-toc-wrap': Pjax.switches.innerHTML
  13. },
  14. analytics: false,
  15. cacheBust: false,
  16. scrollTo : !CONFIG.bookmark.enable
  17. });
  18. window.addEventListener('pjax:success', () => {
  19. document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
  20. var code = element.text || element.textContent || element.innerHTML || '';
  21. var parent = element.parentNode;
  22. parent.removeChild(element);
  23. var script = document.createElement('script');
  24. if (element.id) {
  25. script.id = element.id;
  26. }
  27. if (element.className) {
  28. script.className = element.className;
  29. }
  30. if (element.type) {
  31. script.type = element.type;
  32. }
  33. if (element.src) {
  34. script.src = element.src;
  35. // Force synchronous loading of peripheral JS.
  36. script.async = false;
  37. }
  38. if (element.dataset.pjax !== undefined) {
  39. script.dataset.pjax = '';
  40. }
  41. if (code !== '') {
  42. script.appendChild(document.createTextNode(code));
  43. }
  44. parent.appendChild(script);
  45. });
  46. NexT.boot.refresh();
  47. // Define Motion Sequence & Bootstrap Motion.
  48. if (CONFIG.motion.enable) {
  49. NexT.motion.integrator
  50. .init()
  51. .add(NexT.motion.middleWares.subMenu)
  52. .add(NexT.motion.middleWares.postList)
  53. .bootstrap();
  54. }
  55. NexT.utils.updateSidebarPosition();
  56. });
  57. </script>