diff options
Diffstat (limited to 'web/src/jsx.tsx')
| -rw-r--r-- | web/src/jsx.tsx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/web/src/jsx.tsx b/web/src/jsx.tsx index a92fc11..749e93f 100644 --- a/web/src/jsx.tsx +++ b/web/src/jsx.tsx @@ -11,8 +11,9 @@ export interface Route { const routes: Route[] = []; let err404page = "/"; let rootId = "moneyjsx-root"; -let onprenavigate: Function = () => {}; -let onpostnavigate: Function = () => {}; +let defaultTitle = ""; +export let onprenavigate: Function = () => {}; +export let onpostnavigate: Function = () => {}; function routeForPath( route: string ) : Function | null { if( !routes[route] ) { @@ -37,6 +38,10 @@ export function setRootId( rootId: string ) { rootId = rootId; } +export function setDefaultTitle( title: string ) { + defaultTitle = title; +} + /** * adds a route component to the routes list * the component function must return either a jquery or a DOM element @@ -87,6 +92,7 @@ export function navigate( route: string ) { window.history.pushState( {}, null, url.href ); onprenavigate(); + setTitle(); const el = $( cb() ); curRoute = cb; @@ -111,6 +117,7 @@ export function navigateParams( route: string, params: any ) { window.history.pushState( {}, null, url.href ); onprenavigate(); + setTitle(); const el = $( cb() ); curRoute = cb; @@ -143,6 +150,7 @@ export function navigateParamsSilent( route: string, params: any ) { return navigateSilent( err404page ); onprenavigate(); + setTitle(); const el = $( cb() ); curRoute = cb; @@ -162,6 +170,7 @@ export function navigateSilent( route: string ) { return navigateSilent( err404page ); onprenavigate(); + setTitle(); const el = $( cb() ); curRoute = cb; @@ -185,6 +194,7 @@ export function onPopState() { return; onprenavigate(); + setTitle(); const el = $( cb() ); curRoute = cb; @@ -251,7 +261,7 @@ export function createElement( tag: any, props: any, ...children: any ) { const lowercaseName = name.toLowerCase(); if( lowercaseName in window ) { - element.addEventListener( lowercaseName.substring(2 ), value ); + element.addEventListener( lowercaseName.substring( 2 ), value ); continue; } } @@ -288,3 +298,7 @@ export function createElement( tag: any, props: any, ...children: any ) { export function createFragment( props: any ) { return props.children; } + +function setTitle() { + document.title = defaultTitle; +} |
