diff --git a/pandora/text/templates/pdf/viewer.html b/pandora/text/templates/pdf/viewer.html index 19031d09f..2bd84e563 100644 --- a/pandora/text/templates/pdf/viewer.html +++ b/pandora/text/templates/pdf/viewer.html @@ -23,6 +23,7 @@ limitations under the License. + diff --git a/static/js/pandora.js b/static/js/pandora.js index 690d21d07..1ba0e061b 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -314,15 +314,16 @@ appPanel Ox.Theme(pandora.user.ui.theme); if (isEmbed) { pandora.$ui.embedPanel = pandora.ui.embedPanel().display(); - window.addEventListener('message', function(e) { - var data = {}; - try { - data = JSON.parse(e.data); - } catch(e) {} - if (Ox.contains(pandora.site.themes, data.theme)) { - Ox.Theme(data.theme); - } else if (pandora.isEmbedURL(data.url)) { - pandora.URL.push(data.url); + Ox.$parent.onMessage({ + settheme: function(data) { + if (Ox.contains(pandora.site.themes, data.theme)) { + Ox.Theme(data.theme); + } + }, + seturl: function(data) { + if (pandora.isEmbedURL(data.url)) { + pandora.URL.push(data.url); + } } }); } else { diff --git a/static/js/pandora/embedPanel.js b/static/js/pandora/embedPanel.js index 0fbebb658..13d8d4a06 100644 --- a/static/js/pandora/embedPanel.js +++ b/static/js/pandora/embedPanel.js @@ -126,6 +126,9 @@ pandora.ui.embedPanel = function() { type: data.timeline }); } + }) + .bindEvent(function(data, event) { + Ox.$parent.postMessage(event, {}); }); $controls = Ox.Element(); diff --git a/static/js/pandora/mainMenu.js b/static/js/pandora/mainMenu.js index 90999e268..7f264ba97 100644 --- a/static/js/pandora/mainMenu.js +++ b/static/js/pandora/mainMenu.js @@ -230,13 +230,11 @@ pandora.ui.mainMenu = function() { var iframe, src; Ox.Theme(value); pandora.UI.set('theme', value); - iframe = $('#embed')[0]; + iframe = Ox.UI.elements[$('#embed').data('oxid')]; if (iframe) { - src = $(iframe).attr('src'); + src = iframe.attr('src'); if (src && Ox.parseURL(src).hostname == document.location.hostname) { - iframe.contentWindow.postMessage(JSON.stringify({ - theme: value - }), '*'); + iframe.postMessage('settheme', {theme: value}); } } } else if (data.id == 'showsiteposters') { diff --git a/static/js/pandora/textPanel.js b/static/js/pandora/textPanel.js index 5e27e47bb..b6ae48e3c 100644 --- a/static/js/pandora/textPanel.js +++ b/static/js/pandora/textPanel.js @@ -321,17 +321,25 @@ pandora.ui.textHTML = function(text) { pandora.ui.textPDF = function(text) { - var that = Ox.Element(); + var that = Ox.Element(), + $iframe; if (text.uploaded) { - $('