Commit 00a76cef authored by Ivan Tyagov's avatar Ivan Tyagov

Initial work on making switching between gadgets in an asynchronous calls (no...

Initial work on making switching between gadgets in an asynchronous calls (no page refresh). Work in progress.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40878 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 82ba4b6b
......@@ -228,6 +228,11 @@
%(knowledge_pad.getRelativeUrl(), mode)">\n
<span tal:content="knowledge_pad/getTitle"/>\n
</a>\n
<!-- XXX: instant switch\n
<span tal:attributes="onclick string:loadPadFromServer(\'${knowledge_pad.getRelativeUrl()}\', \'page_wrapper\', \'${mode}\')" \n
tal:content="knowledge_pad/getTitle"/>\n
-->\n
\n
</li>\n
</tal:block>\n
</tal:block>\n
......
......@@ -36,7 +36,7 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block \n
<tal:block\n
tal:repeat="box_id python: options[\'section_layout\']"\n
tal:define="real_context python: options.get(\'real_context\', None);\n
cancel_url python: options.get(\'cancel_url\', None);">\n
......@@ -55,6 +55,7 @@
view_form_id gadget/getViewFormId;\n
render_type gadget/getRenderType;\n
is_asynchronous_gadget python: render_type == \'asynchronous\';\n
force_synchronous_gadget_rendering python: request.get(\'force_synchronous_gadget_rendering\', False);\n
current_web_section python: context.REQUEST.get(\'current_web_section\',\n
here);\n
current_web_section python: \n
......@@ -177,13 +178,13 @@
tal:define="view_form_object python: getattr(real_context, view_form_id);">\n
\n
<!-- Synchronous Gadget -->\n
<div tal:condition="not: is_asynchronous_gadget"\n
<div tal:condition="python: not is_asynchronous_gadget or force_synchronous_gadget_rendering"\n
tal:attributes="id view_form_dom_id"\n
class="box_inner_content" \n
tal:content="structure python: view_form_object(box=box)"/>\n
\n
<!-- Asynchronous Gadget -->\n
<tal:block tal:condition="is_asynchronous_gadget">\n
<tal:block tal:condition="python: is_asynchronous_gadget and not force_synchronous_gadget_rendering">\n
<div tal:attributes="id view_form_dom_id" \n
class="box_inner_content"\n
i18n:translate="" \n
......
......@@ -41,7 +41,9 @@
real_context python: options.get(\'real_context\', None);\n
cancel_url python: options.get(\'cancel_url\', None);\n
is_tab_empty python: (len(layout)==1 and len(layout[0])==0) or\n
(len(layout)==3 and len(layout[0]+layout[1]+layout[2])==0) ">\n
(len(layout)==3 and len(layout[0]+layout[1]+layout[2])==0);\n
page_wrapper_id python: options.get(\'page_wrapper_id\', \'page_wrapper\');"\n
tal:attributes="id page_wrapper_id">\n
<div tal:condition="is_tab_empty">\n
<h3 i18n:translate="" \n
i18n:domain="ui"> \n
......
<?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
Render an entire PAD plus navigation (XXX)\n
Used to in AJAX calls for instan PAD switching.\n
"""\n
pad = context.restrictedTraverse(pad_relative_url)\n
context.REQUEST.set(\'force_synchronous_gadget_rendering\', 1)\n
html = pad.WebSection_viewDashboardWidget(real_context=context, page_wrapper_id=\'\')\n
#WebSection_viewDashboardWidget\n
#KnowledgePad_viewDashboardWidget\n
# XXX: merge both to KnowledgePad_viewDashboardWidget !\n
# toggle new active pad \n
context.ERP5Site_toggleActiveKnowledgePad(pad_relative_url, mode, redirect=False)\n
context.REQUEST.RESPONSE.setHeader(\'Content-Type\', \'text/html;; charset=utf-8\')\n
\n
print html\n
return printed\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>pad_relative_url, mode</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>pad_relative_url</string>
<string>mode</string>
<string>_print_</string>
<string>_print</string>
<string>_getattr_</string>
<string>context</string>
<string>pad</string>
<string>html</string>
<string>False</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>KnowledgePag_getPadAsHTML</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91031570.14</string> </value>
<value> <string>ts91040808.94</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -259,6 +259,22 @@ function showAddNewPadPopup(popup_id, input_id){\n
// MochiKit.DOM.getElement(\'new_pad_title\').focus();\n
}\n
\n
function loadPadFromServer(pad_relative_url, wrapper_dom_id, mode){\n
/* Load Pad from server */\n
d = MochiKit.Async.doSimpleXMLHttpRequest(\'A\', \n
{\'pad_relative_url\':pad_relative_url,\n
\'mode\':mode});\n
d.addCallback(handleServerSuccess);\n
function handleServerSuccess(res){\n
response = res.responseText;\n
// removeElement(wrapper_dom_id);\n
// div = document.createElement("div")\n
dom = getElement(wrapper_dom_id);\n
dom.innerHTML = response;\n
// alert(div);\n
}\n
}\n
\n
function addPadOnServerOnEnter(event, create_url, mode, cancel_url){\n
/* Catch and submit form when ENTER is pressed */\n
if(event.keyCode == 13){\n
......@@ -417,7 +433,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>15402</int> </value>
<value> <int>15973</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
623
\ No newline at end of file
624
\ 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