Skip to content

Latest commit

 

History

History
431 lines (309 loc) · 12.7 KB

contents.md

File metadata and controls

431 lines (309 loc) · 12.7 KB

Contents

Handles DOM manipulation, queries and events for View contents

Kind: global class

new Contents(doc, content, section)

Constructor

Param Type Description
doc Document Document
content Element Parent Element (typically Body)
section Section Section object reference

contents.width([w]) ⇒ number

Get or Set width

Kind: instance method of Contents
Returns: number - width

Param Type
[w] number

contents.height([h]) ⇒ number

Get or Set height

Kind: instance method of Contents
Returns: number - height

Param Type
[h] number

contents.textSize() ⇒ Object

Get size of the text using Range

Kind: instance method of Contents

contents.scrollWidth() ⇒ number

Get documentElement scrollWidth

Kind: instance method of Contents
Returns: number - width

contents.scrollHeight() ⇒ number

Get documentElement scrollHeight

Kind: instance method of Contents
Returns: number - height

contents.overflow([overflow]) ⇒ string

Set overflow css style of the contents

Kind: instance method of Contents

Param Type
[overflow] string

contents.overflowX([overflow]) ⇒ string

Set overflowX css style of the documentElement

Kind: instance method of Contents

Param Type
[overflow] string

contents.overflowY([overflow]) ⇒ string

Set overflowY css style of the documentElement

Kind: instance method of Contents

Param Type
[overflow] string

contents.css(property, value, [priority]) ⇒ any

Set Css styles on the contents element (typically Body)

Kind: instance method of Contents

Param Type Description
property string
value string
[priority] boolean set as "important"

contents.viewport([options]) ⇒ object

Get or Set the viewport element

Kind: instance method of Contents

Param Type
[options] object
[options.width] string
[options.height] string
[options.scale] string
[options.minimum] string
[options.maximum] string
[options.scalable] string

contents.root() ⇒ Element

Get the documentElement

Kind: instance method of Contents
Returns: Element - documentElement

contents.locationOf(target, [ignoreClass]) ⇒ Object

Get the location offset of a EpubCFI or an #id

Kind: instance method of Contents
Returns: Object - target position left and top

Param Type Description
target string | EpubCFI
[ignoreClass] string for the cfi

contents.appendStylesheet(key, input) ⇒ Promise.<Node>

Append a stylesheet link/rules to the document head

Kind: instance method of Contents

Param Type Description
key string
input string | object url or rules

Example

appendStylesheet("common", "/pach/to/stylesheet.css")

Example

appendStylesheet("common", "https://example.com/to/stylesheet.css")

Example

appendStylesheet("common", { h1: { "font-size": "1.5em" }})

contents.removeStylesheet(key) ⇒ boolean

Remove a stylesheet link from the document head

Kind: instance method of Contents

Param Type
key string

contents.clearStylesheets()

Clear all injected stylesheets

Kind: instance method of Contents

contents.appendScript(key, src) ⇒ Promise.<Node>

Append a script node to the document head

Kind: instance method of Contents
Returns: Promise.<Node> - loaded

Param Type Description
key string
src string url

Example

appendScript("common", "/path/to/script.js")

Example

appendScript("common", "https://examples.com/to/script.js")

contents.removeScript(key) ⇒ boolean

Remove a script node from the document head

Kind: instance method of Contents

Param Type
key string

contents.clearScripts()

Clear all injected scripts

Kind: instance method of Contents

contents.appendClass(className)

Append a class to the contents container

Kind: instance method of Contents

Param Type
className string

contents.removeClass(className)

Remove a class from the contents container

Kind: instance method of Contents

Param Type
className string

contents.range(cfi, [ignoreClass]) ⇒ Range

Get a Dom Range from EpubCFI

Kind: instance method of Contents
Returns: Range - range

Param Type
cfi EpubCFI
[ignoreClass] string

contents.cfiFromRange(range, [ignoreClass]) ⇒ string

Get an EpubCFI from a Dom Range

Kind: instance method of Contents
Returns: string - EpubCFI

Param Type
range Range
[ignoreClass] string

contents.cfiFromNode(node, [ignoreClass]) ⇒ string

Get an EpubCFI from a Dom node

Kind: instance method of Contents
Returns: string - EpubCFI

Param Type
node Node
[ignoreClass] string

contents.map(layout) ⇒ Array.<object>

map

Kind: instance method of Contents
Todo

  • find where this is used - remove?
Param Type
layout Layout

contents.format(layout)

Apply CSS to a Document

Kind: instance method of Contents

Param Type
layout Layout

contents.scale(scale, offsetX, offsetY)

Scale contents from center

Kind: instance method of Contents

Param Type
scale number
offsetX number
offsetY number

contents.direction([dir])

Set the direction of the text

Kind: instance method of Contents

Param Type Default Description
[dir] string "'ltr'" values: "ltr" OR "rtl"

contents.mapPage(cfiBase, layout, start, end, dev) ⇒ any

mapPage

Kind: instance method of Contents

Param Type
cfiBase string
layout Layout
start number
end number
dev boolean

contents.writingMode([mode])

Set the writingMode of the text

Kind: instance method of Contents

Param Type Default Description
[mode] string "'horizontal-tb'" "horizontal-tb" OR "vertical-rl" OR "vertical-lr"

contents.destroy()

destroy

Kind: instance method of Contents

Contents.content : Element

document.body by current location

Kind: static property of Contents
Read only: true

Contents.contentRect : object

Kind: static property of Contents
Read only: true

Contents.section : Section

Kind: static property of Contents
Read only: true

Contents.mode : string

writing-mode

Kind: static property of Contents
Read only: true