Commit 2283e291 authored by Gabriel Monnerat's avatar Gabriel Monnerat

2010-11-02 gabriel

* The initial commit

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39789 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a4b8c5f3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>svg-editor</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>canvg</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80046427.57</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>embedapi.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
function embedded_svg_edit(frame){\n
//initialize communication\n
this.frame = frame;\n
this.stack = []; //callback stack\n
\n
var editapi = this;\n
\n
window.addEventListener("message", function(e){\n
if(e.data.substr(0,5) == "ERROR"){\n
editapi.stack.splice(0,1)[0](e.data,"error")\n
}else{\n
editapi.stack.splice(0,1)[0](e.data)\n
}\n
}, false)\n
}\n
\n
embedded_svg_edit.prototype.call = function(code, callback){\n
this.stack.push(callback);\n
this.frame.contentWindow.postMessage(code,"*");\n
}\n
\n
embedded_svg_edit.prototype.getSvgString = function(callback){\n
this.call("svgCanvas.getSvgString()",callback)\n
}\n
\n
embedded_svg_edit.prototype.setSvgString = function(svg){\n
this.call("svgCanvas.setSvgString(\'"+svg.replace(/\'/g, "\\\\\'")+"\')");\n
}\n
*/\n
\n
\n
/*\n
Embedded SVG-edit API\n
\n
General usage:\n
- Have an iframe somewhere pointing to a version of svg-edit > r1000\n
- Initialize the magic with:\n
var svgCanvas = new embedded_svg_edit(window.frames[\'svgedit\']);\n
- Pass functions in this format:\n
svgCanvas.setSvgString("string")\n
- Or if a callback is needed:\n
svgCanvas.setSvgString("string")(function(data, error){\n
if(error){\n
//there was an error\n
}else{\n
//handle data\n
}\n
})\n
\n
Everything is done with the same API as the real svg-edit, \n
and all documentation is unchanged. The only difference is\n
when handling returns, the callback notation is used instead. \n
\n
var blah = new embedded_svg_edit(window.frames[\'svgedit\']);\n
blah.clearSelection("woot","blah",1337,[1,2,3,4,5,"moo"],-42,{a: "tree",b:6, c: 9})(function(){console.log("GET DATA",arguments)})\n
*/\n
\n
function embedded_svg_edit(frame){\n
//initialize communication\n
this.frame = frame;\n
//this.stack = [] //callback stack\n
this.callbacks = {}; //successor to stack\n
this.encode = embedded_svg_edit.encode;\n
//List of functions extracted with this:\n
//Run in firebug on http://svg-edit.googlecode.com/svn/trunk/docs/files/svgcanvas-js.html\n
\n
//for(var i=0,q=[],f = document.querySelectorAll("div.CFunction h3.CTitle a");i<f.length;i++){q.push(f[i].name)};q\n
//var functions = ["clearSelection", "addToSelection", "removeFromSelection", "open", "save", "getSvgString", "setSvgString", "createLayer", "deleteCurrentLayer", "getNumLayers", "getLayer", "getCurrentLayer", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition", "getLayerVisibility", "setLayerVisibility", "moveSelectedToLayer", "getLayerOpacity", "setLayerOpacity", "clear"];\n
\n
\n
//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\n
//var l=[];for(var i in svgCanvas){if(typeof svgCanvas[i] == "function"){l.push(i)}};\n
//run in svgedit itself\n
var functions = ["updateElementFromJson", "embedImage", "fixOperaXML", "clearSelection", "addToSelection", "removeFromSelection", "addNodeToSelection", "open", "save", "getSvgString", "setSvgString", "createLayer", "deleteCurrentLayer", "getNumLayers", "getLayer", "getCurrentLayer", "setCurrentLayer", "renameCurrentLayer", "setCurrentLayerPosition", "getLayerVisibility", "setLayerVisibility", "moveSelectedToLayer", "getLayerOpacity", "setLayerOpacity", "clear", "clearPath", "getNodePoint", "clonePathNode", "deletePathNode", "getResolution", "getImageTitle", "setImageTitle", "setResolution", "setBBoxZoom", "setZoom", "getMode", "setMode", "getStrokeColor", "setStrokeColor", "getFillColor", "setFillColor", "setStrokePaint", "setFillPaint", "getStrokeWidth", "setStrokeWidth", "getStrokeStyle", "setStrokeStyle", "getOpacity", "setOpacity", "getFillOpacity", "setFillOpacity", "getStrokeOpacity", "setStrokeOpacity", "getTransformList", "getBBox", "getRotationAngle", "setRotationAngle", "each", "bind", "setIdPrefix", "getBold", "setBold", "getItalic", "setItalic", "getFontFamily", "setFontFamily", "getFontSize", "setFontSize", "getText", "setTextContent", "setImageURL", "setRectRadius", "setSegType", "quickClone", "beginUndoableChange", "changeSelectedAttributeNoUndo", "finishUndoableChange", "changeSelectedAttribute", "deleteSelectedElements", "groupSelectedElements", "ungroupSelectedElement", "moveToTopSelectedElement", "moveToBottomSelectedElement", "moveSelectedElements", "getStrokedBBox", "getVisibleElements", "cycleElement", "getUndoStackSize", "getRedoStackSize", "getNextUndoCommandText", "getNextRedoCommandText", "undo", "redo", "cloneSelectedElements", "alignSelectedElements", "getZoom", "getVersion", "setIconSize", "setLang", "setCustomHandlers"]\n
\n
//TODO: rewrite the following, it\'s pretty scary.\n
for(var i = 0; i < functions.length; i++){\n
this[functions[i]] = (function(d){\n
return function(){\n
var t = this //new callback\n
for(var g = 0, args = []; g < arguments.length; g++){\n
args.push(arguments[g]);\n
}\n
var cbid = t.send(d,args, function(){}) //the callback (currently it\'s nothing, but will be set later\n
\n
return function(newcallback){\n
t.callbacks[cbid] = newcallback; //set callback\n
}\n
}\n
})(functions[i])\n
}\n
//TODO: use AddEvent for Trident browsers, currently they dont support SVG, but they do support onmessage\n
var t = this;\n
window.addEventListener("message", function(e){\n
if(e.data.substr(0,4)=="SVGe"){ //because svg-edit is too longish\n
var data = e.data.substr(4);\n
var cbid = data.substr(0, data.indexOf(";"));\n
if(t.callbacks[cbid]){\n
if(data.substr(0,6) != "error:"){\n
t.callbacks[cbid](eval("("+data.substr(cbid.length+1)+")"))\n
}else{\n
t.callbacks[cbid](data, "error");\n
}\n
}\n
}\n
//this.stack.shift()[0](e.data,e.data.substr(0,5) == "ERROR"?\'error\':null) //replace with shift\n
}, false)\n
}\n
\n
embedded_svg_edit.encode = function(obj){\n
//simple partial JSON encoder implementation\n
if(window.JSON && JSON.stringify) return JSON.stringify(obj);\n
var enc = arguments.callee; //for purposes of recursion\n
\n
if(typeof obj == "boolean" || typeof obj == "number"){\n
return obj+\'\' //should work...\n
}else if(typeof obj == "string"){\n
//a large portion of this is stolen from Douglas Crockford\'s json2.js\n
return \'"\'+\n
obj.replace(\n
/[\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g\n
, function (a) {\n
return \'\\\\u\' + (\'0000\' + a.charCodeAt(0).toString(16)).slice(-4);\n
})\n
+\'"\'; //note that this isn\'t quite as purtyful as the usualness\n
}else if(obj.length){ //simple hackish test for arrayish-ness\n
for(var i = 0; i < obj.length; i++){\n
obj[i] = enc(obj[i]); //encode every sub-thingy on top\n
}\n
return "["+obj.join(",")+"]";\n
}else{\n
var pairs = []; //pairs will be stored here\n
for(var k in obj){ //loop through thingys\n
pairs.push(enc(k)+":"+enc(obj[k])); //key: value\n
}\n
return "{"+pairs.join(",")+"}" //wrap in the braces\n
}\n
}\n
\n
embedded_svg_edit.prototype.send = function(name, args, callback){\n
var cbid = Math.floor(Math.random()*31776352877+993577).toString();\n
//this.stack.push(callback);\n
this.callbacks[cbid] = callback;\n
for(var argstr = [], i = 0; i < args.length; i++){\n
argstr.push(this.encode(args[i]))\n
}\n
var t = this;\n
setTimeout(function(){//delay for the callback to be set in case its synchronous\n
t.frame.contentWindow.postMessage(cbid+";svgCanvas[\'"+name+"\']("+argstr.join(",")+")","*");\n
}, 0);\n
return cbid;\n
//this.stack.shift()("svgCanvas[\'"+name+"\']("+argstr.join(",")+")")\n
}\n
\n
\n
\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>7532</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extensions</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DTMLDocument" module="OFS.DTMLDocument"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>TODO</string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string>Change type of xml / svg stuff</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80061401.32</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>closepath_icons.svg</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/svg+xml</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
<svg xmlns="http://www.w3.org/2000/svg">\n
<g id="tool_closepath">\n
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n
<g>\n
<title>Layer 1</title>\n
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m121.5,40l-84,106l27,115l166,2l29,-111"/>\n
<line x1="240" y1="136" x2="169.5" y2="74" stroke="#A00" stroke-width="25" fill="none"/>\n
<path stroke="none" fill ="#A00" d="m158,65l31,74l-3,-50l51,-3z"/>\n
<g stroke-width="15" stroke="#00f" fill="#0ff">\n
<circle r="30" cy="41" cx="123"/>\n
<circle r="30" cy="146" cx="40"/>\n
<circle r="30" cy="260" cx="69"/>\n
<circle r="30" cy="260" cx="228"/>\n
<circle r="30" cy="148" cx="260"/>\n
</g>\n
</g>\n
</svg>\n
</g>\n
<g id="tool_openpath">\n
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n
<g>\n
<title>Layer 1</title>\n
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m123.5,38l-84,106l27,115l166,2l29,-111"/>\n
<line x1="276.5" y1="153" x2="108.5" y2="24" stroke="#000" stroke-width="10" fill="none"/>\n
<g stroke-width="15" stroke="#00f" fill="#0ff">\n
<circle r="30" cy="41" cx="123"/>\n
<circle r="30" cy="146" cx="40"/>\n
<circle r="30" cy="260" cx="69"/>\n
<circle r="30" cy="260" cx="228"/>\n
<circle r="30" cy="148" cx="260"/>\n
</g>\n
<g stroke="#A00" stroke-width="15" fill="none">\n
<line x1="168" y1="24" x2="210" y2="150"/>\n
<line x1="210" y1="24" x2="168" y2="150"/>\n
</g>\n
</g>\n
</svg>\n
</g>\n
\n
<g id="svg_eof"/>\n
</svg>
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>1507</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80066299.22</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ext-closepath.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
* ext-closepath.js\n
*\n
* Licensed under the Apache License, Version 2\n
*\n
* Copyright(c) 2010 Jeff Schiller\n
*\n
*/\n
\n
// This extension adds a simple button to the contextual panel for paths\n
// The button toggles whether the path is open or closed\n
svgEditor.addExtension("ClosePath", function(S) {\n
\t\tvar selElems,\n
\t\t\tupdateButton = function(path) {\n
\t\t\t\tvar seglist = path.pathSegList,\n
\t\t\t\t\tclosed = seglist.getItem(seglist.numberOfItems - 1).pathSegType==1,\n
\t\t\t\t\tshowbutton = closed ? \'#tool_openpath\' : \'#tool_closepath\',\n
\t\t\t\t\thidebutton = closed ? \'#tool_closepath\' : \'#tool_openpath\';\n
\t\t\t\t\t$(hidebutton).hide();\n
\t\t\t\t\t$(showbutton).show();\n
\t\t\t},\n
\t\t\tshowPanel = function(on) {\n
\t\t\t\t$(\'#closepath_panel\').toggle(on);\n
\t\t\t\tif (on) {\n
\t\t\t\t\tvar path = selElems[0];\n
\t\t\t\t\tif (path) updateButton(path);\n
\t\t\t\t}\n
\t\t\t},\n
\t\t\n
\t\t\ttoggleClosed = function() {\n
\t\t\t\tvar path = selElems[0];\n
\t\t\t\tif (path) {\n
\t\t\t\t\tvar seglist = path.pathSegList,\n
\t\t\t\t\t\tlast = seglist.numberOfItems - 1;\t\t\t\t\t\n
\t\t\t\t\t// is closed\n
\t\t\t\t\tif(seglist.getItem(last).pathSegType == 1) {\n
\t\t\t\t\t\tseglist.removeItem(last);\n
\t\t\t\t\t}\n
\t\t\t\t\telse {\n
\t\t\t\t\t\tseglist.appendItem(path.createSVGPathSegClosePath());\n
\t\t\t\t\t}\n
\t\t\t\t\tupdateButton(path);\n
\t\t\t\t}\n
\t\t\t};\n
\t\t\n
\t\treturn {\n
\t\t\tname: "ClosePath",\n
\t\t\tsvgicons: "jquery_plugin/svg-editor/extensions/closepath_icons.svg",\n
\t\t\tbuttons: [{\n
\t\t\t\tid: "tool_openpath",\n
\t\t\t\ttype: "context",\n
\t\t\t\tpanel: "closepath_panel",\n
\t\t\t\ttitle: "Open path",\n
\t\t\t\tevents: {\n
\t\t\t\t\t\'click\': function() {\n
\t\t\t\t\t\ttoggleClosed();\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t},\n
\t\t\t{\n
\t\t\t\tid: "tool_closepath",\n
\t\t\t\ttype: "context",\n
\t\t\t\tpanel: "closepath_panel",\n
\t\t\t\ttitle: "Close path",\n
\t\t\t\tevents: {\n
\t\t\t\t\t\'click\': function() {\n
\t\t\t\t\t\ttoggleClosed();\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t}],\n
\t\t\tcallback: function() {\n
\t\t\t\t$(\'#closepath_panel\').hide();\n
\t\t\t},\n
\t\t\tselectedChanged: function(opts) {\n
\t\t\t\tselElems = opts.elems;\n
\t\t\t\tvar i = selElems.length;\n
\t\t\t\t\n
\t\t\t\twhile(i--) {\n
\t\t\t\t\tvar elem = selElems[i];\n
\t\t\t\t\tif(elem && elem.tagName == \'path\') {\n
\t\t\t\t\t\tif(opts.selectedElement && !opts.multiselected) {\n
\t\t\t\t\t\t\tshowPanel(true);\n
\t\t\t\t\t\t} else {\n
\t\t\t\t\t\t\tshowPanel(false);\n
\t\t\t\t\t\t}\n
\t\t\t\t\t} else {\n
\t\t\t\t\t\tshowPanel(false);\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t}\n
\t\t};\n
});\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2131</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80066301.42</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ext-eyedropper.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
* ext-eyedropper.js\n
*\n
* Licensed under the Apache License, Version 2\n
*\n
* Copyright(c) 2010 Jeff Schiller\n
*\n
*/\n
\n
svgEditor.addExtension("eyedropper", function(S) {\n
\t\tvar svgcontent = S.svgcontent,\n
\t\t\tsvgns = "http://www.w3.org/2000/svg",\n
\t\t\tsvgdoc = S.svgroot.parentNode.ownerDocument,\n
\t\t\tChangeElementCommand = svgCanvas.getPrivateMethods().ChangeElementCommand,\n
\t\t\taddToHistory = svgCanvas.getPrivateMethods().addCommandToHistory,\n
\t\t\tcurrentStyle = {fillPaint: "red", fillOpacity: 1.0,\n
\t\t\t\t\t\t\tstrokePaint: "black", strokeOpacity: 1.0, \n
\t\t\t\t\t\t\tstrokeWidth: 5, strokeDashArray: null,\n
\t\t\t\t\t\t\topacity: 1.0,\n
\t\t\t\t\t\t\tstrokeLinecap: \'butt\',\n
\t\t\t\t\t\t\tstrokeLinejoin: \'miter\',\n
\t\t\t\t\t\t\t};\n
\t\t\t\t\t\t\t\n
\t\tfunction getStyle(opts) {\n
\t\t\t// if we are in eyedropper mode, we don\'t want to disable the eye-dropper tool\n
\t\t\tvar mode = svgCanvas.getMode();\n
\t\t\tif (mode == "eyedropper") return;\n
\n
\t\t\tvar elem = null;\n
\t\t\tvar tool = $(\'#tool_eyedropper\');\n
\t\t\t// enable-eye-dropper if one element is selected\n
\t\t\tif (opts.elems.length == 1 && opts.elems[0] && \n
\t\t\t\t$.inArray(opts.elems[0].nodeName, [\'svg\', \'g\', \'use\']) == -1) \n
\t\t\t{\n
\t\t\t\telem = opts.elems[0];\n
\t\t\t\ttool.removeClass(\'disabled\');\n
\t\t\t\t// grab the current style\n
\t\t\t\tcurrentStyle.fillPaint = elem.getAttribute("fill") || "black";\n
\t\t\t\tcurrentStyle.fillOpacity = elem.getAttribute("fill-opacity") || 1.0;\n
\t\t\t\tcurrentStyle.strokePaint = elem.getAttribute("stroke");\n
\t\t\t\tcurrentStyle.strokeOpacity = elem.getAttribute("stroke-opacity") || 1.0;\n
\t\t\t\tcurrentStyle.strokeWidth = elem.getAttribute("stroke-width");\n
\t\t\t\tcurrentStyle.strokeDashArray = elem.getAttribute("stroke-dasharray");\n
\t\t\t\tcurrentStyle.strokeLinecap = elem.getAttribute("stroke-linecap");\n
\t\t\t\tcurrentStyle.strokeLinejoin = elem.getAttribute("stroke-linejoin");\n
\t\t\t\tcurrentStyle.opacity = elem.getAttribute("opacity") || 1.0;\n
\t\t\t}\n
\t\t\t// disable eye-dropper tool\n
\t\t\telse {\n
\t\t\t\ttool.addClass(\'disabled\');\n
\t\t\t}\n
\n
\t\t}\n
\t\t\n
\t\treturn {\n
\t\t\tname: "eyedropper",\n
\t\t\tsvgicons: "jquery_plugin/svg-editor/extensions/eyedropper-icon.xml",\n
\t\t\tbuttons: [{\n
\t\t\t\tid: "tool_eyedropper",\n
\t\t\t\ttype: "mode",\n
\t\t\t\ttitle: "Eye Dropper Tool",\n
\t\t\t\tevents: {\n
\t\t\t\t\t"click": function() {\n
\t\t\t\t\t\tsvgCanvas.setMode("eyedropper");\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t}],\n
\t\t\t\n
\t\t\t// if we have selected an element, grab its paint and enable the eye dropper button\n
\t\t\tselectedChanged: getStyle,\n
\t\t\telementChanged: getStyle,\n
\t\t\t\n
\t\t\tmouseDown: function(opts) {\n
\t\t\t\tvar mode = svgCanvas.getMode();\n
\t\t\t\tif (mode == "eyedropper") {\n
\t\t\t\t\tvar e = opts.event;\n
\t\t\t\t\tvar target = e.target;\n
\t\t\t\t\tif ($.inArray(target.nodeName, [\'svg\', \'g\', \'use\']) == -1) {\n
\t\t\t\t\t\tvar changes = {};\n
\n
\t\t\t\t\t\tvar change = function(elem, attrname, newvalue) {\n
\t\t\t\t\t\t\tchanges[attrname] = elem.getAttribute(attrname);\n
\t\t\t\t\t\t\telem.setAttribute(attrname, newvalue);\n
\t\t\t\t\t\t};\n
\t\t\t\t\t\t\n
\t\t\t\t\t\tif (currentStyle.fillPaint) \t\tchange(target, "fill", currentStyle.fillPaint);\n
\t\t\t\t\t\tif (currentStyle.fillOpacity) \t\tchange(target, "fill-opacity", currentStyle.fillOpacity);\n
\t\t\t\t\t\tif (currentStyle.strokePaint) \t\tchange(target, "stroke", currentStyle.strokePaint);\n
\t\t\t\t\t\tif (currentStyle.strokeOpacity) \tchange(target, "stroke-opacity", currentStyle.strokeOpacity);\n
\t\t\t\t\t\tif (currentStyle.strokeWidth) \t\tchange(target, "stroke-width", currentStyle.strokeWidth);\n
\t\t\t\t\t\tif (currentStyle.strokeDashArray) \tchange(target, "stroke-dasharray", currentStyle.strokeDashArray);\n
\t\t\t\t\t\tif (currentStyle.opacity) \t\t\tchange(target, "opacity", currentStyle.opacity);\n
\t\t\t\t\t\tif (currentStyle.strokeLinecap) \tchange(target, "stroke-linecap", currentStyle.strokeLinecap);\n
\t\t\t\t\t\tif (currentStyle.strokeLinejoin) \tchange(target, "stroke-linejoin", currentStyle.strokeLinejoin);\n
\t\t\t\t\t\t\n
\t\t\t\t\t\taddToHistory(new ChangeElementCommand(target, changes));\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t},\n
\t\t};\n
});\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>3740</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80066302.54</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ext-helloworld.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/x-javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string>/*\n
* ext-helloworld.js\n
*\n
* Licensed under the Apache License, Version 2\n
*\n
* Copyright(c) 2010 Alexis Deveria\n
*\n
*/\n
\n
/* \n
\tThis is a very basic SVG-Edit extension. It adds a "Hello World" button in\n
\tthe left panel. Clicking on the button, and then the canvas will show the\n
\tuser the point on the canvas that was clicked on.\n
*/\n
\n
svgEditor.addExtension("Hello World", function() {\n
\n
\t\treturn {\n
\t\t\tname: "Hello World",\n
\t\t\t// For more notes on how to make an icon file, see the source of\n
\t\t\t// the hellorworld-icon.xml\n
\t\t\tsvgicons: "jquery_plugin/svg-editor/extensions/helloworld-icon.xml",\n
\t\t\t\n
\t\t\t// Multiple buttons can be added in this array\n
\t\t\tbuttons: [{\n
\t\t\t\t// Must match the icon ID in helloworld-icon.xml\n
\t\t\t\tid: "hello_world", \n
\t\t\t\t\n
\t\t\t\t// This indicates that the button will be added to the "mode"\n
\t\t\t\t// button panel on the left side\n
\t\t\t\ttype: "mode", \n
\t\t\t\t\n
\t\t\t\t// Tooltip text\n
\t\t\t\ttitle: "Say \'Hello World\'", \n
\t\t\t\t\n
\t\t\t\t// Events\n
\t\t\t\tevents: {\n
\t\t\t\t\t\'click\': function() {\n
\t\t\t\t\t\t// The action taken when the button is clicked on.\n
\t\t\t\t\t\t// For "mode" buttons, any other button will \n
\t\t\t\t\t\t// automatically be de-pressed.\n
\t\t\t\t\t\tsvgCanvas.setMode("hello_world");\n
\t\t\t\t\t}\n
\t\t\t\t}\n
\t\t\t}],\n
\t\t\t// This is triggered when the main mouse button is pressed down \n
\t\t\t// on the editor canvas (not the tool panels)\n
\t\t\tmouseDown: function() {\n
\t\t\t\t// Check the mode on mousedown\n
\t\t\t\tif(svgCanvas.getMode() == "hello_world") {\n
\t\t\t\t\n
\t\t\t\t\t// The returned object must include "started" with \n
\t\t\t\t\t// a value of true in order for mouseUp to be triggered\n
\t\t\t\t\treturn {started: true};\n
\t\t\t\t}\n
\t\t\t},\n
\t\t\t\n
\t\t\t// This is triggered from anywhere, but "started" must have been set\n
\t\t\t// to true (see above). Note that "opts" is an object with event info\n
\t\t\tmouseUp: function(opts) {\n
\t\t\t\t// Check the mode on mouseup\n
\t\t\t\tif(svgCanvas.getMode() == "hello_world") {\n
\t\t\t\t\tvar zoom = svgCanvas.getZoom();\n
\t\t\t\t\t\n
\t\t\t\t\t// Get the actual coordinate by dividing by the zoom value\n
\t\t\t\t\tvar x = opts.mouse_x / zoom;\n
\t\t\t\t\tvar y = opts.mouse_y / zoom;\n
\t\t\t\t\t\n
\t\t\t\t\tvar text = "Hello World!\\n\\nYou clicked here: " \n
\t\t\t\t\t\t+ x + ", " + y;\n
\t\t\t\t\t\t\n
\t\t\t\t\t// Show the text using the custom alert function\n
\t\t\t\t\t$.alert(text);\n
\t\t\t\t}\n
\t\t\t}\n
\t\t};\n
});\n
\n
</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2198</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts80061395.19</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>eyedropper-icon.xml</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/svg+xml</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
<svg xmlns="http://www.w3.org/2000/svg">\n
\n
<g id="tool_eyedropper">\n
<svg viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->\n
<defs>\n
<radialGradient id="eyedropper_svg_6" cx="0.5" cy="0.5" r="0.5">\n
<stop offset="0" stop-color="#ffffff" stop-opacity="1"/>\n
<stop offset="1" stop-color="#e5e5e5" stop-opacity="0.38"/>\n
</radialGradient>\n
<linearGradient id="eyedropper_svg_15" x1="0" y1="0" x2="0.58594" y2="0.55078">\n
<stop offset="0" stop-color="#ffffff" stop-opacity="0.57"/>\n
<stop offset="1" stop-color="#000056" stop-opacity="1"/>\n
</linearGradient>\n
<linearGradient id="eyedropper_svg_19" x1="0" y1="0" x2="1" y2="1">\n
<stop offset="0" stop-color="#ffffff" stop-opacity="1"/>\n
<stop offset="1" stop-color="#ffffff" stop-opacity="0"/>\n
</linearGradient>\n
</defs>\n
<g display="inline">\n
<title>Layer 1</title>\n
<path d="m193.899994,73l-119.899979,118l-15,39.5l10.25,4.5l43.750015,-20l108.999969,-112l-28.100006,-30z" id="svg_3" fill="none" stroke="#000000" stroke-width="5"/>\n
<path d="m58.649994,232c-2.75,28.200012 -26.399994,28.950012 -21.899994,59c4.5,30.049988 55,28 55.5,-1.25c0.5,-29.25 -20.25,-28.75 -22.25,-54.75l-11.350006,-3z" id="svg_4" fill="#aa56ff" stroke="#000000" stroke-width="7"/>\n
<path d="m45.474976,269.275024l13.775024,0.474976l-0.75,16.75l-14.25,-1.25l1.224976,-15.974976z" id="svg_5" fill="url(#eyedropper_svg_6)" stroke-width="5" fill-opacity="0.73"/>\n
<path d="m217.899994,46c21.5,-101.549999 141.600006,20.449997 28.100006,33l-5,44l-63,-66l39.899994,-11z" id="svg_2" fill="#000000" stroke-width="5"/>\n
<path d="m206.825012,61.075008c3.712494,-2.46249 7.637482,-3.53751 14.424988,-5.575008c10.125,-16.5 32.875,-41.5 40.5,-35c7.625,6.5 -21.25,35.625 -37.5,39.25c-5.5,10.125 -8,13.875 -17.25,16.5c-2.837494,-8.162514 -4.262482,-12.337486 -0.174988,-15.174992z" id="svg_7" fill="url(#eyedropper_svg_15)" stroke-width="5"/>\n
<path d="m133.049988,134.75l46.950012,9.25l-66,70l-42.5,20.5l-11.5,-5l14,-37.5l59.049988,-57.25z" id="svg_11" fill="#aa56ff" stroke="#000000" stroke-width="7"/>\n
<path d="m71.425034,212.350006l9.050888,-20.022537l51.516724,-49.327469l8.507355,0.97197l-69.074966,68.378036z" id="svg_16" fill="url(#eyedropper_svg_19)" stroke-width="5"/>\n
</g>\n
</svg>\n
</g>\n
\t\n
\t<g id="svg_eof"/>\n
</svg>
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>2374</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>images</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment