summaryrefslogtreecommitdiffstats
path: root/sphinx/themes/bizstyle/static/bizstyle.js_t
blob: fd0865e5d8a613386512a7d7d4aadbad2fbb0ea1 (plain)
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
//
// bizstyle.js
// ~~~~~~~~~~~
//
// Sphinx javascript -- for bizstyle theme.
//
// This theme was created by referring to 'sphinxdoc'
//
// :copyright: Copyright 2007-2023 by Sphinx team, see AUTHORS.
// :license: BSD, see LICENSE for details.
//
const initialiseBizStyle = () => {
    if (navigator.userAgent.indexOf("iPhone") > 0 || navigator.userAgent.indexOf("Android") > 0) {
        document.querySelector("li.nav-item-0 a").innerText = "Top"
    }
    const truncator = item => {if (item.textContent.length > 20) {
        item.title = item.innerText
        item.innerText = item.innerText.substr(0, 17) + "..."
      }
    }
    document.querySelectorAll("div.related:first ul li:not(.right) a").slice(1).forEach(truncator);
    document.querySelectorAll("div.related:last ul li:not(.right) a").slice(1).forEach(truncator);
}

window.addEventListener("resize",
  () => (document.querySelector("li.nav-item-0 a").innerText = (window.innerWidth <= 776) ? "Top" : "{{ shorttitle|e }}")
)

if (document.readyState !== "loading") initialiseBizStyle()
else document.addEventListener("DOMContentLoaded", initialiseBizStyle)