Handles DOM manipulation, queries and events for View contents
Kind: global class
- Contents
- new Contents(doc, content, section)
- instance
- .width([w]) ⇒
number
- .height([h]) ⇒
number
- .textSize() ⇒
Object
- .scrollWidth() ⇒
number
- .scrollHeight() ⇒
number
- .overflow([overflow]) ⇒
string
- .overflowX([overflow]) ⇒
string
- .overflowY([overflow]) ⇒
string
- .css(property, value, [priority]) ⇒
any
- .viewport([options]) ⇒
object
- .root() ⇒
Element
- .locationOf(target, [ignoreClass]) ⇒
Object
- .appendStylesheet(key, input) ⇒
Promise.<Node>
- .removeStylesheet(key) ⇒
boolean
- .clearStylesheets()
- .appendScript(key, src) ⇒
Promise.<Node>
- .removeScript(key) ⇒
boolean
- .clearScripts()
- .appendClass(className)
- .removeClass(className)
- .range(cfi, [ignoreClass]) ⇒
Range
- .cfiFromRange(range, [ignoreClass]) ⇒
string
- .cfiFromNode(node, [ignoreClass]) ⇒
string
- .map(layout) ⇒
Array.<object>
- .format(layout)
- .scale(scale, offsetX, offsetY)
- .direction([dir])
- .mapPage(cfiBase, layout, start, end, dev) ⇒
any
- .writingMode([mode])
- .destroy()
- .width([w]) ⇒
- static
- .content :
Element
- .contentRect :
object
- .section :
Section
- .mode :
string
- .content :
Constructor
Param | Type | Description |
---|---|---|
doc | Document |
Document |
content | Element |
Parent Element (typically Body) |
section | Section |
Section object reference |
Get or Set width
Kind: instance method of Contents
Returns: number
- width
Param | Type |
---|---|
[w] | number |
Get or Set height
Kind: instance method of Contents
Returns: number
- height
Param | Type |
---|---|
[h] | number |
Get size of the text using Range
Kind: instance method of Contents
Get documentElement scrollWidth
Kind: instance method of Contents
Returns: number
- width
Get documentElement scrollHeight
Kind: instance method of Contents
Returns: number
- height
Set overflow css style of the contents
Kind: instance method of Contents
Param | Type |
---|---|
[overflow] | string |
Set overflowX css style of the documentElement
Kind: instance method of Contents
Param | Type |
---|---|
[overflow] | string |
Set overflowY css style of the documentElement
Kind: instance method of Contents
Param | Type |
---|---|
[overflow] | string |
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" |
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 |
Get the documentElement
Kind: instance method of Contents
Returns: Element
- documentElement
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 |
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" }})
Remove a stylesheet link from the document head
Kind: instance method of Contents
Param | Type |
---|---|
key | string |
Clear all injected stylesheets
Kind: instance method of Contents
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")
Remove a script node from the document head
Kind: instance method of Contents
Param | Type |
---|---|
key | string |
Clear all injected scripts
Kind: instance method of Contents
Append a class to the contents container
Kind: instance method of Contents
Param | Type |
---|---|
className | string |
Remove a class from the contents container
Kind: instance method of Contents
Param | Type |
---|---|
className | string |
Get a Dom Range from EpubCFI
Kind: instance method of Contents
Returns: Range
- range
Param | Type |
---|---|
cfi | EpubCFI |
[ignoreClass] | string |
Get an EpubCFI from a Dom Range
Kind: instance method of Contents
Returns: string
- EpubCFI
Param | Type |
---|---|
range | Range |
[ignoreClass] | string |
Get an EpubCFI from a Dom node
Kind: instance method of Contents
Returns: string
- EpubCFI
Param | Type |
---|---|
node | Node |
[ignoreClass] | string |
map
Kind: instance method of Contents
Todo
- find where this is used - remove?
Param | Type |
---|---|
layout | Layout |
Apply CSS to a Document
Kind: instance method of Contents
Param | Type |
---|---|
layout | Layout |
Scale contents from center
Kind: instance method of Contents
Param | Type |
---|---|
scale | number |
offsetX | number |
offsetY | number |
Set the direction of the text
Kind: instance method of Contents
Param | Type | Default | Description |
---|---|---|---|
[dir] | string |
"'ltr'" |
values: "ltr" OR "rtl" |
mapPage
Kind: instance method of Contents
Param | Type |
---|---|
cfiBase | string |
layout | Layout |
start | number |
end | number |
dev | boolean |
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" |
destroy
Kind: instance method of Contents
document.body by current location
Kind: static property of Contents
Read only: true
Kind: static property of Contents
Read only: true
Kind: static property of Contents
Read only: true
writing-mode
Kind: static property of Contents
Read only: true