xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var svgEditorExtension_php_savefile = (function () {
  'use strict';
 
  /* globals jQuery */
  // TODO: Might add support for "exportImage" custom
  //   handler as in "ext-server_opensave.js" (and in savefile.php)
  var extPhp_savefile = {
    name: 'php_savefile',
    init: function init() {
      var svgEditor = this;
      var $ = jQuery;
      var svgCanvas = svgEditor.canvas;
 
      function getFileNameFromTitle() {
        var title = svgCanvas.getDocumentTitle();
        return title.trim();
      }
 
      var saveSvgAction = svgEditor.curConfig.extPath + 'savefile.php';
      svgEditor.setCustomHandlers({
        save: function save(win, data) {
          var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
              filename = getFileNameFromTitle();
          $.post(saveSvgAction, {
            output_svg: svg,
            filename: filename
          });
        }
      });
    }
  };
 
  return extPhp_savefile;
 
}());