Parent

pym. Parent

new Parent(id, url, configopt)

The Parent half of a response iframe.

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

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.

Members

(inner) el :HTMLElement

The container DOM object

Source:
Type:
  • HTMLElement

(inner) id :string

The id of the container element

Source:
Type:
  • string

(inner) iframe :HTMLElement

The contained child iframe

Default Value:
  • null
Source:
Type:
  • HTMLElement

(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) settings :Object

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

Source:
Type:
  • Object

(inner) url :String

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

Source:
Type:
  • String

Methods

onMessage(messageType, callback)

Bind a callback to a given messageType from the child.

Reserved message names are: "height", "scrollTo" and "navigateTo".

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

Source:

sendMessage(messageType, message)

Send a message to the the child.

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

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.

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

Source:
Parameters:
Name Type Description
message String

The new height.

(inner) _onNavigateToMessage(message)

Navigate parent to a new url.

Source:
Parameters:
Name Type Description
message String

The url to navigate to.

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

Source:
Parameters:
Name Type Description
message String

The offset inside the child page.

(inner) _processMessage(e)

Process a new message from the child.

Source:
Parameters:
Name Type Description
e Event

A message event.

(inner) _throttleOnScroll()

Throttled scroll function.

Source:

Type Definitions

onMessageCallback(message)

Source:
Parameters:
Name Type Description
message String

The message data.