Parent

pym. Parent

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
Name Type Attributes Default Description
xdomain string <optional>
'*'

xdomain to validate messages received

title string <optional>

if passed it will be assigned to the iframe title attribute

name string <optional>

if passed it will be assigned to the iframe name attribute

id string <optional>

if passed it will be assigned to the iframe id attribute

allowfullscreen boolean <optional>

if passed and different than false it will be assigned to the iframe allowfullscreen attribute

sandbox string <optional>

if passed it will be assigned to the iframe sandbox attribute (we do not validate the syntax so be careful!!)

parenturlparam string <optional>

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

parenturlvalue string <optional>

if passed it will be override the default parentUrl query string parameter value passed to the iframe src

optionalparams string <optional>

if passed and different than false it will strip the querystring params parentUrl and parentTitle passed to the iframe src

trackscroll boolean <optional>

if passed it will activate scroll tracking on the parent

scrollwait number <optional>

if passed it will set the throttle wait in order to fire scroll messaging. Defaults to 100 ms.

Source:
See:

Members

(inner) el :HTMLElement

The container DOM object

Type:
  • HTMLElement
Source:

(inner) id :string

The id of the container element

Type:
  • string
Source:

(inner) iframe :HTMLElement

The contained child iframe

Type:
  • HTMLElement
Default Value:
  • null
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) settings :Object

The parent instance settings, updated by the values passed in the config object

Type:
  • Object
Source:

(inner) url :String

The url that will be set as the iframe's src

Type:
  • String
Source:

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.

Source:

remove()

Remove this parent from the page and unbind it's event handlers.

Source:

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.

Source:

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.

Source:

sendWidth()

Transmit the current iframe width to the child.

You shouldn't need to call this directly.

Source:

(inner) _constructIframe()

Construct the iframe.

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) _onHeightMessage(message)

Resize iframe in response to new height message from child.

Parameters:
Name Type Description
message String

The new height.

Source:

(inner) _onNavigateToMessage(message)

Navigate parent to a new url.

Parameters:
Name Type Description
message String

The url to navigate to.

Source:

(inner) _onResize()

Send width on resize.

Source:

(inner) _onScroll()

Send viewport and iframe info on scroll.

Source:

(inner) _onScrollToChildPosMessage(message)

Scroll parent to a given child position.

Parameters:
Name Type Description
message String

The offset inside the child page.

Source:

(inner) _processMessage(e)

Process a new message from the child.

Parameters:
Name Type Description
e Event

A message event.

Source:

(inner) _throttleOnScroll()

Throttled scroll function.

Source:

Type Definitions

onMessageCallback(message)

Parameters:
Name Type Description
message String

The message data.

Source: