2014-01-31 12:58:16 +00:00
|
|
|
/*globals $, svgCanvas, svgEditor*/
|
|
|
|
/*jslint regexp:true*/
|
2014-01-31 13:12:52 +00:00
|
|
|
// TODO: Might add support for "exportImage" custom
|
|
|
|
// handler as in "ext-server_opensave.js" (and in savefile.php)
|
|
|
|
|
2014-01-31 12:58:16 +00:00
|
|
|
svgEditor.addExtension("php_savefile", {
|
|
|
|
callback: function() {
|
|
|
|
'use strict';
|
|
|
|
function getFileNameFromTitle () {
|
|
|
|
var title = svgCanvas.getDocumentTitle();
|
2014-02-01 16:13:51 +00:00
|
|
|
return $.trim(title);
|
2014-01-31 12:58:16 +00:00
|
|
|
}
|
2014-02-12 03:48:48 +00:00
|
|
|
var save_svg_action = svgEditor.curConfig.extPath + 'savefile.php';
|
2014-01-31 12:58:16 +00:00
|
|
|
svgEditor.setCustomHandlers({
|
|
|
|
save: function(win, data) {
|
2014-02-01 16:42:46 +00:00
|
|
|
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
2014-01-31 12:58:16 +00:00
|
|
|
filename = getFileNameFromTitle();
|
|
|
|
|
|
|
|
$.post(save_svg_action, {output_svg: svg, filename: filename});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|