Child

pym. Child

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
Name Type Attributes Default Description
renderCallback function <optional>
null

Callback invoked after receiving a resize event from the parent, sets module:pym.Child#settings.renderCallback

xdomain string <optional>
'*'

xdomain to validate messages received

polling number <optional>
0

polling frequency in milliseconds to send height to parent

id number <optional>

parent container id used when navigating the child iframe to a new page but we want to keep it responsive.

Source:

Members

(inner) id :String

The id of the parent container

Type:
  • String
Source:

(inner) messageHandlers :Object

Stores the registered messageHandlers for each messageType

Type:
  • Object
Source:

(inner) messageRegex :String

RegularExpression to validate the received messages

Type:
  • String
Source:

(inner) parentTitle :String

The title of the parent page from document.title.

Type:
  • String
Source:

(inner) parentUrl :String

The URL of the parent page from window.location.href.

Type:
  • String
Source:

(inner) parentWidth :string

The initial width of the parent page

Type:
  • string
Source:

(inner) timerId :String

The timerId in order to be able to stop when polling is enabled

Type:
  • String
Source:

Methods

Navigate parent to a given url.

Parameters:
Name Type Description
url String

The url to navigate to.

Source:

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.

Source:

remove()

Unbind child event handlers and timers.

Source:

scrollParentTo(hash)

Scroll parent to a given element id.

Parameters:
Name Type Description
hash String

The id of the element to scroll to.

Source:

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.

Source:

scrollParentToChildPos(pos)

Scroll parent to a particular child offset.

Parameters:
Name Type Description
pos Number

The offset of the child element to scroll to.

Source:

sendHeight()

Transmit the current iframe height to the parent.

Call this directly in cases where you manually alter the height of the iframe contents.

Source:

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.

Source:

(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.

Source:

(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.

Source:

(inner) _onWidthMessage(message)

Resize iframe in response to new width message from parent.

Parameters:
Name Type Description
message String

The new width.

Source:

(inner) _processMessage(e)

Process a new message from the parent.

Parameters:
Name Type Description
e Event

A message event.

Source:

Type Definitions

onMarkedEmbeddedStatus(classname)

Parameters:
Name Type Description
classname String

"embedded" or "not-embedded".

Source:

onMessageCallback(message)

Parameters:
Name Type Description
message String

The message data.

Source: