/* eslint-disable no-var */ /* globals svgEditor, svgedit, svgCanvas, canvg, $ */ /* * ext-server_opensave.js * * Licensed under the MIT License * * Copyright(c) 2010 Alexis Deveria * */ svgEditor.addExtension('server_opensave', { callback: function () { 'use strict'; function getFileNameFromTitle () { var title = svgCanvas.getDocumentTitle(); // We convert (to underscore) only those disallowed Win7 file name characters return $.trim(title).replace(/[/\\:*?"<>|]/g, '_'); } function xhtmlEscape (str) { return str.replace(/&(?!amp;)/g, '&').replace(/"/g, '"').replace(/')[0].download === ''; if (support) { a = $('hidden').attr({download: (filename || 'image') + suffix, href: uri}).css('display', 'none').appendTo('body'); a[0].click(); return true; } } var openSvgAction, importSvgAction, importImgAction, openSvgForm, importSvgForm, importImgForm, saveSvgAction = svgEditor.curConfig.extPath + 'filesave.php', saveImgAction = svgEditor.curConfig.extPath + 'filesave.php', // Create upload target (hidden iframe) cancelled = false, Utils = svgedit.utilities; $('').hide().appendTo('body'); svgEditor.setCustomHandlers({ save: function (win, data) { var svg = '\n' + data, // Firefox doesn't seem to know it is UTF-8 (no matter whether we use or skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works filename = getFileNameFromTitle(); if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + Utils.encode64(svg))) { return; } $('