|
1 | 1 | (function() { |
2 | 2 | var appState = window.__yardAppState || (window.__yardAppState = { |
3 | | - listenersBound: false, |
4 | | - navigationListenerBound: false |
| 3 | + navigationListenerBound: false, |
| 4 | + navigationChangeBound: false, |
| 5 | + navResizerBound: false, |
| 6 | + searchFrameGlobalsBound: false |
5 | 7 | }); |
6 | 8 | var safeLocalStorage = {}; |
7 | 9 | var safeSessionStorage = {}; |
|
173 | 175 |
|
174 | 176 | function searchFrameButtons() { |
175 | 177 | queryAll(".full_list_link").forEach(function(link) { |
| 178 | + if (link.dataset.yardSearchFrameBound === "true") return; |
| 179 | + |
176 | 180 | link.addEventListener("click", function(event) { |
177 | 181 | event.preventDefault(); |
178 | 182 | toggleSearchFrame(link, link.getAttribute("href")); |
179 | 183 | }); |
| 184 | + |
| 185 | + link.dataset.yardSearchFrameBound = "true"; |
180 | 186 | }); |
181 | 187 |
|
182 | | - if (appState.listenersBound) return; |
| 188 | + if (appState.searchFrameGlobalsBound) return; |
183 | 189 |
|
184 | 190 | window.addEventListener("message", function(event) { |
185 | 191 | if (event.data === "navEscape") resetSearchFrame(); |
|
189 | 195 | if (!isVisible(query("#search"))) resetSearchFrame(); |
190 | 196 | }); |
191 | 197 |
|
192 | | - appState.listenersBound = true; |
| 198 | + appState.searchFrameGlobalsBound = true; |
193 | 199 | } |
194 | 200 |
|
195 | 201 | function linkSummaries() { |
|
399 | 405 |
|
400 | 406 | if (!resizer) return; |
401 | 407 |
|
402 | | - resizer.addEventListener( |
403 | | - "pointerdown", |
404 | | - function(event) { |
405 | | - resizer.setPointerCapture(event.pointerId); |
406 | | - event.preventDefault(); |
407 | | - event.stopPropagation(); |
408 | | - }, |
409 | | - false |
410 | | - ); |
411 | | - resizer.addEventListener( |
412 | | - "pointerup", |
413 | | - function(event) { |
414 | | - resizer.releasePointerCapture(event.pointerId); |
415 | | - event.preventDefault(); |
416 | | - event.stopPropagation(); |
417 | | - }, |
418 | | - false |
419 | | - ); |
420 | | - resizer.addEventListener( |
421 | | - "pointermove", |
422 | | - function(event) { |
423 | | - if ((event.buttons & 1) === 0) return; |
424 | | - |
425 | | - safeSessionStorage.navWidth = String(event.pageX); |
426 | | - queryAll(".nav_wrap").forEach(function(node) { |
427 | | - node.style.width = Math.max(200, event.pageX) + "px"; |
428 | | - }); |
429 | | - event.preventDefault(); |
430 | | - event.stopPropagation(); |
431 | | - }, |
432 | | - false |
433 | | - ); |
| 408 | + if (!appState.navResizerBound) { |
| 409 | + resizer.addEventListener( |
| 410 | + "pointerdown", |
| 411 | + function(event) { |
| 412 | + resizer.setPointerCapture(event.pointerId); |
| 413 | + event.preventDefault(); |
| 414 | + event.stopPropagation(); |
| 415 | + }, |
| 416 | + false |
| 417 | + ); |
| 418 | + resizer.addEventListener( |
| 419 | + "pointerup", |
| 420 | + function(event) { |
| 421 | + resizer.releasePointerCapture(event.pointerId); |
| 422 | + event.preventDefault(); |
| 423 | + event.stopPropagation(); |
| 424 | + }, |
| 425 | + false |
| 426 | + ); |
| 427 | + resizer.addEventListener( |
| 428 | + "pointermove", |
| 429 | + function(event) { |
| 430 | + if ((event.buttons & 1) === 0) return; |
| 431 | + |
| 432 | + safeSessionStorage.navWidth = String(event.pageX); |
| 433 | + queryAll(".nav_wrap").forEach(function(node) { |
| 434 | + node.style.width = Math.max(200, event.pageX) + "px"; |
| 435 | + }); |
| 436 | + event.preventDefault(); |
| 437 | + event.stopPropagation(); |
| 438 | + }, |
| 439 | + false |
| 440 | + ); |
| 441 | + |
| 442 | + appState.navResizerBound = true; |
| 443 | + } |
434 | 444 |
|
435 | 445 | if (safeSessionStorage.navWidth) { |
436 | 446 | queryAll(".nav_wrap").forEach(function(node) { |
|
461 | 471 | var hash = window.location.hash; |
462 | 472 | if (!hash) return; |
463 | 473 |
|
| 474 | + var targetId = hash.slice(1); |
| 475 | + var decodedTargetId = targetId; |
| 476 | + |
464 | 477 | try { |
465 | | - var target = query(hash); |
466 | | - if (target) target.scrollIntoView(); |
| 478 | + decodedTargetId = decodeURIComponent(targetId); |
467 | 479 | } catch (error) {} |
| 480 | + |
| 481 | + var target = |
| 482 | + document.getElementById(decodedTargetId) || |
| 483 | + document.getElementById(targetId); |
| 484 | + |
| 485 | + if (target) target.scrollIntoView(); |
468 | 486 | } |
469 | 487 |
|
470 | 488 | function mainFocus() { |
|
476 | 494 | } |
477 | 495 |
|
478 | 496 | function navigationChange() { |
| 497 | + if (appState.navigationChangeBound) return; |
| 498 | + |
479 | 499 | window.onpopstate = focusHashTarget; |
| 500 | + appState.navigationChangeBound = true; |
480 | 501 | } |
481 | 502 |
|
482 | 503 | window.__app = function() { |
|
0 commit comments