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 Properties
|
Members
(inner) el :HTMLElement
The container DOM object
Type:
- HTMLElement
(inner) id :string
The id of the container element
Type:
- string
(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. |
remove()
Remove this parent from the page and unbind it's event handlers.
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. |
sendWidth()
Transmit the current iframe width to the child.
You shouldn't need to call this directly.
(inner) _constructIframe()
Construct the iframe.
(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) _onResize()
Send width on resize.
(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. |
Type Definitions
onMessageCallback(message)
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The message data. |