From da89475bad096b910040dcb71082051f9736faa1 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 24 Feb 2013 09:38:56 +0000 Subject: [PATCH] fix pdf embed postMessage --- static/pdf.js/embeds.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/static/pdf.js/embeds.js b/static/pdf.js/embeds.js index 965b50fba..39bca21f8 100644 --- a/static/pdf.js/embeds.js +++ b/static/pdf.js/embeds.js @@ -3,6 +3,30 @@ Ox.Message.bind(function(event, data, oxid) { //process messages here } }); +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; + } +}; function getEmbedURL(id, videoURL) { var parsed = Ox.parseURL(videoURL),