import { Rule } from './Rule' ; import { validateRuntimeOptions , RuntimeTypes } from '../runtimeOptionChecker' ; import { div } from '../dom' ; import { Page } from '../book' ; export interface RunningHeaderRuleOptions { selector : string ; render : ( page : Page ) => HTMLElement ; } class RunningHeader extends Rule { constructor ( options = { } ) { super ( options ) ; validateRuntimeOptions ( options , { name : 'RunningHeader' , render : RuntimeTypes . func , } ) ; } eachPage ( page ) { if ( ! page . runningHeader ) { const elmt = div ( '.running-header' ) ; page . element . appendChild ( elmt ) ; page . runningHeader = elmt ; } page . runningHeader . innerHTML = this . render ( page ) ; } render ( page ) { return `${ page . number }` ; } } export default RunningHeader ;