PageSourceSearch

https://saili.science/js/next-boot.js

js saili.science collected 2026-09-25 22:37:35 UTC 2,463 bytes, 80 lines download raw bytes

1/* global NexT, CONFIG */
2
3NexT.boot = {};
4
5NexT.boot.registerEvents = function() {
6
7  NexT.utils.registerScrollPercent();
8  NexT.utils.registerCanIUseTag();
9  NexT.utils.updateFooterPosition();
10
11  // Mobile top menu bar.
12  document.querySelector('.site-nav-toggle .toggle').addEventListener('click', event => {
13    event.currentTarget.classList.toggle('toggle-close');
14    const siteNav = document.querySelector('.site-nav');
15    if (!siteNav) return;
16    siteNav.style.setProperty('--scroll-height', siteNav.scrollHeight + 'px');
17    document.body.classList.toggle('site-nav-on');
18  });
19
20  document.querySelectorAll('.sidebar-nav li').forEach((element, index) => {
21    element.addEventListener('click', () => {
22      NexT.utils.activateSidebarPanel(index);
23    });
24  });
25
26  window.addEventListener('hashchange', () => {
27    const tHash = location.hash;
28    if (tHash !== '' && !tHash.match(/%\S{2}/)) {
29      const target = document.querySelector(`.tabs ul.nav-tabs li a[href="${tHash}"]`);
30      target?.click();
31    }
32  });
33
34  window.addEventListener('tabs:click', e => {
35    NexT.utils.registerCodeblock(e.target);
36  });
37};
38
39NexT.boot.refresh = function() {
40
41  /**
42   * Register JS handlers by condition option.
43   * Need to add config option in Front-End at 'scripts/helpers/next-config.js' file.
44   */
45  CONFIG.prism && window.Prism.highlightAll();
46  CONFIG.mediumzoom && window.mediumZoom('.post-body :not(a) > img, .post-body > img', {
47    background: 'var(--content-bg-color)'
48  });
49  CONFIG.lazyload && window.lozad('.post-body img').observe();
50  CONFIG.pangu && window.pangu.spacingElementByTagName('main');
51
52  CONFIG.exturl && NexT.utils.registerExtURL();
53  NexT.utils.wrapTableWithBox();
54  NexT.utils.registerCodeblock();
55  NexT.utils.registerTabsTag();
56  NexT.utils.registerActiveMenuItem();
57  NexT.utils.registerLangSelect();
58  NexT.utils.registerSidebarTOC();
59  NexT.utils.registerPostReward();
60  NexT.utils.registerVideoIframe();
61};
62
63NexT.boot.motion = function() {
64  // Define Motion Sequence & Bootstrap Motion.
65  if (CONFIG.motion.enable) {
66    NexT.motion.integrator
67      .add(NexT.motion.middleWares.header)
68      .add(NexT.motion.middleWares.sidebar)
69      .add(NexT.motion.middleWares.postList)
70      .add(NexT.motion.middleWares.footer)
71      .bootstrap();
72  }
73  NexT.utils.updateSidebarPosition();
74};
75
76document.addEventListener('DOMContentLoaded', () => {
77  NexT.boot.registerEvents();
78  NexT.boot.refresh();
79  NexT.boot.motion();
80});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.