Commit 97c22f2d authored by Ivan Tyagov's avatar Ivan Tyagov

Enable instant switching to new pad (i.e. without page refresh).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41091 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 177c5981
......@@ -186,16 +186,16 @@
<li tal:attributes="id dom_id;\n
class python: test(is_active, \'tab tab_selected\', \'tab\')">\n
\n
<!-- \n
<a tal:attributes="href string:\n
ERP5Site_toggleActiveKnowledgePad?knowledge_pad_url=${knowledge_pad_relative_url}&amp;mode=${mode}">\n
<span tal:attributes="id pad_title_dom_id;"\n
tal:content="knowledge_pad/getTitle"/>\n
</a>\n
</a>-->\n
\n
\n
<!-- <span tal:attributes="id pad_title_dom_id;\n
<span tal:attributes="id pad_title_dom_id;\n
onclick string:loadPadFromServer(\'${knowledge_pad_relative_url}\', \'${dom_id}\', \'${mode}\')" \n
tal:content="knowledge_pad/getTitle"/>-->\n
tal:content="knowledge_pad/getTitle"/>\n
\n
<div class="pad-actions"\n
tal:attributes="style python: test(is_active, \'display:block\', \'display:none\')">\n
......@@ -292,7 +292,14 @@
</div>\n
</div>\n
</tal:block>\n
\n
<tal:block metal:define-macro="loading_message">\n
<div id="loading-wrapper" style="display:none;">\n
<img src="ajax-loader.gif" title="Loading" alt="Loading"/>\n
<p i18n:translate="" i18n:domain="ui"> Please wait until your changes are being applied. </p>\n
</div>\n
\n
</tal:block>
]]></unicode> </value>
</item>
......
......@@ -64,6 +64,7 @@
<div id="pad-navigation-wrapper">\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/navigation"/>\n
</div>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/loading_message"/>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/knowledge_pad_security_check"/> \n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"/>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"/> \n
......
......@@ -60,7 +60,7 @@
# asynchronous request and server can set it in context.REQUEST\n
from Products.ERP5Type.JSONEncoder import encodeInJson\n
current_web_section_url = \'\'\n
current_web_section = context.REQUEST.get(\'current_web_section\', None)\n
current_web_section = context.REQUEST.get(\'current_web_section\', context.getWebSiteValue())\n
if current_web_section is not None:\n
current_web_section_url = current_web_section.getRelativeUrl()\n
if params is None:\n
......@@ -132,8 +132,8 @@ return s\n
<string>Products.ERP5Type.JSONEncoder</string>
<string>encodeInJson</string>
<string>current_web_section_url</string>
<string>None</string>
<string>current_web_section</string>
<string>None</string>
<string>isinstance</string>
<string>str</string>
<string>box_relative_url</string>
......
......@@ -51,10 +51,8 @@
<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
XXX: rather than return HTML we should return JSON as some parts like JS needs to be evaluated explicitly by\n
browser.\n
Render an entire Pad and needed JavaScript code.\n
Used to make instant Pad switching.\n
"""\n
pad = context.restrictedTraverse(pad_relative_url)\n
\n
......@@ -64,14 +62,26 @@ body = pad.KnowledgePad_viewDashboardWidget(real_context=context)\n
# toggle new active pad \n
context.ERP5Site_toggleActiveKnowledgePad(pad_relative_url, mode, redirect=False)\n
\n
# XXX: generate all JS updater code\n
javascript = \'\'\'updater(\'http://localhost/km/ERP5Site_viewRssGadget\', \'knowledge_pad_module/65/2\', \'visual_2\', \'web_site_module/km_test_web_site\', \'0\', {});\n
updater(\'http://localhost/km/ERP5Site_viewRssGadget\', \'knowledge_pad_module/64/3\', \'visual_3\', \'\', \'0\', {}); \'\'\'\n
\n
# generate needed JavaScript code\n
javascript_list = []\n
for box in pad.objectValues():\n
gadget = box.getSpecialiseValue()\n
gadget_type = gadget.getRenderType()\n
if box.getValidationState() in [\'visible\', \'invisible\'] \\\n
and gadget_type==\'asynchronous\':\n
edit_form_id=gadget.getEditFormId()\n
view_form_id=gadget.getViewFormId()\n
base_url = \'%s/%s\' %(context.absolute_url(), view_form_id) \n
box_dom_id = box.getRelativeUrl().replace(\'/\', \'_\')\n
view_form_dom_id = \'%s_content\' %box_dom_id;\n
javascript_code = pad.KnowledgePad_generateAjaxCall(base_url, box, \\\n
view_form_dom_id, ignore_security_check=1)\n
javascript_list.append(javascript_code)\n
javascript = \'\'.join(javascript_list)\n
# return JSON\n
result = {\'body\': body,\n
\'javascript\': javascript }\n
return \'%s\' % result\n
\'javascript\': javascript}\n
return result\n
</string> </value>
</item>
<item>
......@@ -115,6 +125,17 @@ return \'%s\' % result\n
<string>pad</string>
<string>body</string>
<string>False</string>
<string>javascript_list</string>
<string>_getiter_</string>
<string>box</string>
<string>gadget</string>
<string>gadget_type</string>
<string>edit_form_id</string>
<string>view_form_id</string>
<string>base_url</string>
<string>box_dom_id</string>
<string>view_form_dom_id</string>
<string>javascript_code</string>
<string>javascript</string>
<string>result</string>
</tuple>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" 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>ts91383226.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ajax-loader.gif</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/gif</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="base64">R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH+GkNyZWF0ZWQgd2l0aCBhamF4
bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAADMwi63P4wyklr
E2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQACgABACwAAAAA
EAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUk
KhIAIfkEAAoAAgAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9
HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkEAAoAAwAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYum
CYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkEAAoABAAsAAAAABAAEAAAAzII
unInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQACgAF
ACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJ
ibufbSlKAAAh+QQACgAGACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFG
xTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAAKAAcALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdce
CAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>16</int> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>673</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ajax-loader.gif</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>16</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91368675.54</string> </value>
<value> <string>ts91384188.54</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -40,6 +40,22 @@
margin-top: 0.5em;\n
}\n
\n
#loading-wrapper{ \n
position:absolute; \n
width:250px; \n
top:80px; \n
left:50%; \n
margin-left:-150px; \n
text-align:center; \n
padding:7px 0 0 0; \n
background-color: #FFF; \n
z-index:1000;\n
} \n
#loading-wrapper p{\n
font-weight: bold;\n
font-size: 90%;\n
}\n
\n
/* 3 columng gadget layout */\n
div.portal-column {\n
float: left;\n
......@@ -497,7 +513,7 @@ div.gadget-rss-reader .body {\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>8253</int> </value>
<value> <int>8519</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91368480.41</string> </value>
<value> <string>ts91383963.02</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -279,6 +279,7 @@ function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_
function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
/* Load Pad from server */\n
// XXX: show some animation ?\n
getElement("loading-wrapper").style.display="block";\n
\n
d = MochiKit.Async.loadJSONDoc(\'KnowledgePag_getPadAsJSON\', \n
{\'pad_relative_url\':pad_relative_url,\n
......@@ -291,7 +292,6 @@ function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
old_selected_pad = getFirstElementByTagAndClassName("li", "tab_selected", pads_container);\n
old_selected_pad.setAttribute("class", "tab");\n
pad_actions = getFirstElementByTagAndClassName("div", "pad-actions", old_selected_pad);\n
\n
pad_actions.style.display="none";\n
\n
// set new selected pad class \n
......@@ -314,9 +314,10 @@ function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
body_element.innerHTML = body;\n
// init new Pad\n
initialize();\n
// execute JS code\n
// execute JS code provided by server\n
eval(javascript);\n
\n
// give some timeout as we can be sometimes two fast loading a tab\n
setTimeout("getElement(\'loading-wrapper\').style.display=\'none\';", 250 );\n
}\n
}\n
\n
......@@ -500,7 +501,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>18522</int> </value>
<value> <int>18734</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
641
\ No newline at end of file
642
\ 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