Commit 7b2f48f5 authored by Ivan Tyagov's avatar Ivan Tyagov

Initial commit of gadget's interaction POC.

parent 98bbca72
<?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>erp5_gadget_interaction</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="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>\074!DOCTYPE html\076\n
\074html\076\n
\n
\074head\076\n
\074!-- \074script src="adsafe.js"\076\074/script\076 --\076\n
\074script src="jquery/core/jquery.js"\076\074/script\076\n
\074script src="jquery/plugin/renderjs/renderjs.js"\076\074/script\076\n
\074script src="interactor.js"\076\074/script\076\n
\n
\074/head\076\n
\n
\074body\076\n
\n
\074h1\076test\074/h1\076\n
\n
\074div id="content" gadget="test_gadgets/A"\076\074/div\076\n
\n
\074script type="text/javascript" language="javascript"\076\n
//\074![CDATA[\n
// init all when DOM is ready\n
$(document).ready(function() {\n
RenderJs.bootstrap($("#content"));\n
// XXX: we use timeouts as we do not know if gadget structure is yet ready, how to do that in a generic way?\n
window.setTimeout(\'RenderJs.update($("#content"));\', DEFAULT_GADGET_DOM_READY_TIMEOUT);\n
});\n
//]]\076\n
\074/script\076\n
\n
\n
\074/body\076\n
\074/html\076</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>interactions</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="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts36565830.87</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>interactor.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[
// Basic gadget interaction library\n
var InteractionGadget = {\n
\n
bind: function (dom){\n
/*\n
* Bind event between gadgets.\n
*/\n
dom.find("connect").each(function (key, value){\n
source = $(value).attr("source").split(".");\n
source_gadget_id = source[0];\n
source_method_id = source[1];\n
source_gadget = GadgetIndex.getGadgetById(source_gadget_id);\n
\n
destination = $(value).attr("destination").split(".");\n
destination_gadget_id = destination[0];\n
destination_method_id = destination[1];\n
destination_gadget = GadgetIndex.getGadgetById(destination_gadget_id);\n
\n
if (source_gadget.hasOwnProperty(source_method_id)){\n
// direct javascript use case\n
func_body = \'GadgetIndex.getGadgetById("\' + source_gadget_id + \'")["original_\' + source_method_id + \'"]();\';\n
func_body = func_body + \'\\nGadgetIndex.getGadgetById("\' + destination_gadget_id + \'")["\' + destination_method_id + \'"]();\';\n
func = new Function(func_body);\n
source_gadget["original_" + source_method_id] = source_gadget[source_method_id];\n
source_gadget[source_method_id] = func;\n
}\n
else{\n
// this is a custom event attached to HTML gadget representation\n
func_body = \'GadgetIndex.getGadgetById("\' + destination_gadget_id + \'")["\' + destination_method_id + \'"]();\';\n
func = new Function(func_body);\n
source_gadget.dom.bind(source_method_id, func);\n
}\n
console.log(source_gadget_id, \'.\', source_method_id, \'-->\', destination_gadget_id, \'.\', destination_method_id);\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>1590</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>test_gadgets</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="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>\074div gadget="" id="main-interactor"\076\n
\074connect source="B.jsCall1" destination="C.jsCall1"\076\074/connect\076\n
\074connect source="B.htmlEvent1" destination="C.htmlEvent1"\076\074/connect\076\n
\074connect source="B.htmlEvent2" destination="C.htmlEvent2"\076\074/connect\076\n
\074connect source="C.jsCall2" destination="B.jsCall2"\076\074/connect\076\n
\074/div\076\n
\n
\074div gadget="test_gadgets/B" id="B"\076\074/div\076\n
\074div gadget="test_gadgets/C" id="C"\076\074/div\076\n
\n
\074script type="text/javascript" language="javascript"\076\n
//\074![CDATA[\n
$(document).ready(function() {\n
window.setTimeout(\'InteractionGadget.bind($("#main-interactor"));\', DEFAULT_GADGET_DOM_READY_TIMEOUT); \n
});\n
//]]\076\n
\074/script\076\n
\n
\074!-- Adsafe test --\076\n
\074!--\074div id="WIDGETNAME_"\076\n
Adsafe\n
\074script type="text/javascript" language="javascript"\076\n
ADSAFE.go("WIDGETNAME_", function (dom) {\n
"use strict";\n
\n
// This is where the code for the widget is placed. It can access\n
// the document through the dom parameter, allowing it indirect\n
// access to html elements, allowing it to change content, styling,\n
// and behavior.\n
\n
});\n
\074/script\076\n
\074/div\076--\076</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>A</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>\074div\076\n
B (gadget)\n
\074button onclick="GadgetIndex.getGadgetById(\'B\').jsCall1()"\076B.jsCall1 -\076 C.jsCall1\074/button\076\n
\074button onclick="$(\'#B\').trigger(\'htmlEvent1\')"\076HTML event 1\074/button\076\n
\074button onclick="$(\'#B\').trigger(\'htmlEvent2\')"\076HTML event 2\074/button\076\n
\074/div\076\n
\n
\074script type="text/javascript" language="javascript"\076\n
//\074![CDATA[\n
$(document).ready(function() {\n
gadget = GadgetIndex.getGadgetById("B");\n
gadget.jsCall1 = function (){alert("B.jscall1");};\n
gadget.jsCall2 = function (){alert("B.jscall2");};\n
});\n
//]]\076\n
\074/script\076</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>B</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>\074div\076\n
C (gadget)\n
\074button onclick="GadgetIndex.getGadgetById(\'C\').jsCall2();"\076C.jsCall2 -\076 B.jsCall2\074/button\076\n
\074/div\076\n
\n
\074script type="text/javascript" language="javascript"\076\n
//\074![CDATA[\n
$(document).ready(function() {\n
gadget = GadgetIndex.getGadgetById("C");\n
gadget.jsCall1 = function (){alert("C.jscall1");};\n
gadget.jsCall2 = function (){alert("C.jscall2");};\n
gadget.htmlEvent1 = function (){alert("C.htmlEvent1");};\n
gadget.htmlEvent2 = function (){alert("C.htmlEvent2");};\n
});\n
//]]\076\n
\074/script\076</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>C</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>
1
\ No newline at end of file
erp5_gadget_interaction
\ No newline at end of file
erp5_gadget_interaction
\ 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