new Child(configopt)
The Child half of a responsive iframe.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
<optional> |
Configuration for the child instance. sets module:pym.Child~settings Properties
|
Members
(inner) id :String
The id of the parent container
Type:
- String
(inner) messageHandlers :Object
Stores the registered messageHandlers for each messageType
Type:
- Object
(inner) messageRegex :String
RegularExpression to validate the received messages
Type:
- String
(inner) parentTitle :String
The title of the parent page from document.title.
Type:
- String
(inner) parentUrl :String
The URL of the parent page from window.location.href.
Type:
- String
(inner) parentWidth :string
The initial width of the parent page
Type:
- string
(inner) timerId :String
The timerId in order to be able to stop when polling is enabled
Type:
- String
Methods
navigateParentTo(url)
Navigate parent to a given url.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The url to navigate to. |
onMessage(messageType, callback)
Bind a callback to a given messageType from the child.
Reserved message names are: "width".
Parameters:
Name | Type | Description |
---|---|---|
messageType |
String | The type of message being listened for. |
callback |
module:pym.Child~onMessageCallback | The callback to invoke when a message of the given type is received. |
remove()
Unbind child event handlers and timers.
scrollParentTo(hash)
Scroll parent to a given element id.
Parameters:
Name | Type | Description |
---|---|---|
hash |
String | The id of the element to scroll to. |
scrollParentToChildEl(id)
Scroll parent to a given child element id.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | The id of the child element to scroll to. |
scrollParentToChildPos(pos)
Scroll parent to a particular child offset.
Parameters:
Name | Type | Description |
---|---|---|
pos |
Number | The offset of the child element to scroll to. |
sendHeight()
Transmit the current iframe height to the parent.
Call this directly in cases where you manually alter the height of the iframe contents.
sendMessage(messageType, message)
Send a message to the the Parent.
Parameters:
Name | Type | Description |
---|---|---|
messageType |
String | The type of message to send. |
message |
String | The message data to send. |
(inner) _fire(messageType, message)
Fire all event handlers for a given message type.
Parameters:
Name | Type | Description |
---|---|---|
messageType |
String | The type of message. |
message |
String | The message data. |
(inner) _markWhetherEmbedded(The)
Mark Whether the child is embedded or not
executes a callback in case it was passed to the config
Parameters:
Name | Type | Description |
---|---|---|
The |
module:pym.Child~onMarkedEmbeddedStatus | callback to execute after determining whether embedded or not. |
(inner) _onWidthMessage(message)
Resize iframe in response to new width message from parent.
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The new width. |
(inner) _processMessage(e)
Process a new message from the parent.
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | A message event. |
Type Definitions
onMarkedEmbeddedStatus(classname)
Parameters:
Name | Type | Description |
---|---|---|
classname |
String | "embedded" or "not-embedded". |
onMessageCallback(message)
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The message data. |