1
0
Fork 0
forked from 0x2620/oxjs

add Ox.Message for message passing between frame and parent

This commit is contained in:
j 2013-02-24 07:37:20 +00:00
commit 47efc7377a
3 changed files with 107 additions and 0 deletions

View file

@ -287,6 +287,30 @@ 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(event, message);
return this;
},
onMessage: function() {
var callback;
if (Ox.isObject(arguments[0])) {
Ox.forEach(arguments[0], function(callback, event) {
Ox.Message.bind(function(evt, data, oxid) {
if (Ox.isUndefined(oxid) && event == evt) {
callback(data);
}
});
});
} else {
callback = arguments[0];
Ox.Message.bind(function(event, data, oxid) {
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;