textPanel: post message when loading new embed url

This commit is contained in:
rolux 2013-02-22 02:20:12 +00:00
parent 6605fb7b38
commit b923aab424

View file

@ -173,7 +173,8 @@ pandora.ui.textPanel = function() {
return urls; return urls;
} }
function selectEmbed(selected) { function selectEmbed(index) {
selected = index;
pandora.$ui.textEmbed.update(embedURLs[selected]); pandora.$ui.textEmbed.update(embedURLs[selected]);
} }
@ -352,9 +353,23 @@ pandora.ui.textEmbed = function(url) {
.appendTo(that); .appendTo(that);
that.update = function(url) { that.update = function(url) {
var parsed, src;
if (url) { if (url) {
url = url.replace(/&/g, '&') + '&matchRatio=true'; 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(); $message.hide();
$iframe.show(); $iframe.show();
} else { } else {