Commit 149c2a4a authored by Ivan Tyagov's avatar Ivan Tyagov

If an asynchronous gadget is minimized we do not need to load its content...

If  an asynchronous gadget is minimized we do not need to load its content from server (needless requests). Still we will load it when user click maximize button.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41483 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1c953d82
...@@ -80,11 +80,14 @@ if editable_mode in (\'True\', True, 1):\n ...@@ -80,11 +80,14 @@ if editable_mode in (\'True\', True, 1):\n
editable_mode = 1\n editable_mode = 1\n
else:\n else:\n
editable_mode = 0\n editable_mode = 0\n
\n js_update_code = """updater(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', %s);""" %(url, box_relative_url, dom_id, \n
s = """\n
updater(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', %s);\n
""" %(url, box_relative_url, dom_id, \n
current_web_section_url, editable_mode, encodeInJson(params))\n current_web_section_url, editable_mode, encodeInJson(params))\n
if box.getValidationState()==\'invisible\':\n
# we can generate \n
s = """invisible_gadgets["%s"]="%s";""" %(dom_id, js_update_code)\n
else:\n
s = js_update_code\n
\n
return s\n return s\n
</string> </value> </string> </value>
</item> </item>
...@@ -139,6 +142,7 @@ return s\n ...@@ -139,6 +142,7 @@ return s\n
<string>box_relative_url</string> <string>box_relative_url</string>
<string>editable_mode</string> <string>editable_mode</string>
<string>True</string> <string>True</string>
<string>js_update_code</string>
<string>s</string> <string>s</string>
</tuple> </tuple>
</value> </value>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts92251348.76</string> </value> <value> <string>ts92483701.94</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -36,6 +36,9 @@ var active_knowledge_pad_title_dom_id = \'\';\n ...@@ -36,6 +36,9 @@ var active_knowledge_pad_title_dom_id = \'\';\n
// enable or disable integration with server\n // enable or disable integration with server\n
var is_knowledge_template_used = 0;\n var is_knowledge_template_used = 0;\n
\n \n
// dictionary of invisible gadgets\n
var invisible_gadgets={};\n
\n
function createCustomKnowledgePadOnServer(){\n function createCustomKnowledgePadOnServer(){\n
url = "ERP5Site_createDefaultKnowledgePadListForUser";\n url = "ERP5Site_createDefaultKnowledgePadListForUser";\n
d = MochiKit.Async.doSimpleXMLHttpRequest(url, \n d = MochiKit.Async.doSimpleXMLHttpRequest(url, \n
...@@ -484,7 +487,15 @@ function initialize(){\n ...@@ -484,7 +487,15 @@ function initialize(){\n
if (is_knowledge_template_used){\n if (is_knowledge_template_used){\n
showCreateDefaultKnowledgePadWarningMessage();}\n showCreateDefaultKnowledgePadWarningMessage();}\n
else{\n else{\n
// togle DOM element (locally)\n
toggle(minimize_wrapper);\n toggle(minimize_wrapper);\n
js_dom_id = box.id + \'_content\';\n
js_code = invisible_gadgets[js_dom_id];\n
if (js_code!=undefined){\n
eval(js_code);\n
// gadget is now visible, i.e. no need to query server just toggle locally dom\n
delete invisible_gadgets[js_dom_id];}\n
// update server \n
doSimpleXMLHttpRequest("KnowledgeBox_toggleVisibility", \n doSimpleXMLHttpRequest("KnowledgeBox_toggleVisibility", \n
{box_relative_url: box.id});}});\n {box_relative_url: box.id});}});\n
}\n }\n
...@@ -521,7 +532,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n ...@@ -521,7 +532,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>19554</int> </value> <value> <int>19989</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
662 663
\ No newline at end of file \ 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