Commit 23344161 authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_svg_editor: gadgetify method-draw application

- use GadgetField for method-draw
- remove EditorField support for svg editor
parent 869f9e3f
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>portal_type = context.getPortalType()\n
if portal_type in ("Web Illustration",):\n
text_content = context.getTextContent()\n
elif portal_type in ("Image",):\n
text_content = context.getData()\n
\n
return text_content\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getSVGTextContent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
wrapper to JQuery insert the data in the current document\n
"""\n
text_content = context.REQUEST.get("text")\n
if text_content is not None:\n
portal_type = context.getPortalType()\n
if portal_type in ("Web Illustration",):\n
getattr(context, "setTextContent")\n
context.edit(text_content=text_content)\n
elif portal_type in ("Image",):\n
getattr(context, "setData")\n
context.edit(data=text_content)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_setSVGTextContent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -75,7 +75,6 @@
<value>
<list>
<string>my_text_content</string>
<string>text_content</string>
</list>
</value>
</item>
......@@ -114,7 +113,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>svg_edit_form_view</string> </value>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts53195793.9</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>method-draw.gadget.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*jslint indent: 2 */\n
/*global window, rJS, RSVP, svgCanvas */\n
(function (window, rJS, RSVP) {\n
"use strict";\n
\n
rJS(window)\n
.ready(function (g) {\n
g.props = {};\n
var deferred = RSVP.defer();\n
svgCanvas.ready(function () {\n
deferred.resolve();\n
});\n
return deferred.promise;\n
})\n
.declareMethod(\'render\', function (options) {\n
this.props.key = options.key;\n
svgCanvas.setSvgString(options.value);\n
})\n
.declareService(function () {\n
if (/(?:^\\?|&)auto_focus=(true|1)(?:&|$)/.test(window.location.search)) {\n
window.focus(); // should be done by the parent gadget?\n
}\n
})\n
.declareMethod(\'getContent\', function () {\n
var form_data = {};\n
form_data[this.props.key] = svgCanvas.getSvgString();\n
return form_data;\n
});\n
\n
}(window, rJS, RSVP));\n
]]></string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>840</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="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode>window.onload = function () {\n
$.ajax({\n
url: "Base_getSVGTextContent",\n
async: true,\n
success: function (text_content) {\n
var svg_canvas, frame = window.frames.svgframe;\n
frame.focus();\n
if (text_content !== "") {\n
svg_canvas = frame.svgCanvas;\n
svg_canvas.ready(function () {\n
svg_canvas.setSvgString(text_content);\n
});\n
}\n
}\n
});\n
};\n
\n
$(document).ready(function () {\n
$("button.save").click(function (event) {\n
event.preventDefault();\n
var svg_canvas = window.frames.svgframe.svgCanvas;\n
$.ajax({\n
type: "POST",\n
url: "Base_setSVGTextContent",\n
data: "text=" + encodeURIComponent(svg_canvas.getSvgString()),\n
success: function () {\n
window.location.reload();\n
}\n
});\n
});\n
$("iframe#svgframe").css("border", "0px");\n
});\n
\n
window.addEventListener("keydown", function (event) {\n
if (event.keyCode === 8) {\n
event.preventDefault();\n
}\n
});</unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>svg-editor.erp5.js</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>iso-8859-15</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"\n
xmlns:metal="http://xml.zope.org/namespaces/metal"\n
xmlns:i18n="http://xml.zope.org/namespaces/i18n">\n
<tal:block metal:define-macro="master"\n
tal:define="js_list_jquery_template python: [\'jquery/core/jquery.js\',\n
\'svg-editor.erp5.js\'];\n
global js_list js_list | python:[];\n
dummy python:js_list.extend(js_list_jquery_template);">\n
<tal:block metal:use-macro="here/view_main/macros/master">\n
<tal:block metal:fill-slot="main">\n
<tal:block metal:use-macro="here/form_render/macros/master" />\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
</tal:block>
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>svg_edit_form_view</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<script type="text/javascript" src="jquery/core/jquery.js"></script>\n
<script type="text/javascript" src="svg-editor.erp5.js"></script>\n
<iframe name="svgframe" \n
id="svgframe" \n
src="method-draw/method-draw.html" \n
width="100%" \n
height="570"/>\n
]]></unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>svg_editor_support</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2016-01-19 tristan
* Gadgetify method-draw
* Remove EditorField support
2016-01-18 tristan
* Replace svg-edit by method-draw
* Remove jquery plugin dependencies to improve maintenance
......
Business Template to install SVG Editor using method-draw
\ No newline at end of file
Business Template to install SVG Editor using method-draw as a renderjs gadget
\ No newline at end of file
gabriel
\ No newline at end of file
gabriel
tristan
\ No newline at end of file
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