adding load from url
parent
71085b7e14
commit
e9b482e561
|
@ -96,7 +96,6 @@ MD.Import = function(){
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onloadend = function(e) {
|
reader.onloadend = function(e) {
|
||||||
loadSvgString(e.target.result);
|
loadSvgString(e.target.result);
|
||||||
editor.saveCanvas();
|
|
||||||
editor.canvas.update(true);
|
editor.canvas.update(true);
|
||||||
};
|
};
|
||||||
reader.readAsText(f.files[0]);
|
reader.readAsText(f.files[0]);
|
||||||
|
@ -135,5 +134,6 @@ MD.Import = function(){
|
||||||
|
|
||||||
this.place = place;
|
this.place = place;
|
||||||
this.open = open;
|
this.open = open;
|
||||||
|
this.loadSvgString = loadSvgString;
|
||||||
|
|
||||||
}
|
}
|
|
@ -349,6 +349,25 @@ MD.Editor = function(){
|
||||||
editor.modal.source.open();
|
editor.modal.source.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadFromUrl(url, cb){
|
||||||
|
if(!cb) cb = function(){/*noop*/};
|
||||||
|
$.ajax({
|
||||||
|
'url': url,
|
||||||
|
'dataType': 'text',
|
||||||
|
cache: false,
|
||||||
|
success: function(str) {
|
||||||
|
editor.import.loadSvgString(str, cb);
|
||||||
|
},
|
||||||
|
error: function(xhr, stat, err) {
|
||||||
|
if(xhr.status != 404 && xhr.responseText) {
|
||||||
|
editor.import.loadSvgString(xhr.responseText, cb);
|
||||||
|
} else {
|
||||||
|
$.alert("Unable to load from URL" + ": \n"+err+'', cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.el = el;
|
this.el = el;
|
||||||
this.selectedChanged = selectedChanged;
|
this.selectedChanged = selectedChanged;
|
||||||
this.elementChanged = elementChanged;
|
this.elementChanged = elementChanged;
|
||||||
|
@ -387,6 +406,7 @@ MD.Editor = function(){
|
||||||
this.donate = donate;
|
this.donate = donate;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.saveCanvas = saveCanvas;
|
this.saveCanvas = saveCanvas;
|
||||||
|
this.loadFromUrl = loadFromUrl;
|
||||||
|
|
||||||
this.export = function(){
|
this.export = function(){
|
||||||
if(window.canvg) {
|
if(window.canvg) {
|
||||||
|
|
Loading…
Reference in New Issue