Fix local part of issue 759 - Image library not working in embedded editor. IAN image library issue still needs addressed

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1924 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Will Schleter
2011-01-16 22:11:27 +00:00
parent ff498b5bc7
commit 71dc44137d

View File

@@ -14,7 +14,7 @@
$('a').click(function() { $('a').click(function() {
var href = this.href; var href = this.href;
var target = window.parent;
// Convert Non-SVG images to data URL first // Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library) // (this could also have been done server-side by the library)
if(this.href.indexOf('.svg') === -1) { if(this.href.indexOf('.svg') === -1) {
@@ -23,7 +23,7 @@ $('a').click(function() {
name: $(this).text(), name: $(this).text(),
id: href id: href
}); });
window.top.postMessage(meta_str, "*"); target.postMessage(meta_str, "*");
var img = new Image(); var img = new Image();
img.onload = function() { img.onload = function() {
@@ -40,7 +40,7 @@ $('a').click(function() {
alert("Data URL conversion failed: " + err); alert("Data URL conversion failed: " + err);
var dataurl = ""; var dataurl = "";
} }
window.top.postMessage('|' + href + '|' + dataurl, "*"); target.postMessage('|' + href + '|' + dataurl, "*");
} }
img.src = href; img.src = href;
} else { } else {
@@ -49,12 +49,12 @@ $('a').click(function() {
name: $(this).text(), name: $(this).text(),
id: href id: href
}); });
window.top.postMessage(meta_str, "*"); target.postMessage(meta_str, "*");
// Do ajax request for image's href value // Do ajax request for image's href value
$.get(href, function(data) { $.get(href, function(data) {
data = '|' + href + '|' + data; data = '|' + href + '|' + data;
// This is where the magic happens! // This is where the magic happens!
window.top.postMessage(data, "*"); target.postMessage(data, "*");
}, 'html'); // 'html' is necessary to keep returned data as a string }, 'html'); // 'html' is necessary to keep returned data as a string
} }