Ox.parent -> Ox.

This commit is contained in:
rlx 2014-09-25 18:30:49 +02:00
parent 41bf6ac372
commit 86f1bad4eb

View file

@ -63,13 +63,13 @@
if (message.data.oxid) { if (message.data.oxid) {
// The inner window receives the oxid of the outer iframe element // The inner window receives the oxid of the outer iframe element
Ox.oxid = message.data.oxid; Ox.oxid = message.data.oxid;
Ox.parent.postMessage('init', {}) Ox.$parent.postMessage('init', {})
} else if (message.target) { } else if (message.target) {
// The outer window receives init from iframe // The outer window receives init from iframe
Ox.elements[message.target].triggerEvent('init'); Ox.elements[message.target].triggerEvent('init');
} }
} else { } else {
(message.target ? Ox.elements[message.target] : Ox.parent) (message.target ? Ox.elements[message.target] : Ox.$parent)
.triggerMessage(message.event, message.data); .triggerMessage(message.event, message.data);
} }
} }
@ -186,9 +186,9 @@
} }
/*@ /*@
Ox.parent <o> Proxy to be used by iframes for messaging with outer window Ox.$parent <o> Proxy to be used by iframes for messaging with outer window
@*/ @*/
Ox.parent = Ox.$parent = (function() { Ox.$parent = (function() {
var self = {messageCallbacks: {}}, var self = {messageCallbacks: {}},
that = {oxid: Ox.uid()}; that = {oxid: Ox.uid()};
@ -374,7 +374,7 @@
Adds handlers for multiple messages Adds handlers for multiple messages
self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`) self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`)
If `self` is missing and this method is not rebound, then the If `self` is missing and this method is not rebound, then the
handler is bound to the outer window (via `Ox.parent`) handler is bound to the outer window (via `Ox.$parent`)
message <s> Message name message <s> Message name
callback <f> Callback function callback <f> Callback function
data <o> Message data (key/value pairs) data <o> Message data (key/value pairs)
@ -399,7 +399,7 @@
Adds handlers for multiple messages Adds handlers for multiple messages
self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`) self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`)
If `self` is missing and this method is not rebound, then the If `self` is missing and this method is not rebound, then the
handler is bound to the outer window (via `Ox.parent`) handler is bound to the outer window (via `Ox.$parent`)
message <s> Message name message <s> Message name
callback <f> Callback function callback <f> Callback function
data <o> Message data (key/value pairs) data <o> Message data (key/value pairs)
@ -425,7 +425,7 @@
data <o> Message data (key/value pairs) data <o> Message data (key/value pairs)
@*/ @*/
that.post = function() { that.post = function() {
var isParent = this == Ox.parent, var isParent = this == Ox.$parent,
target = isParent ? window.parent : this[0].contentWindow; target = isParent ? window.parent : this[0].contentWindow;
Ox.forEach( Ox.forEach(
Ox.makeObject(Ox.slice(arguments)), Ox.makeObject(Ox.slice(arguments)),
@ -472,7 +472,7 @@
Removes handlers for multiple messages Removes handlers for multiple messages
self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`) self <o> Object with `messageCallbacks` (`Ox.Element`'s `self`)
If `self` is missing and this method is not rebound, then the If `self` is missing and this method is not rebound, then the
handler is bound to the outer window (via `Ox.parent`) handler is bound to the outer window (via `Ox.$parent`)
message <s> Message name message <s> Message name
callback <f> Message handler callback <f> Message handler
@*/ @*/