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 ( ) ;
return $ . trim ( title ) ; // .replace(/[^a-z0-9\.\_\-]+/gi, '_'); // We could do this more stringent client-side filtering, but we need to do on the server anyways
}
var save _svg _action = 'extensions/savefile.php' ;
svgEditor . setCustomHandlers ( {
save : function ( win , data ) {
var svg = "<?xml version=\"1.0\"?>\n" + data ,
filename = getFileNameFromTitle ( ) ;
$ . post ( save _svg _action , { output _svg : svg , filename : filename } ) ;
}
} ) ;
}
} ) ;
this . saveHandler = function ( svg ) { 'use strict' ;
$ . post ( "svg-editor-save.php" , { svg _data : svg } ) ;
} ;