Child

pym. Child

new Child(configopt)

The Child half of a responsive iframe.

Source:
Parameters:
Name Type Attributes Description
config Object <optional>

Configuration for the child instance. sets module:pym.Child~settings

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.

parenturlparam string <optional>

if passed it will be override the default parentUrl query string parameter name expected on the iframe src

Members

(inner) id :String

The id of the parent container

Source:
Type:
  • String

(inner) messageHandlers :Object

Stores the registered messageHandlers for each messageType

Source:
Type:
  • Object

(inner) messageRegex :String

RegularExpression to validate the received messages

Source:
Type:
  • String

(inner) parentTitle :String

The title of the parent page from document.title.

Source:
Type:
  • String

(inner) parentUrl :String

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

Source:
Type:
  • String

(inner) parentWidth :string

The initial width of the parent page

Source:
Type:
  • string

(inner) timerId :String

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

Source:
Type:
  • String

Methods

Navigate parent to a given url.

Source:
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".

Source:
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.

Source:

scrollParentTo(hash)

Scroll parent to a given element id.

Source:
Parameters:
Name Type Description
hash String

The id of the element to scroll to.

scrollParentToChildEl(id)

Scroll parent to a given child element id.

Source:
Parameters:
Name Type Description
id String

The id of the child element to scroll to.

scrollParentToChildPos(pos)

Scroll parent to a particular child offset.

Source:
Parameters:
Name Type Description
pos Number

The offset of the child element to scroll to.

sendHeight()

Ask parent to send the current viewport and iframe position information

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.

Source:
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.

Source:
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

Source:
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.

Source:
Parameters:
Name Type Description
message String

The new width.

(inner) _processMessage(e)

Process a new message from the parent.

Source:
Parameters:
Name Type Description
e Event

A message event.

Type Definitions

onMarkedEmbeddedStatus(classname)

Source:
Parameters:
Name Type Description
classname String

"embedded" or "not-embedded".

onMessageCallback(message)

Source:
Parameters:
Name Type Description
message String

The message data.