|
902 | 902 | e.preventDefault();
|
903 | 903 | e.stopPropagation();
|
904 | 904 | menu.togglePinEntry(this.entry.id);
|
| 905 | + this.$pinLink.textContent = menu._pinnedIds[this.entry.id] ? 'Unpin' : 'Pin'; |
905 | 906 | });
|
906 | 907 |
|
907 | 908 | this.$refsLink = document.createElement('a');
|
|
922 | 923 | sdoBox.deactivate();
|
923 | 924 | this.active = true;
|
924 | 925 | this.entry = entry;
|
| 926 | + this.$pinLink.textContent = menu._pinnedIds[entry.id] ? 'Unpin' : 'Pin'; |
925 | 927 | this.$outer.classList.add('active');
|
926 | 928 | this.top = el.offsetTop - this.$outer.offsetHeight;
|
927 | 929 | this.left = el.offsetLeft - 10;
|
|
1117 | 1119 | referencePane.init();
|
1118 | 1120 | });
|
1119 | 1121 |
|
| 1122 | +// preserve state during navigation |
| 1123 | +
|
| 1124 | +function getTocPath(li) { |
| 1125 | + let path = []; |
| 1126 | + let pointer = li; |
| 1127 | + while (true) { |
| 1128 | + let parent = pointer.parentElement; |
| 1129 | + if (parent == null) { |
| 1130 | + return null; |
| 1131 | + } |
| 1132 | + let index = [].indexOf.call(parent.children, pointer); |
| 1133 | + if (index == -1) { |
| 1134 | + return null; |
| 1135 | + } |
| 1136 | + path.unshift(index); |
| 1137 | + pointer = parent.parentElement; |
| 1138 | + if (pointer == null) { |
| 1139 | + return null; |
| 1140 | + } |
| 1141 | + if (pointer.id === 'menu-toc') { |
| 1142 | + break; |
| 1143 | + } |
| 1144 | + if (pointer.tagName !== 'LI') { |
| 1145 | + return null; |
| 1146 | + } |
| 1147 | + } |
| 1148 | + return path; |
| 1149 | +} |
| 1150 | +
|
| 1151 | +function activateTocPath(path) { |
| 1152 | + try { |
| 1153 | + let pointer = document.getElementById('menu-toc'); |
| 1154 | + for (let index of path) { |
| 1155 | + pointer = pointer.querySelector('ol').children[index]; |
| 1156 | + } |
| 1157 | + pointer.classList.add('active'); |
| 1158 | + } catch (e) { |
| 1159 | + // pass |
| 1160 | + } |
| 1161 | +} |
| 1162 | +
|
| 1163 | +function getActiveTocPaths() { |
| 1164 | + return [...menu.$menu.querySelectorAll('.active')].map(getTocPath).filter(p => p != null); |
| 1165 | +} |
| 1166 | +
|
| 1167 | +function loadStateFromSessionStorage() { |
| 1168 | + if (!window.sessionStorage || typeof menu === 'undefined' || window.navigating) { |
| 1169 | + return; |
| 1170 | + } |
| 1171 | + if (sessionStorage.referencePaneState != null) { |
| 1172 | + let state = JSON.parse(sessionStorage.referencePaneState); |
| 1173 | + if (state != null) { |
| 1174 | + if (state.type === 'ref') { |
| 1175 | + let entry = menu.search.biblio.byId[state.id]; |
| 1176 | + if (entry != null) { |
| 1177 | + referencePane.showReferencesFor(entry); |
| 1178 | + } |
| 1179 | + } else if (state.type === 'sdo') { |
| 1180 | + let sdos = sdoMap[state.id]; |
| 1181 | + if (sdos != null) { |
| 1182 | + referencePane.$headerText.innerHTML = state.html; |
| 1183 | + referencePane.showSDOsBody(sdos, state.id); |
| 1184 | + } |
| 1185 | + } |
| 1186 | + delete sessionStorage.referencePaneState; |
| 1187 | + } |
| 1188 | + } |
| 1189 | +
|
| 1190 | + if (sessionStorage.activeTocPaths != null) { |
| 1191 | + document |
| 1192 | + .getElementById('menu-toc') |
| 1193 | + .querySelectorAll('.active') |
| 1194 | + .forEach(e => { |
| 1195 | + e.classList.remove('active'); |
| 1196 | + }); |
| 1197 | + let active = JSON.parse(sessionStorage.activeTocPaths); |
| 1198 | + active.forEach(activateTocPath); |
| 1199 | + delete sessionStorage.activeTocPaths; |
| 1200 | + } |
| 1201 | +
|
| 1202 | + if (sessionStorage.searchValue != null) { |
| 1203 | + let value = JSON.parse(sessionStorage.searchValue); |
| 1204 | + menu.search.$searchBox.value = value; |
| 1205 | + menu.search.search(value); |
| 1206 | + delete sessionStorage.searchValue; |
| 1207 | + } |
| 1208 | +
|
| 1209 | + if (sessionStorage.tocScroll != null) { |
| 1210 | + let tocScroll = JSON.parse(sessionStorage.tocScroll); |
| 1211 | + menu.$toc.scrollTop = tocScroll; |
| 1212 | + delete sessionStorage.tocScroll; |
| 1213 | + } |
| 1214 | +} |
| 1215 | +
|
| 1216 | +document.addEventListener('DOMContentLoaded', loadStateFromSessionStorage); |
| 1217 | +
|
| 1218 | +window.addEventListener('pageshow', loadStateFromSessionStorage); |
| 1219 | +
|
| 1220 | +window.addEventListener('beforeunload', () => { |
| 1221 | + if (!window.sessionStorage || typeof menu === 'undefined') { |
| 1222 | + return; |
| 1223 | + } |
| 1224 | + sessionStorage.referencePaneState = JSON.stringify(referencePane.state || null); |
| 1225 | + sessionStorage.activeTocPaths = JSON.stringify(getActiveTocPaths()); |
| 1226 | + sessionStorage.searchValue = JSON.stringify(menu.search.$searchBox.value); |
| 1227 | + sessionStorage.tocScroll = JSON.stringify(menu.$toc.scrollTop); |
| 1228 | +}); |
| 1229 | +
|
1120 | 1230 | 'use strict';
|
1121 | 1231 | let decimalBullet = Array.from({ length: 100 }, (a, i) => '' + (i + 1));
|
1122 | 1232 | let alphaBullet = Array.from({ length: 26 }, (a, i) => String.fromCharCode('a'.charCodeAt(0) + i));
|
|
2414 | 2524 | </ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120">
|
2415 | 2525 | <title>Menu</title>
|
2416 | 2526 | <path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
|
2417 |
| - </svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright & Software License"><span class="secnum">A</span> Copyright & Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / April 8, 2022</h1><h1 class="title">Proposal Title Goes Here</h1> |
| 2527 | + </svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright & Software License"><span class="secnum">A</span> Copyright & Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / May 23, 2022</h1><h1 class="title">Proposal Title Goes Here</h1> |
2418 | 2528 |
|
2419 | 2529 | <emu-clause id="sec-demo-clause">
|
2420 | 2530 | <h1><span class="secnum">1</span> This is an emu-clause</h1>
|
|
0 commit comments