Qs_Form_Element_SvgEditor = { options: { jsLoadFiles: false, currentSvg: null, currentJpg: null, editorOptions: {} }, svgCanvas: null, svgEditor: null, emptySvg: null, init: function (options) { Qs_Form_Element_SvgEditor.options = $.extend({}, Qs_Form_Element_SvgEditor.options, options); Qs_Form_Element_SvgEditor.initEmbed(); if (false !== Qs_Form_Element_SvgEditor.options.jsLoadFiles) { Qs_Form_Element_SvgEditor.loadSvgFromServer(); } }, initEmbed: function () { var frame = document.getElementById('svgedit'); Qs_Form_Element_SvgEditor.svgEditor = frame.contentWindow.svgEditor; $('#btnSubmit').bind('click', function(){Qs_Form_Element_SvgEditor.saveSvg()}); }, loadSvgFromServer: function () { var imagePath = Qs_Form_Element_SvgEditor.options.editorOptions.ImagePath, jpg = Qs_Form_Element_SvgEditor.options.currentJpg, svg = Qs_Form_Element_SvgEditor.options.currentSvg, jpgFull = imagePath + jpg, svgFull = imagePath + svg; if (jpg) { Qs_Form_Element_SvgEditor.svgEditor.ready(function () { Qs_Form_Element_SvgEditor.svgEditor.canvas.setBackground('#fff', jpgFull); }); } if (svg) { Qs_Form_Element_SvgEditor.svgEditor.ready(function () { try { Qs_Form_Element_SvgEditor.svgEditor.loadFromURL(svgFull); } catch (e) { alert(e.message); } }); } }, saveSvg: function () { var svg_text = Qs_Form_Element_SvgEditor.svgEditor.canvas.getSvgString(); $('#' + Qs_Form_Element_SvgEditor.options.editorOptions.elementName + '-svgData').val(base64_encode(svg_text)); } }