/* * ext-imagelib.js * * Licensed under the Apache License, Version 2 * * Copyright(c) 2010 Alexis Deveria * */ svgEditor.addExtension("imagelib", function() { var img_libs = [{ name: 'Demo library (local)', url: 'extensions/imagelib/index.html', description: 'Demonstration library for SVG-edit on this server' }, { name: 'Demo library (external)', url: 'http://a.deveria.com/tests/clip-art/', description: 'Demonstration library for SVG-edit on another domain' } ]; function closeBrowser() { $('#imgbrowse_holder').hide(); } window.addEventListener("message", function(evt) { // Receive postMessage data var response = evt.data; if(!response) { $.alert('No data was given', closeBrowser); return; } var char1 = response.charAt(0); switch (char1) { case '<': svgCanvas.importSvgString(response); break; case 'd': if(response.indexOf('data:') === 0) { var pre = 'data:image/svg+xml;base64,'; var src = response.substring(pre.length); svgCanvas.importSvgString(svgCanvas.Utils.decode64(src)); break; } // Else fall through default: $.alert('Unexpected data was returned', closeBrowser); return; } closeBrowser(); }, true); function showBrowser() { var browser = $('#imgbrowse'); if(!browser.length) { $('
\
').insertAfter('#svg_docprops'); browser = $('#imgbrowse'); var all_libs = 'Select an image library'; var lib_opts = $('