From b7f417c29d8c2f4c7bb996b5a79986f9ae0402ac Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 24 Feb 2013 07:48:25 +0000 Subject: [PATCH] use Ox.Message --- pandora/text/templates/pdf/viewer.html | 1 + static/js/pandora.js | 19 ++++--- static/js/pandora/embedPanel.js | 3 + static/js/pandora/mainMenu.js | 8 +-- static/js/pandora/textPanel.js | 24 +++++--- static/pdf.js/embeds.js | 79 ++++++++++++++++---------- 6 files changed, 81 insertions(+), 53 deletions(-) diff --git a/pandora/text/templates/pdf/viewer.html b/pandora/text/templates/pdf/viewer.html index 19031d09..2bd84e56 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 690d21d0..1ba0e061 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 0fbebb65..13d8d4a0 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 90999e26..7f264ba9 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 5e27e47b..b6ae48e3 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) { - $('