1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const Toc_1 = require("./Toc");
|
4 |
|
5 | function makeMenu(spec) {
|
6 | const pinContainer = spec.doc.createElement('div');
|
7 | pinContainer.setAttribute('id', 'menu-pins');
|
8 | const pinHeader = spec.doc.createElement('div');
|
9 | pinHeader.textContent = 'Pins';
|
10 | pinHeader.setAttribute('class', 'menu-pane-header');
|
11 | const pinList = spec.doc.createElement('ul');
|
12 | pinList.setAttribute('id', 'menu-pins-list');
|
13 | pinContainer.appendChild(pinHeader);
|
14 | pinContainer.appendChild(pinList);
|
15 | const toc = Toc_1.default.build(spec, true);
|
16 | const tocContainer = spec.doc.createElement('div');
|
17 | tocContainer.setAttribute('id', 'menu-toc');
|
18 | tocContainer.innerHTML = toc;
|
19 | const tocHeader = spec.doc.createElement('div');
|
20 | tocHeader.textContent = 'Table of Contents';
|
21 | tocHeader.setAttribute('class', 'menu-pane-header');
|
22 | tocContainer.appendChild(tocHeader);
|
23 | const searchContainer = spec.doc.createElement('div');
|
24 | searchContainer.setAttribute('id', 'menu-search');
|
25 | searchContainer.innerHTML =
|
26 | '<input type=text id=menu-search-box placeholder=Search...><div id=menu-search-results class=inactive></div>';
|
27 | const menuContainer = spec.doc.createElement('div');
|
28 | menuContainer.setAttribute('id', 'menu');
|
29 | menuContainer.appendChild(searchContainer);
|
30 | menuContainer.appendChild(pinContainer);
|
31 | menuContainer.appendChild(tocHeader);
|
32 | menuContainer.appendChild(tocContainer);
|
33 | const menuSpacer = spec.doc.createElement('div');
|
34 | menuSpacer.setAttribute('id', 'menu-spacer');
|
35 | const menuToggle = spec.doc.createElement('div');
|
36 | menuToggle.setAttribute('id', 'menu-toggle');
|
37 | menuToggle.innerHTML =
|
38 |
|
39 |
|
40 | `<svg xmlns="http://www.w3.org/2000/svg"
|
41 | style="width:100%; height:100%; stroke:currentColor"
|
42 | viewBox="0 0 120 120">
|
43 | <title>Menu</title>
|
44 | <path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60" />
|
45 | </svg>`;
|
46 | const json = JSON.stringify({ refsByClause: spec.refsByClause, entries: spec.biblio.toJSON() }, biblioReplacer);
|
47 | return {
|
48 | eles: [menuContainer, menuSpacer, menuToggle],
|
49 | js: `let biblio = JSON.parse(\`${json.replace(/[\\`$]/g, '\\$&')}\`);`,
|
50 | };
|
51 | }
|
52 | exports.default = makeMenu;
|
53 | function biblioReplacer(k, v) {
|
54 | if (!['title', 'namespace', 'location', 'variants'].includes(k)) {
|
55 | return v;
|
56 | }
|
57 | if (k === 'title' && this.type === 'clause' && this.title !== this.titleHTML) {
|
58 | return v;
|
59 | }
|
60 | return undefined;
|
61 | }
|