2009-06-10 12:32:24 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
2009-06-07 15:03:22 +00:00
|
|
|
<Module>
|
2009-06-10 12:32:24 +00:00
|
|
|
<ModulePrefs title="SVG-edit" height="600">
|
|
|
|
<Require feature="rpc" />
|
|
|
|
</ModulePrefs>
|
2009-06-07 15:03:22 +00:00
|
|
|
<Content type="html">
|
2009-06-10 12:32:24 +00:00
|
|
|
<![CDATA[
|
2009-06-07 15:03:22 +00:00
|
|
|
|
|
|
|
<script type="text/javascript" src="http://wave-api.appspot.com/public/wave.js"></script>
|
|
|
|
<link rel="stylesheet" href="http://svg-edit.googlecode.com/svn/trunk/editor/jpicker/jpicker.css" type="text/css"/>
|
|
|
|
<link rel="stylesheet" href="http://svg-edit.googlecode.com/svn/trunk/editor/svg-editor.css" type="text/css"/>
|
|
|
|
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
|
|
|
|
<script type="text/javascript" src="http://svg-edit.googlecode.com/svn/trunk/editor/jquery.rightClick.js"></script>
|
|
|
|
<script type="text/javascript" src="http://svg-edit.googlecode.com/svn/trunk/editor/jpicker/jpicker.js"></script>
|
|
|
|
<script type="text/javascript" src="http://svg-edit.googlecode.com/svn/trunk/editor/svgcanvas.js"></script>
|
|
|
|
<script type="text/javascript" src="http://svg-edit.googlecode.com/svn/trunk/editor/svg-editor.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="svg_editor">
|
|
|
|
|
|
|
|
<div id="color_picker" class="tools_flyout"></div>
|
|
|
|
|
|
|
|
<div id="tools_rect" class="tools_flyout">
|
|
|
|
<div id="tool_square" title="Square"></div>
|
|
|
|
<div id="tool_rect" title="Rectangle"></div>
|
|
|
|
<div id="tool_fhrect" title="Free-Hand Rectangle"></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="tools_ellipse" class="tools_flyout">
|
|
|
|
<div id="tool_circle" title="Circle"></div>
|
|
|
|
<div id="tool_ellipse" title="Ellipse"></div>
|
|
|
|
<div id="tool_fhellipse" title="Free-Hand Ellipse"></div>
|
|
|
|
</div>
|
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
<div id="context_tools" class="tools_panel">
|
|
|
|
<!-- File-like buttons: New, Save -->
|
|
|
|
<img class="tool_button" id="tool_clear" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/clear.png" title="New Image [N]" alt="Clear" />
|
|
|
|
<img class="tool_button" id="tool_save" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/save.png" title="Save Image [S]" alt="Save"/>
|
|
|
|
|
|
|
|
<!-- FIXME: need a separator image -->
|
|
|
|
|
|
|
|
<!-- Edit-like buttons: Delete -->
|
|
|
|
<img class="tool_button" id="tool_delete" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/delete.png" title="Delete Element [X]" alt="Delete"/>
|
|
|
|
|
|
|
|
<!-- FIXME: need a separator image -->
|
|
|
|
|
|
|
|
<div id="text_panel">
|
|
|
|
<select id="font_family" class="text_tool" title="Change Font Family">
|
|
|
|
<option selected="selected" value="serif">serif</option>
|
|
|
|
<option value="sans-serif">sans-serif</option>
|
|
|
|
<option value="cursive">cursive</option>
|
|
|
|
<option value="fantasy">fantasy</option>
|
|
|
|
<option value="monospace">monospace</option>
|
|
|
|
</select>
|
|
|
|
<select id="font_size" class="text_tool" title="Change Font Size">
|
|
|
|
<option value="6pt">6pt</option>
|
|
|
|
<option value="8pt">8pt</option>
|
|
|
|
<option value="10pt">10pt</option>
|
|
|
|
<option selected="selected" value="12pt">12pt</option>
|
|
|
|
<option value="14pt">14pt</option>
|
|
|
|
<option value="16pt">16pt</option>
|
|
|
|
<option value="20pt">20pt</option>
|
|
|
|
<option value="24pt">24pt</option>
|
|
|
|
<option value="32pt">32pt</option>
|
|
|
|
<option value="48pt">48pt</option>
|
|
|
|
<option value="64pt">64pt</option>
|
|
|
|
<option value="72pt">72pt</option>
|
|
|
|
<option value="80pt">80pt</option>
|
|
|
|
<option value="96pt">96pt</option>
|
|
|
|
<option value="120pt">120pt</option>
|
|
|
|
</select>
|
|
|
|
<input id="text" class="text_tool" type="text" title="Change text contents" size="40"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2009-06-07 15:03:22 +00:00
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
<div id="tools" class="tools_panel">
|
|
|
|
|
|
|
|
<img class="tool_button" id="tool_select" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/select.png" title="Select Tool [1]" alt="Select"/><br/>
|
|
|
|
<img class="tool_button_current" id="tool_path" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/path.png" title="Pencil Tool [2]" alt="Pencil"/><br/>
|
|
|
|
<img class="tool_button" id="tool_line" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/line.png" title="Line Tool [3]" alt="Line"/><br/>
|
|
|
|
<img class="tool_button" id="tools_rect_show" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/square.png" title="Square/Rect Tool [4/Shift+4]" alt="Square"/><br/>
|
|
|
|
<img class="tool_button" id="tools_ellipse_show" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/circle.png" title="Circle/Ellipse Tool [5/Shift+5]" alt="Circle"/><br/>
|
|
|
|
<img class="tool_button" id="tool_text" src="http://svg-edit.googlecode.com/svn/trunk/editor/images/text.png" title="Text Tool [6]" alt="Text"/>
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
<div>opacity<br/>
|
|
|
|
<select id="group_opacity" title="Change group opacity">
|
|
|
|
<option selected="selected" value="1">100 %</option>
|
|
|
|
<option value="0.9">90 %</option>
|
|
|
|
<option value="0.8">80 %</option>
|
|
|
|
<option value="0.7">70 %</option>
|
|
|
|
<option value="0.6">60 %</option>
|
|
|
|
<option value="0.5">50 %</option>
|
|
|
|
<option value="0.4">40 %</option>
|
|
|
|
<option value="0.3">30 %</option>
|
|
|
|
<option value="0.2">20 %</option>
|
|
|
|
<option value="0.1">10 %</option>
|
|
|
|
</select>
|
2009-06-07 15:03:22 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
<div>fill
|
|
|
|
<div id="fill_color" title="Change fill color"></div>
|
|
|
|
<select id="fill_opacity" title="Change fill opacity">
|
|
|
|
<option selected="selected" value="1">100 %</option>
|
|
|
|
<option value="0.9">90 %</option>
|
|
|
|
<option value="0.8">80 %</option>
|
|
|
|
<option value="0.7">70 %</option>
|
|
|
|
<option value="0.6">60 %</option>
|
|
|
|
<option value="0.5">50 %</option>
|
|
|
|
<option value="0.4">40 %</option>
|
|
|
|
<option value="0.3">30 %</option>
|
|
|
|
<option value="0.2">20 %</option>
|
|
|
|
<option value="0.1">10 %</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
<div>stroke
|
|
|
|
<div id="stroke_color" title="Change stroke color"></div>
|
|
|
|
<div>
|
|
|
|
<select id="stroke_width" title="Change stroke width">
|
|
|
|
<option selected="selected" value="1">1</option>
|
|
|
|
<option value="2">2</option>
|
|
|
|
<option value="3">3</option>
|
|
|
|
<option value="5">5</option>
|
|
|
|
<option value="7">7</option>
|
|
|
|
</select>
|
|
|
|
</div><div>
|
|
|
|
<select id="stroke_style" title="Change stroke dash style">
|
|
|
|
<option selected="selected" value="none">---</option>
|
|
|
|
<option value="2,2">...</option>
|
|
|
|
<option value="5,5">- -</option>
|
|
|
|
<option value="5,2,2,2">- .</option>
|
|
|
|
<option value="5,2,2,2,2,2">- ..</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<select id="stroke_opacity" title="Change stroke opacity">
|
|
|
|
<option selected="selected" value="1">100 %</option>
|
|
|
|
<option value="0.9">90 %</option>
|
|
|
|
<option value="0.8">80 %</option>
|
|
|
|
<option value="0.7">70 %</option>
|
|
|
|
<option value="0.6">60 %</option>
|
|
|
|
<option value="0.5">50 %</option>
|
|
|
|
<option value="0.4">40 %</option>
|
|
|
|
<option value="0.3">30 %</option>
|
|
|
|
<option value="0.2">20 %</option>
|
|
|
|
<option value="0.1">10 %</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="workarea">
|
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
<style id="styleoverrides" type="text/css"></style>
|
2009-06-07 15:03:22 +00:00
|
|
|
<div id="svgcanvas">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="palette_holder">
|
2009-06-10 12:32:24 +00:00
|
|
|
<div id="palette" title="Left-click to change fill color, right-click to change stroke color">
|
2009-06-07 15:03:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
<div id="footer" class="tools_panel">
|
2009-06-12 12:11:59 +00:00
|
|
|
SVG-edit Google Wave Gadget @ <a href="http://svg-edit.googlecode.com/" target="_blank">http://svg-edit.googlecode.com/</a>
|
2009-06-10 12:32:24 +00:00
|
|
|
</div>
|
|
|
|
|
2009-06-07 15:03:22 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2009-06-07 15:07:57 +00:00
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
var svgCanvas = null;
|
|
|
|
|
|
|
|
function stateUpdated() {
|
2009-06-12 05:11:13 +00:00
|
|
|
// 'state' is an object of key-value pairs that map ids to JSON serialization of SVG elements
|
|
|
|
// 'keys' is an array of all the keys in the state
|
2009-06-10 12:32:24 +00:00
|
|
|
var state = wave.getState();
|
|
|
|
var keys = state.getKeys();
|
|
|
|
svgCanvas.each(function(e) {
|
2009-06-12 05:11:13 +00:00
|
|
|
// 'this' is the SVG DOM element node (ellipse, rect, etc)
|
|
|
|
// 'e' is an integer describing the position within the document
|
2009-06-12 06:54:42 +00:00
|
|
|
var v = state.get(this.nodeId);
|
2009-06-10 12:32:24 +00:00
|
|
|
if (v) {
|
2009-06-09 22:19:52 +00:00
|
|
|
var ob;
|
2009-06-10 12:32:24 +00:00
|
|
|
eval("ob=" + v); // FIXME: Yes, I'm using eval... Dirty, dirty..
|
|
|
|
if (ob) {
|
2009-06-12 11:57:14 +00:00
|
|
|
svgCanvas.updateElementFromJson(ob);
|
2009-06-10 12:32:24 +00:00
|
|
|
} else {
|
2009-06-09 22:19:52 +00:00
|
|
|
var node = svgdoc.getElementById(k);
|
|
|
|
if (node) node.parentNode.removeChild(node);
|
|
|
|
}
|
2009-06-12 11:57:14 +00:00
|
|
|
keys.remove(this.nodeId);
|
2009-06-10 12:32:24 +00:00
|
|
|
} else {
|
2009-06-12 11:57:14 +00:00
|
|
|
this.parentNode.removeChild(this);
|
2009-06-10 12:32:24 +00:00
|
|
|
}
|
|
|
|
});
|
2009-06-09 22:19:52 +00:00
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
// New nodes
|
|
|
|
for (var k in keys) {
|
2009-06-09 22:19:52 +00:00
|
|
|
var ob;
|
2009-06-12 11:57:14 +00:00
|
|
|
var v = state.get(keys[k]);
|
2009-06-10 12:32:24 +00:00
|
|
|
eval("ob=" + v); // FIXME: Yes, I'm using eval... Dirty, dirty..
|
2009-06-12 11:57:14 +00:00
|
|
|
if (ob) svgCanvas.updateElementFromJson(ob)
|
2009-06-10 12:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-07 15:03:22 +00:00
|
|
|
|
2009-06-12 04:12:33 +00:00
|
|
|
function sendDelta(svgCanvas, elem) {
|
2009-06-09 22:39:58 +00:00
|
|
|
if (!wave) return;
|
2009-06-09 22:19:52 +00:00
|
|
|
var delta = {};
|
|
|
|
var attrs = {};
|
|
|
|
var a = elem.attributes;
|
|
|
|
for (var i = 0; i < a.length; i++) {
|
|
|
|
attrs[a.item(i).nodeName] = a.item(i).nodeValue;
|
2009-06-10 12:32:24 +00:00
|
|
|
}
|
|
|
|
var ob = { element: elem.nodeName, attr: attrs };
|
|
|
|
delta[elem.id] = wave.util.printJson(ob, false);
|
2009-06-09 22:19:52 +00:00
|
|
|
wave.getState().submitDelta(delta);
|
|
|
|
}
|
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
function main() {
|
|
|
|
svgCanvas = svg_edit_setup();
|
2009-06-12 06:54:42 +00:00
|
|
|
svgCanvas.setIdPrefix("svg_"+wave.getViewer().getId()+"_");
|
2009-06-10 12:32:24 +00:00
|
|
|
if (wave && wave.isInWaveContainer()) {
|
|
|
|
wave.setStateCallback(stateUpdated);
|
|
|
|
}
|
|
|
|
svgCanvas.bind("changed", sendDelta);
|
|
|
|
}
|
2009-06-09 22:19:52 +00:00
|
|
|
|
2009-06-10 12:32:24 +00:00
|
|
|
gadgets.util.registerOnLoadHandler(main);
|
2009-06-07 15:03:22 +00:00
|
|
|
|
|
|
|
</script>
|
2009-06-10 12:32:24 +00:00
|
|
|
]]>
|
|
|
|
</Content>
|
2009-06-07 15:03:22 +00:00
|
|
|
</Module>
|