2018-05-16 00:53:27 +00:00
|
|
|
/* eslint-disable no-var */
|
|
|
|
/* globals $, svgCanvas, svgEditor */
|
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)
|
|
|
|
|
2018-05-16 00:53:27 +00:00
|
|
|
svgEditor.addExtension('php_savefile', {
|
2018-05-18 04:54:31 +00:00
|
|
|
callback: function () {
|
|
|
|
'use strict';
|
|
|
|
function getFileNameFromTitle () {
|
|
|
|
var title = svgCanvas.getDocumentTitle();
|
|
|
|
return $.trim(title);
|
|
|
|
}
|
|
|
|
var saveSvgAction = svgEditor.curConfig.extPath + 'savefile.php';
|
|
|
|
svgEditor.setCustomHandlers({
|
|
|
|
save: function (win, data) {
|
|
|
|
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
|
|
|
filename = getFileNameFromTitle();
|
2014-01-31 12:58:16 +00:00
|
|
|
|
2018-05-18 04:54:31 +00:00
|
|
|
$.post(saveSvgAction, {output_svg: svg, filename: filename});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-31 12:58:16 +00:00
|
|
|
});
|