Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 63x 63x 63x 63x 63x 63x 63x 63x 63x 63x 63x 63x 83x 83x 83x 83x 83x 138x 138x 138x 83x 83x 83x 83x 83x 83x 83x 83x 83x 45x 45x 83x 83x 63x 63x 63x 365x 365x 365x 365x 63x 63x 63x 48x 48x 48x 28x 48x 20x 20x 48x 48x 63x 63x 63x 4x 3x 3x 4x 63x 63x 63x 4x 3x 3x 4x 63x 63x 63x 6x 5x 5x 6x 63x 63x 63x 81x 81x 81x 63x 63x 63x 81x 81x 81x 63x 63x 63x 8x 8x 8x 8x 63x 63x 63x 81x 81x 81x 81x 81x 63x 63x 63x 74x 74x 74x 74x 63x 63x 63x 213x 213x 213x 213x 63x 63x 63x 76x 76x 76x 76x 76x 76x 76x 63x | import { NavigationDelegate } from './NavigationDelegate.js';
/**
* Browser navigation delegate interacting with window, location, document.title,
* and hashchange/click events.
* @augments NavigationDelegate
*/
export class BrowserNavigationDelegate extends NavigationDelegate {
/**
* Creates an instance of BrowserNavigationDelegate.
*/
constructor() {
super();
this.hashListeners = new Set();
this.linkClickListeners = new Set();
this.onWindowHashChange = () => {
for (const listener of this.hashListeners) {
listener(this.getHash());
}
};
this.onWindowClick = (e) => {
if (typeof window === 'undefined' || !e || !e.target || typeof e.target.closest !== 'function') {
return;
}
const target = e.target.closest('[data-ax-link]');
if (target) {
e.preventDefault();
const route = target.getAttribute('data-ax-link');
if (route) {
for (const listener of this.linkClickListeners) {
listener(route);
}
}
}
};
if (typeof window !== 'undefined') {
window.addEventListener('hashchange', this.onWindowHashChange);
window.addEventListener('click', this.onWindowClick);
if (!window.__avenx_routers) {
window.__avenx_routers = new Set();
}
}
}
/** @override */
getHash() {
if (typeof window !== 'undefined' && window.location) {
return window.location.hash || '#/';
}
return '#/';
}
/** @override */
setHash(hash, options = {}) {
if (typeof window !== 'undefined' && window.location) {
// window.location.hash = hash;
if (options.replace) {
window.location.replace(hash);
} else {
window.location.hash = hash;
}
}
}
/** @override */
back() {
if (typeof window !== 'undefined' && window.history && typeof window.history.back === 'function') {
window.history.back();
}
}
/** @override */
forward() {
if (typeof window !== 'undefined' && window.history && typeof window.history.forward === 'function') {
window.history.forward();
}
}
/** @override */
go(delta) {
if (typeof window !== 'undefined' && window.history && typeof window.history.go === 'function') {
window.history.go(delta);
}
}
/** @override */
onHashChange(callback) {
this.hashListeners.add(callback);
return () => this.hashListeners.delete(callback);
}
/** @override */
onLinkClick(callback) {
this.linkClickListeners.add(callback);
return () => this.linkClickListeners.delete(callback);
}
/** @override */
setTitle(title) {
if (typeof document !== 'undefined') {
document.title = title;
}
}
/** @override */
registerRouter(router) {
if (typeof window !== 'undefined') {
if (!window.__avenx_routers) {
window.__avenx_routers = new Set();
}
window.__avenx_routers.add(router);
}
}
/** @override */
unregisterRouter(router) {
if (typeof window !== 'undefined' && window.__avenx_routers) {
window.__avenx_routers.delete(router);
}
}
/** @override */
getActiveRouters() {
if (typeof window !== 'undefined' && window.__avenx_routers) {
return window.__avenx_routers;
}
return new Set();
}
/** @override */
destroy() {
if (typeof window !== 'undefined') {
window.removeEventListener('hashchange', this.onWindowHashChange);
window.removeEventListener('click', this.onWindowClick);
}
this.hashListeners.clear();
this.linkClickListeners.clear();
}
}
|