Added file select option for raster images in server_open extension. Also added Uploading file dialog box for server-based uploads

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1624 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2010-07-05 15:38:06 +00:00
parent d80dd06bad
commit c0fa1ef4b1
5 changed files with 68 additions and 12 deletions

View File

@@ -12,6 +12,8 @@ svgEditor.addExtension("server_open", {
// Do nothing if client support is found
if(window.FileReader) return;
var cancelled = false;
// Change these to appropriate script file
var open_svg_action = 'extensions/fileopen.php?type=load_svg';
var import_svg_action = 'extensions/fileopen.php?type=import_svg';
@@ -19,7 +21,16 @@ svgEditor.addExtension("server_open", {
// Set up function for PHP uploader to use
svgEditor.processFile = function(str64, type) {
var xmlstr = svgCanvas.Utils.decode64(str64);
if(cancelled) {
cancelled = false;
return;
}
$('#dialog_box').hide();
if(type != 'import_img') {
var xmlstr = svgCanvas.Utils.decode64(str64);
}
switch ( type ) {
case 'load_svg':
@@ -31,6 +42,9 @@ svgEditor.addExtension("server_open", {
svgCanvas.importSvgString(xmlstr);
svgEditor.updateCanvas();
break;
case 'import_img':
svgCanvas.setGoodImage(str64);
break;
}
}
@@ -55,6 +69,18 @@ svgEditor.addExtension("server_open", {
form.empty();
var inp = $('<input type="file" name="svg_file">').appendTo(form);
function submit() {
// This submits the form, which returns the file data using svgEditor.uploadSVG
form.submit();
rebuildInput(form);
$.process_cancel("Uploading...", function() {
cancelled = true;
$('#dialog_box').hide();
});
}
if(form[0] == open_svg_form[0]) {
inp.change(function() {
// This takes care of the "are you sure" dialog box
@@ -63,17 +89,13 @@ svgEditor.addExtension("server_open", {
rebuildInput(form);
return;
}
// This submits the form, which returns the file data using svgEditor.uploadSVG
form.submit();
rebuildInput(form);
submit();
});
});
} else {
inp.change(function() {
// This submits the form, which returns the file data using svgEditor.uploadSVG
form.submit();
rebuildInput(form);
submit();
});
}
}
@@ -89,6 +111,7 @@ svgEditor.addExtension("server_open", {
// Add forms to buttons
$("#tool_open").show().prepend(open_svg_form);
$("#tool_import").show().prepend(import_svg_form);
$("#tool_image").prepend(import_img_form);
}
});