index.js 20.0 KB
Newer Older
Five-菜鸟级's avatar
init  
Five-菜鸟级 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
(()=>{
  var e = {
      163: e=>{
          e.exports = function(e) {
              var t, n = [].forEach, l = [].some, o = document.body, i = !0, r = " ";
              function s(t, l) {
                  var o, i, c, d = l.appendChild((o = t,
                  i = document.createElement("li"),
                  c = document.createElement("a"),
                  e.listItemClass && i.setAttribute("class", e.listItemClass),
                  e.onClick && (c.onclick = e.onClick),
                  e.includeTitleTags && c.setAttribute("title", o.textContent),
                  e.includeHtml && o.childNodes.length ? n.call(o.childNodes, (function(e) {
                      c.appendChild(e.cloneNode(!0))
                  }
                  )) : c.textContent = o.textContent.replace(/^\#\s/g, ""),
                  c.setAttribute("href", e.basePath + "#" + o.id),
                  c.setAttribute("class", e.linkClass + r + "node-name--" + o.nodeName + r + e.extraLinkClasses),
                  i.appendChild(c),
                  i));
                  if (t.children.length) {
                      var u = a(t.isCollapsed);
                      t.children.forEach((function(e) {
                          s(e, u)
                      }
                      )),
                      d.appendChild(u)
                  }
              }
              function a(t) {
                  var n = e.orderedList ? "ol" : "ul"
                    , l = document.createElement(n)
                    , o = e.listClass + r + e.extraListClasses;
                  return t && (o += r + e.collapsibleClass,
                  o += r + e.isCollapsedClass),
                  l.setAttribute("class", o),
                  l
              }
              function c(t) {
                  var n = 0;
                  return null !== t && (n = t.offsetTop,
                  e.hasInnerContainers && (n += c(t.offsetParent))),
                  n
              }
              function d(t) {
                  return t && -1 !== t.className.indexOf(e.collapsibleClass) && -1 !== t.className.indexOf(e.isCollapsedClass) ? (t.className = t.className.split(r + e.isCollapsedClass).join(""),
                  d(t.parentNode.parentNode)) : t
              }
              return {
                  enableTocAnimation: function() {
                      i = !0
                  },
                  disableTocAnimation: function(t) {
                      var n = t.target || t.srcElement;
                      "string" == typeof n.className && -1 !== n.className.indexOf(e.linkClass) && (i = !1)
                  },
                  render: function(e, n) {
                      var l = a(!1);
                      if (n.forEach((function(e) {
                          s(e, l)
                      }
                      )),
                      null !== (t = e || t))
                          return t.firstChild && t.removeChild(t.firstChild),
                          0 === n.length ? t : t.appendChild(l)
                  },
                  updateToc: function(s) {
                  
                      var a;
                      a = e.scrollContainer && document.querySelector(e.scrollContainer) ? document.querySelector(e.scrollContainer).scrollTop : document.documentElement.scrollTop || o.scrollTop,
                      e.positionFixedSelector && function() {
                          var n;
                          n = e.scrollContainer && document.querySelector(e.scrollContainer) ? document.querySelector(e.scrollContainer).scrollTop : document.documentElement.scrollTop || o.scrollTop;
                          var l = document.querySelector(e.positionFixedSelector);
                          "auto" === e.fixedSidebarOffset && (e.fixedSidebarOffset = t.offsetTop),
                          n > e.fixedSidebarOffset ? -1 === l.className.indexOf(e.positionFixedClass) && (l.className += r + e.positionFixedClass) : l.className = l.className.split(r + e.positionFixedClass).join("")
                      }();
                      var u, f = s;
                      if (i && null !== t && f.length > 0) {
                          l.call(f, (function(t, n) {
                              return c(t) > a + e.headingsOffset+15? (u = f[0 === n ? n : n - 1],
                              !0) : n === f.length - 1 ? (u = f[f.length - 1],
                              !0) : void 0
                          }
                          ));
                          var m = t.querySelectorAll("." + e.linkClass);
                         
                          n.call(m, (function(t) {
                              t.className = t.className.split(r + e.activeLinkClass).join("")
                          }
                          ));
                          var h = t.querySelectorAll("." + e.listItemClass);
                          n.call(h, (function(t) {
                              t.className = t.className.split(r + e.activeListItemClass).join("")
                          }
                          ));
                          var p = t.querySelector("." + e.linkClass + ".node-name--" + u.nodeName + '[href="' + e.basePath + "#" + u.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/@])/g, "\\$1") + '"]');
                          p && -1 === p.className.indexOf(e.activeLinkClass) && (p.className += r + e.activeLinkClass);
                          var C = p && p.parentNode;
                          C && -1 === C.className.indexOf(e.activeListItemClass) && (C.className += r + e.activeListItemClass);
                          var g = t.querySelectorAll("." + e.listClass + "." + e.collapsibleClass);
                          n.call(g, (function(t) {
                              -1 === t.className.indexOf(e.isCollapsedClass) && (t.className += r + e.isCollapsedClass)
                          }
                          )),
                          p && p.nextSibling && -1 !== p.nextSibling.className.indexOf(e.isCollapsedClass) && (p.nextSibling.className = p.nextSibling.className.split(r + e.isCollapsedClass).join("")),
                          d(p && p.parentNode.parentNode)
                      }
                  }
              }
          }
      }
      ,
      547: e=>{
          e.exports = {
              tocSelector: ".js-toc",
              contentSelector: ".js-toc-content",
              headingSelector: "h1, h2, h3",
              ignoreSelector: ".js-toc-ignore",
              hasInnerContainers: !1,
              linkClass: "toc-link",
              extraLinkClasses: "",
              activeLinkClass: "is-active-link",
              listClass: "toc-list",
              extraListClasses: "",
              isCollapsedClass: "is-collapsed",
              collapsibleClass: "is-collapsible",
              listItemClass: "toc-list-item",
              activeListItemClass: "is-active-li",
              collapseDepth: 0,
              scrollSmooth: !0,
              scrollSmoothDuration: 420,
              scrollSmoothOffset: 0,
              scrollEndCallback: function(e) {},
              headingsOffset: 1,
              throttleTimeout: 50,
              positionFixedSelector: null,
              positionFixedClass: "is-position-fixed",
              fixedSidebarOffset: "auto",
              includeHtml: !1,
              includeTitleTags: !1,
              onClick: function(e) {},
              orderedList: !0,
              scrollContainer: null,
              skipRendering: !1,
              headingLabelCallback: !1,
              ignoreHiddenElements: !1,
              headingObjectCallback: null,
              basePath: "",
              disableTocScrollSync: !1
          }
      }
      ,
      971: function(e, t, n) {
          var l, o, i;
          o = [],
          l = function(e) {
              "use strict";
              var t, l, o, i = n(547), r = {}, s = {}, a = n(163), c = n(279), d = n(938), u = !!(e && e.document && e.document.querySelector && e.addEventListener);
              if ("undefined" != typeof window || u) {
                  var f = Object.prototype.hasOwnProperty;
                  return s.destroy = function() {
                      var e = h(r);
                      null !== e && (r.skipRendering || e && (e.innerHTML = ""),
                      r.scrollContainer && document.querySelector(r.scrollContainer) ? (document.querySelector(r.scrollContainer).removeEventListener("scroll", this._scrollListener, !1),
                      document.querySelector(r.scrollContainer).removeEventListener("resize", this._scrollListener, !1),
                      t && document.querySelector(r.scrollContainer).removeEventListener("click", this._clickListener, !1)) : (document.removeEventListener("scroll", this._scrollListener, !1),
                      document.removeEventListener("resize", this._scrollListener, !1),
                      t && document.removeEventListener("click", this._clickListener, !1)))
                  }
                  ,
                  s.init = function(e) {
                      if (u) {
                          r = function() {
                              for (var e = {}, t = 0; t < arguments.length; t++) {
                                  var n = arguments[t];
                                  for (var l in n)
                                      f.call(n, l) && (e[l] = n[l])
                              }
                              return e
                          }(i, e || {}),
                          this.options = r,
                          this.state = {},
                          r.scrollSmooth && (r.duration = r.scrollSmoothDuration,
                          r.offset = r.scrollSmoothOffset,
                          s.scrollSmooth = n(374).initSmoothScrolling(r)),
                          t = a(r),
                          l = c(r),
                          this._buildHtml = t,
                          this._parseContent = l,
                          this._headingsArray = o,
                          s.destroy();
                          var p = function(e) {
                              try {
                                  return e.contentElement || document.querySelector(e.contentSelector)
                              } catch (t) {
                                  return console.warn("Contents element not found: " + e.contentSelector),
                                  null
                              }
                          }(r);
                          if (null !== p) {
                              var C = h(r);
                              if (null !== C && null !== (o = l.selectHeadings(p, r.headingSelector))) {
                                  var g = l.nestHeadingsArray(o).nest;
                                  r.skipRendering || t.render(C, g),
                                  this._scrollListener = m((function(e) {
                                      t.updateToc(o),
                                      !r.disableTocScrollSync && d(r);
                                      var n = e && e.target && e.target.scrollingElement && 0 === e.target.scrollingElement.scrollTop;
                                      (e && (0 === e.eventPhase || null === e.currentTarget) || n) && (t.updateToc(o),
                                      r.scrollEndCallback && r.scrollEndCallback(e))
                                  }
                                  ), r.throttleTimeout),
                                  this._scrollListener(),
                                  r.scrollContainer && document.querySelector(r.scrollContainer) ? (document.querySelector(r.scrollContainer).addEventListener("scroll", this._scrollListener, !1),
                                  document.querySelector(r.scrollContainer).addEventListener("resize", this._scrollListener, !1)) : (document.addEventListener("scroll", this._scrollListener, !1),
                                  document.addEventListener("resize", this._scrollListener, !1));
                                  var v = null;
                                  return this._clickListener = m((function(e) {
                                      r.scrollSmooth && t.disableTocAnimation(e),
                                      t.updateToc(o),
                                      v && clearTimeout(v),
                                      v = setTimeout((function() {
                                          t.enableTocAnimation()
                                      }
                                      ), r.scrollSmoothDuration)
                                  }
                                  ), r.throttleTimeout),
                                  r.scrollContainer && document.querySelector(r.scrollContainer) ? document.querySelector(r.scrollContainer).addEventListener("click", this._clickListener, !1) : document.addEventListener("click", this._clickListener, !1),
                                  this
                              }
                          }
                      }
                  }
                  ,
                  s.refresh = function(e) {
                      s.destroy(),
                      s.init(e || this.options)
                  }
                  ,
                  e.tocbot = s,
                  s
              }
              function m(e, t, n) {
                  var l, o;
                  return t || (t = 250),
                  function() {
                      var i = n || this
                        , r = +new Date
                        , s = arguments;
                      l && r < l + t ? (clearTimeout(o),
                      o = setTimeout((function() {
                          l = r,
                          e.apply(i, s)
                      }
                      ), t)) : (l = r,
                      e.apply(i, s))
                  }
              }
              function h(e) {
                  try {
                      return e.tocElement || document.querySelector(e.tocSelector)
                  } catch (t) {
                      return console.warn("TOC element not found: " + e.tocSelector),
                      null
                  }
              }
          }(void 0 !== n.g ? n.g : this.window || this.global),
          void 0 === (i = "function" == typeof l ? l.apply(t, o) : l) || (e.exports = i)
      },
      279: e=>{
          e.exports = function(e) {
              var t = [].reduce;
              function n(e) {
                  return e[e.length - 1]
              }
              function l(e) {
                  return +e.nodeName.toUpperCase().replace("H", "")
              }
              function o(t) {
                  if (!(t instanceof window.HTMLElement))
                      return t;
                  if (e.ignoreHiddenElements && (!t.offsetHeight || !t.offsetParent))
                      return null;
                  const n = t.getAttribute("data-heading-label") || (e.headingLabelCallback ? String(e.headingLabelCallback(t.textContent)) : t.textContent.trim());
                  var o = {
                      id: t.id,
                      children: [],
                      nodeName: t.nodeName,
                      headingLevel: l(t),
                      textContent: n
                  };
                  return e.includeHtml && (o.childNodes = t.childNodes),
                  e.headingObjectCallback ? e.headingObjectCallback(o, t) : o
              }
              return {
                  nestHeadingsArray: function(l) {
                      return t.call(l, (function(t, l) {
                          var i = o(l);
                          return i && function(t, l) {
                              for (var i = o(t), r = i.headingLevel, s = l, a = n(s), c = r - (a ? a.headingLevel : 0); c > 0 && (!(a = n(s)) || r !== a.headingLevel); )
                                  a && void 0 !== a.children && (s = a.children),
                                  c--;
                              r >= e.collapseDepth && (i.isCollapsed = !0),
                              s.push(i)
                          }(i, t.nest),
                          t
                      }
                      ), {
                          nest: []
                      })
                  },
                  selectHeadings: function(t, n) {
                      var l = n;
                      e.ignoreSelector && (l = n.split(",").map((function(t) {
                          return t.trim() + ":not(" + e.ignoreSelector + ")"
                      }
                      )));
                      try {
                          return t.querySelectorAll(l)
                      } catch (e) {
                          return console.warn("Headers not found with selector: " + l),
                          null
                      }
                  }
              }
          }
      }
      ,
      374: (e,t)=>{
          t.initSmoothScrolling = function(e) {
              var t = e.duration
                , n = e.offset
                , l = location.hash ? o(location.href) : location.href;
              function o(e) {
                  return e.slice(0, e.lastIndexOf("#"))
              }
              document.body.addEventListener("click", (function(i) {
                  var r;
                  "a" !== (r = i.target).tagName.toLowerCase() || !(r.hash.length > 0 || "#" === r.href.charAt(r.href.length - 1)) || o(r.href) !== l && o(r.href) + "#" !== l || i.target.className.indexOf("no-smooth-scroll") > -1 || "#" === i.target.href.charAt(i.target.href.length - 2) && "!" === i.target.href.charAt(i.target.href.length - 1) || -1 === i.target.className.indexOf(e.linkClass) || function(e, t) {
                      var n, l, o = window.pageYOffset, i = {
                          duration: t.duration,
                          offset: t.offset || 0,
                          callback: t.callback,
                          easing: t.easing || function(e, t, n, l) {
                              return (e /= l / 2) < 1 ? n / 2 * e * e + t : -n / 2 * (--e * (e - 2) - 1) + t
                          }
                      }, r = document.querySelector('[id="' + decodeURI(e).split("#").join("") + '"]') || document.querySelector('[id="' + e.split("#").join("") + '"]'), s = "string" == typeof e ? i.offset + (e ? r && r.getBoundingClientRect().top || 0 : -(document.documentElement.scrollTop || document.body.scrollTop)) : e, a = "function" == typeof i.duration ? i.duration(s) : i.duration;
                      function c(e) {
                          l = e - n,
                          window.scrollTo(0, i.easing(l, o, s, a)),
                          l < a ? requestAnimationFrame(c) : (window.scrollTo(0, o + s),
                          "function" == typeof i.callback && i.callback())
                      }
                      requestAnimationFrame((function(e) {
                          n = e,
                          c(e)
                      }
                      ))
                  }(i.target.hash, {
                      duration: t,
                      offset: n,
                      callback: function() {
                          var e, t;
                          e = i.target.hash,
                          (t = document.getElementById(e.substring(1))) && (/^(?:a|select|input|button|textarea)$/i.test(t.tagName) || (t.tabIndex = -1),
                          t.focus())
                      }
                  })
              }
              ), !1)
          }
      }
      ,
      938: e=>{
          e.exports = function(e) {
              // var t = e.tocElement || document.querySelector(e.tocSelector);
              // if (t && t.scrollHeight > t.clientHeight) {
              //     var n = t.querySelector("." + e.activeListItemClass);
              //     console.log(n);
              //     // n && (t.scrollTop = n.offsetTop)
              // }
          }
      }
  }
    , t = {};
  function n(l) {
      var o = t[l];
      if (void 0 !== o)
          return o.exports;
      var i = t[l] = {
          exports: {}
      };
      return e[l].call(i.exports, i, i.exports, n),
      i.exports
  }
  n.g = function() {
      if ("object" == typeof globalThis)
          return globalThis;
      try {
          return this || new Function("return this")()
      } catch (e) {
          if ("object" == typeof window)
              return window
      }
  }(),
  n(971)
}
)();