diff --git a/source/Ox.UI/Ox.UI.js b/source/Ox.UI/Ox.UI.js index 84f42542..b9a941d6 100644 --- a/source/Ox.UI/Ox.UI.js +++ b/source/Ox.UI/Ox.UI.js @@ -287,32 +287,6 @@ Ox.load.UI = function(options, callback) { Ox.$document = Ox.UI.$document = $(document); Ox.$head = Ox.UI.$head = $('head'); Ox.$window = Ox.UI.$window = $(window); - Ox.$parent = { - postMessage: function(event, message) { - Ox.Message.post(Ox.$parent, event, message); - return this; - }, - onMessage: function() { - var callback; - if (Ox.isObject(arguments[0])) { - Ox.forEach(arguments[0], function(callback, event) { - Ox.Message.bind(function(event_, data, oxid) { - if (event_ == event && Ox.isUndefined(oxid)) { - callback(data || {}); - } - }); - }); - } else { - callback = arguments[0]; - Ox.Message.bind(function(event, data, oxid) { - if (Ox.isUndefined(oxid)) { - callback(event, data || {}); - } - }); - } - return this; - } - }; // fixme: is this the right place to do this? $.browser.mozilla && Ox.$document.on('dragstart', function() { return false; diff --git a/source/Ox.UI/js/Core/Message.js b/source/Ox.UI/js/Core/Message.js index 1cfd105d..16e4dcff 100644 --- a/source/Ox.UI/js/Core/Message.js +++ b/source/Ox.UI/js/Core/Message.js @@ -24,6 +24,34 @@ Ox.Message = (function() { } }); + // Defined here so one can just load Message.js in addtion to Ox.js + Ox.$parent = { + postMessage: function(event, message) { + Ox.Message.post(Ox.$parent, event, message); + return this; + }, + onMessage: function() { + var callback; + if (Ox.isObject(arguments[0])) { + Ox.forEach(arguments[0], function(callback, event) { + Ox.Message.bind(function(event_, data, oxid) { + if (event_ == event && Ox.isUndefined(oxid)) { + callback(data || {}); + } + }); + }); + } else { + callback = arguments[0]; + Ox.Message.bind(function(event, data, oxid) { + if (Ox.isUndefined(oxid)) { + callback(event, data || {}); + } + }); + } + return this; + } + }; + /*@ .bind Adds message handler (callback) -> Ox.Message @@ -45,7 +73,7 @@ Ox.Message = (function() { that.post = function(target, event, data) { target = target == Ox.$parent ? window.parent : Ox.isElement(target[0]) ? target[0].contentWindow - : $('#' + target)[0].contentWindow; + : Ox.$('#' + target)[0].contentWindow; target.postMessage(JSON.stringify({ event: event, data: data,