Tab fixes
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2651 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -2,41 +2,41 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Embed API</title>
|
<title>Embed API</title>
|
||||||
<script src="jquery.js"></script>
|
<script src="jquery.js"></script>
|
||||||
<script src="embedapi.js"></script>
|
<script src="embedapi.js"></script>
|
||||||
<script>
|
<script>
|
||||||
/*globals $, EmbeddedSVGEdit*/
|
/*globals $, EmbeddedSVGEdit*/
|
||||||
$(function () {'use strict';
|
$(function () {'use strict';
|
||||||
|
|
||||||
var svgCanvas = null;
|
var svgCanvas = null;
|
||||||
|
|
||||||
function initEmbed() {
|
function initEmbed() {
|
||||||
var doc, mainButton,
|
var doc, mainButton,
|
||||||
frame = document.getElementById('svgedit');
|
frame = document.getElementById('svgedit');
|
||||||
svgCanvas = new EmbeddedSVGEdit(frame);
|
svgCanvas = new EmbeddedSVGEdit(frame);
|
||||||
// Hide main button, as we will be controlling new, load, save, etc. from the host document
|
// Hide main button, as we will be controlling new, load, save, etc. from the host document
|
||||||
doc = frame.contentDocument || frame.contentWindow.document;
|
doc = frame.contentDocument || frame.contentWindow.document;
|
||||||
mainButton = doc.getElementById('main_button');
|
mainButton = doc.getElementById('main_button');
|
||||||
mainButton.style.display = 'none';
|
mainButton.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSvgData(data, error) {
|
function handleSvgData(data, error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
alert('error ' + error);
|
alert('error ' + error);
|
||||||
} else {
|
} else {
|
||||||
alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data);
|
alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSvg() {
|
function loadSvg() {
|
||||||
var svgexample = '<svg width="640" height="480" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><g><title>Layer 1</title><rect stroke-width="5" stroke="#000000" fill="#FF0000" id="svg_1" height="35" width="51" y="35" x="32"/><ellipse ry="15" rx="24" stroke-width="5" stroke="#000000" fill="#0000ff" id="svg_2" cy="60" cx="66"/></g></svg>';
|
var svgexample = '<svg width="640" height="480" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><g><title>Layer 1</title><rect stroke-width="5" stroke="#000000" fill="#FF0000" id="svg_1" height="35" width="51" y="35" x="32"/><ellipse ry="15" rx="24" stroke-width="5" stroke="#000000" fill="#0000ff" id="svg_2" cy="60" cx="66"/></g></svg>';
|
||||||
svgCanvas.setSvgString(svgexample);
|
svgCanvas.setSvgString(svgexample);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSvg() {
|
function saveSvg() {
|
||||||
svgCanvas.getSvgString()(handleSvgData);
|
svgCanvas.getSvgString()(handleSvgData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
$('#load').click(loadSvg);
|
$('#load').click(loadSvg);
|
||||||
@@ -45,12 +45,12 @@
|
|||||||
// Export globals
|
// Export globals
|
||||||
window.initEmbed = initEmbed;
|
window.initEmbed = initEmbed;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<button id="load">Load example</button>
|
<button id="load">Load example</button>
|
||||||
<button id="save">Save data</button>
|
<button id="save">Save data</button>
|
||||||
<br/>
|
<br/>
|
||||||
<iframe src="svg-editor.html" width="900px" height="600px" id="svgedit" onload="initEmbed();"></iframe>
|
<iframe src="svg-editor.html" width="900px" height="600px" id="svgedit" onload="initEmbed();"></iframe>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -61,31 +61,32 @@ function EmbeddedSVGEdit(frame){
|
|||||||
// List of functions extracted with this:
|
// List of functions extracted with this:
|
||||||
// Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html
|
// Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html
|
||||||
|
|
||||||
//for(var i=0,q=[],f = document.querySelectorAll("div.CFunction h3.CTitle a");i<f.length;i++){q.push(f[i].name)};q
|
// for (var i=0,q=[],f = document.querySelectorAll("div.CFunction h3.CTitle a"); i < f.length; i++) { q.push(f[i].name); }; q
|
||||||
//var functions = ["clearSelection", "addToSelection", "removeFromSelection", "open", "save", "getSvgString", "setSvgString",
|
// var functions = ["clearSelection", "addToSelection", "removeFromSelection", "open", "save", "getSvgString", "setSvgString",
|
||||||
//"createLayer", "deleteCurrentLayer", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition", "setLayerVisibility",
|
// "createLayer", "deleteCurrentLayer", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition", "setLayerVisibility",
|
||||||
//"moveSelectedToLayer", "clear"];
|
// "moveSelectedToLayer", "clear"];
|
||||||
|
|
||||||
// Newer, well, it extracts things that aren't documented as well. All functions accessible through the normal thingy can now be accessed though the API
|
// Newer, well, it extracts things that aren't documented as well. All functions accessible through the normal thingy can now be accessed though the API
|
||||||
// var l = []; for (var i in svgCanvas){ if (typeof svgCanvas[i] == "function") { l.push(i);} };
|
// var l = []; for (var i in svgCanvas){ if (typeof svgCanvas[i] == "function") { l.push(i);} };
|
||||||
// Run in svgedit itself
|
// Run in svgedit itself
|
||||||
var i,
|
var i,
|
||||||
t = this,
|
t = this,
|
||||||
functions = ["updateElementFromJson", "embedImage", "fixOperaXML", "clearSelection", "addToSelection",
|
functions = ["updateElementFromJson", "embedImage", "fixOperaXML", "clearSelection",
|
||||||
"removeFromSelection", "addNodeToSelection", "open", "save", "getSvgString", "setSvgString", "createLayer",
|
"addToSelection",
|
||||||
"deleteCurrentLayer", "getCurrentDrawing", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition",
|
"removeFromSelection", "addNodeToSelection", "open", "save", "getSvgString", "setSvgString", "createLayer",
|
||||||
"setLayerVisibility", "moveSelectedToLayer", "clear", "clearPath", "getNodePoint", "clonePathNode", "deletePathNode",
|
"deleteCurrentLayer", "getCurrentDrawing", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition",
|
||||||
"getResolution", "getImageTitle", "setImageTitle", "setResolution", "setBBoxZoom", "setZoom", "getMode", "setMode",
|
"setLayerVisibility", "moveSelectedToLayer", "clear", "clearPath", "getNodePoint", "clonePathNode", "deletePathNode",
|
||||||
"getStrokeColor", "setStrokeColor", "getFillColor", "setFillColor", "setStrokePaint", "setFillPaint", "getStrokeWidth",
|
"getResolution", "getImageTitle", "setImageTitle", "setResolution", "setBBoxZoom", "setZoom", "getMode", "setMode",
|
||||||
"setStrokeWidth", "getStrokeStyle", "setStrokeStyle", "getOpacity", "setOpacity", "getFillOpacity", "setFillOpacity",
|
"getStrokeColor", "setStrokeColor", "getFillColor", "setFillColor", "setStrokePaint", "setFillPaint", "getStrokeWidth",
|
||||||
"getStrokeOpacity", "setStrokeOpacity", "getTransformList", "getBBox", "getRotationAngle", "setRotationAngle", "each",
|
"setStrokeWidth", "getStrokeStyle", "setStrokeStyle", "getOpacity", "setOpacity", "getFillOpacity", "setFillOpacity",
|
||||||
"bind", "setIdPrefix", "getBold", "setBold", "getItalic", "setItalic", "getFontFamily", "setFontFamily", "getFontSize",
|
"getStrokeOpacity", "setStrokeOpacity", "getTransformList", "getBBox", "getRotationAngle", "setRotationAngle", "each",
|
||||||
"setFontSize", "getText", "setTextContent", "setImageURL", "setRectRadius", "setSegType", "quickClone",
|
"bind", "setIdPrefix", "getBold", "setBold", "getItalic", "setItalic", "getFontFamily", "setFontFamily", "getFontSize",
|
||||||
"changeSelectedAttributeNoUndo", "changeSelectedAttribute", "deleteSelectedElements", "groupSelectedElements", "zoomChanged",
|
"setFontSize", "getText", "setTextContent", "setImageURL", "setRectRadius", "setSegType", "quickClone",
|
||||||
"ungroupSelectedElement", "moveToTopSelectedElement", "moveToBottomSelectedElement", "moveSelectedElements",
|
"changeSelectedAttributeNoUndo", "changeSelectedAttribute", "deleteSelectedElements", "groupSelectedElements", "zoomChanged",
|
||||||
"getStrokedBBox", "getVisibleElements", "cycleElement", "getUndoStackSize", "getRedoStackSize", "getNextUndoCommandText",
|
"ungroupSelectedElement", "moveToTopSelectedElement", "moveToBottomSelectedElement", "moveSelectedElements",
|
||||||
"getNextRedoCommandText", "undo", "redo", "cloneSelectedElements", "alignSelectedElements", "getZoom", "getVersion",
|
"getStrokedBBox", "getVisibleElements", "cycleElement", "getUndoStackSize", "getRedoStackSize", "getNextUndoCommandText",
|
||||||
"setIconSize", "setLang", "setCustomHandlers"];
|
"getNextRedoCommandText", "undo", "redo", "cloneSelectedElements", "alignSelectedElements", "getZoom", "getVersion",
|
||||||
|
"setIconSize", "setLang", "setCustomHandlers"];
|
||||||
|
|
||||||
// TODO: rewrite the following, it's pretty scary.
|
// TODO: rewrite the following, it's pretty scary.
|
||||||
for (i = 0; i < functions.length; i++) {
|
for (i = 0; i < functions.length; i++) {
|
||||||
@@ -97,10 +98,10 @@ function EmbeddedSVGEdit(frame){
|
|||||||
// We accept and post strings as opposed to objets for the sake of IE9 support; this
|
// We accept and post strings as opposed to objets for the sake of IE9 support; this
|
||||||
// will most likely be changed in the future
|
// will most likely be changed in the future
|
||||||
if (typeof e.data !== 'string') {
|
if (typeof e.data !== 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result, cbid,
|
var result, cbid,
|
||||||
data = e.data && JSON.parse(e.data);
|
data = e.data && JSON.parse(e.data);
|
||||||
if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit') {
|
if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user