new Parent(id, url, configopt)
The Parent half of a response iframe.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
String
|
The id of the div into which the iframe will be rendered. sets module:pym.Parent~id |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url |
String
|
The url of the iframe source. sets module:pym.Parent~url |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config |
Object
|
<optional> |
Configuration for the parent instance. sets module:pym.Parent~settings
|
Members
(inner) iframe :HTMLElement
The contained child iframe
Type:
-
HTMLElement
(inner) messageHandlers :Object
Stores the registered messageHandlers for each messageType
Type:
-
Object
(inner) messageRegex :String
RegularExpression to validate the received messages
Type:
-
String
(inner) settings :Object
The parent instance settings, updated by the values passed in the config object
Type:
-
Object
(inner) url :String
The url that will be set as the iframe's src
Type:
-
String
Methods
onMessage(messageType, callback)
Bind a callback to a given messageType from the child.
Reserved message names are: "height", "scrollTo" and "navigateTo".
Parameters:
Name | Type | Description |
---|---|---|
messageType |
String
|
The type of message being listened for. |
callback |
module:pym.Parent~onMessageCallback
|
The callback to invoke when a message of the given type is received. |
sendMessage(messageType, message)
Send a message to the the child.
Parameters:
Name | Type | Description |
---|---|---|
messageType |
String
|
The type of message to send. |
message |
String
|
The message data to send. |
sendViewportAndIFramePosition()
Transmit the current viewport and iframe position to the child.
Sends viewport width, viewport height
and iframe bounding rect top-left-bottom-right
all separated by spaces
You shouldn't need to call this directly.
sendWidth()
Transmit the current iframe width to the child.
You shouldn't need to call this directly.
(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) _onHeightMessage(message)
Resize iframe in response to new height message from child.
Parameters:
Name | Type | Description |
---|---|---|
message |
String
|
The new height. |
(inner) _onNavigateToMessage(message)
Navigate parent to a new url.
Parameters:
Name | Type | Description |
---|---|---|
message |
String
|
The url to navigate to. |
(inner) _onScrollToChildPosMessage(message)
Scroll parent to a given child position.
Parameters:
Name | Type | Description |
---|---|---|
message |
String
|
The offset inside the child page. |
(inner) _processMessage(e)
Process a new message from the child.
Parameters:
Name | Type | Description |
---|---|---|
e |
Event
|
A message event. |