From b923aab424e9e8e48ac1ee425127f6a44164f8e6 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 22 Feb 2013 02:20:12 +0000 Subject: [PATCH] textPanel: post message when loading new embed url --- static/js/pandora/textPanel.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/static/js/pandora/textPanel.js b/static/js/pandora/textPanel.js index 4762691df..9d8ddead1 100644 --- a/static/js/pandora/textPanel.js +++ b/static/js/pandora/textPanel.js @@ -173,7 +173,8 @@ pandora.ui.textPanel = function() { return urls; } - function selectEmbed(selected) { + function selectEmbed(index) { + selected = index; pandora.$ui.textEmbed.update(embedURLs[selected]); } @@ -352,9 +353,23 @@ pandora.ui.textEmbed = function(url) { .appendTo(that); that.update = function(url) { + var parsed, src; if (url) { url = url.replace(/&/g, '&') + '&matchRatio=true'; - $iframe[0].contentWindow.postMessage(url); + src = $iframe.attr('src'); + parsed = {src: Ox.parseURL(src), url: Ox.parseURL(url)}; + if ( + src + && parsed.url.protocol == parsed.src.protocol + && parsed.url.hostname == parsed.src.hostname + ) { + $iframe[0].contentWindow.postMessage( + parsed.url.pathname + parsed.url.search + parsed.url.hash, + '*' + ); + } else { + $iframe.attr({src: url}); + } $message.hide(); $iframe.show(); } else {