ext-php_savefile.js 695 B

1234567891011121314151617181920212223
  1. /*globals $, svgCanvas, svgEditor*/
  2. /*jslint regexp:true*/
  3. // TODO: Might add support for "exportImage" custom
  4. // handler as in "ext-server_opensave.js" (and in savefile.php)
  5. svgEditor.addExtension("php_savefile", {
  6. callback: function() {
  7. 'use strict';
  8. function getFileNameFromTitle () {
  9. var title = svgCanvas.getDocumentTitle();
  10. return $.trim(title);
  11. }
  12. var save_svg_action = svgEditor.curConfig.extPath + 'savefile.php';
  13. svgEditor.setCustomHandlers({
  14. save: function(win, data) {
  15. var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
  16. filename = getFileNameFromTitle();
  17. $.post(save_svg_action, {output_svg: svg, filename: filename});
  18. }
  19. });
  20. }
  21. });