Commit 25fee905 authored by Ivan Tyagov's avatar Ivan Tyagov

Make Javascript code work explicitly with MochiKit JS library.

This way it's possible to use it together with another JS library safely.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34468 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent dea58870
...@@ -50,10 +50,9 @@ function replaceContent(req) {\n ...@@ -50,10 +50,9 @@ function replaceContent(req) {\n
loading_deferred.cancel();\n loading_deferred.cancel();\n
loading_deferred = undefined;\n loading_deferred = undefined;\n
}\n }\n
\n //var container = $(\'container\');\n
var container = $(\'container\');\n var container = MochiKit.DOM.getElement("container");\n
container.innerHTML = req.responseText;\n container.innerHTML = req.responseText;\n
\n
addOnClickEventsToTabs(req);\n addOnClickEventsToTabs(req);\n
}\n }\n
\n \n
...@@ -62,37 +61,39 @@ function showServerSideError(req) {\n ...@@ -62,37 +61,39 @@ function showServerSideError(req) {\n
loading_deferred.cancel();\n loading_deferred.cancel();\n
loading_deferred = undefined;\n loading_deferred = undefined;\n
}\n }\n
\n //var container = $(\'container\');\n
var container = $(\'container\');\n var container = MochiKit.DOM.getElement("container");\n
container.innerHTML = \'Server side error.\';\n container.innerHTML = \'Server side error.\';\n
\n
addOnClickEventsToTabs(req);\n addOnClickEventsToTabs(req);\n
}\n }\n
\n \n
function showLoadingMessage() {\n function showLoadingMessage() {\n
var container = $(\'container\');\n //var container = $(\'container\');\n
var container = MochiKit.DOM.getElement("container");\n
container.innerHTML = \'<div><p style="text-align: left; vertical-align: middle; font-size: large;">Loading...</p></div>\';\n container.innerHTML = \'<div><p style="text-align: left; vertical-align: middle; font-size: large;">Loading...</p></div>\';\n
loading_deferred = undefined;\n loading_deferred = undefined;\n
}\n }\n
\n \n
function selectTab(e) {\n function selectTab(e) {\n
var tab_box = $(\'tab_box\');\n //var tab_box = $(\'tab_box\');\n
var item_list = tab_box.getElementsByTagName(\'li\');\n //var item_list = tab_box.getElementsByTagName(\'li\');\n
var item_list = MochiKit.DOM.getElementsByTagAndClassName("li", null, "tab_box");\n
for (var i = 0; i < item_list.length; i++) {\n for (var i = 0; i < item_list.length; i++) {\n
var item = item_list[i];\n var item = item_list[i];\n
var node = item.getElementsByTagName(\'a\')[0];\n //var node = item.getElementsByTagName(\'a\')[0];\n
var node = MochiKit.DOM.getFirstElementByTagAndClassName("a", null, item);\n
if (this == node) {\n if (this == node) {\n
if (getNodeAttribute(item, \'class\') != \'selected\') {\n if (getNodeAttribute(item, \'class\') != \'selected\') {\n
setNodeAttribute(item, \'class\', \'selected\');\n MochiKit.DOM.setNodeAttribute(item, \'class\', \'selected\');\n
}\n }\n
node.blur();\n node.blur();\n
} else {\n } else {\n
if (getNodeAttribute(item, \'class\') != \'non_selected\') {\n if (getNodeAttribute(item, \'class\') != \'non_selected\') {\n
setNodeAttribute(item, \'class\', \'non_selected\');\n MochiKit.DOM.setNodeAttribute(item, \'class\', \'non_selected\');\n
}\n }\n
}\n }\n
disconnectAll(node, \'onclick\');\n MochiKit.Signal.disconnectAll(node, \'onclick\');\n
connect(node, \'onclick\', function (e) { e.stop(); });\n MochiKit.Signal.connect(node, \'onclick\', function (e) { e.stop(); });\n
}\n }\n
\n \n
var mapping = {\n var mapping = {\n
...@@ -101,24 +102,26 @@ function selectTab(e) {\n ...@@ -101,24 +102,26 @@ function selectTab(e) {\n
};\n };\n
\n \n
var url = mapping[this.parentNode.id];\n var url = mapping[this.parentNode.id];\n
var d = doSimpleXMLHttpRequest(url);\n var d = MochiKit.Async.doSimpleXMLHttpRequest(url);\n
d.addCallbacks(replaceContent, showServerSideError);\n d.addCallbacks(replaceContent, showServerSideError);\n
e.stop();\n e.stop();\n
\n \n
loading_deferred = callLater(0.3, showLoadingMessage);\n loading_deferred = MochiKit.Async.callLater(0.3, showLoadingMessage);\n
\n \n
// Set a cookie.\n // Set a cookie.\n
document.cookie = \'erp5_site_selected_tab=\' + escape(this.parentNode.id);\n document.cookie = \'erp5_site_selected_tab=\' + escape(this.parentNode.id);\n
}\n }\n
\n \n
function addOnClickEventsToTabs(e) {\n function addOnClickEventsToTabs(e) {\n
var tab_box = $(\'tab_box\');\n //var tab_box = $(\'tab_box\');\n
var item_list = tab_box.getElementsByTagName(\'li\');\n //var item_list = tab_box.getElementsByTagName(\'li\');\n
var item_list = MochiKit.DOM.getElementsByTagAndClassName("li", null, "tab_box");\n
for (var i = 0; i < item_list.length; i++) {\n for (var i = 0; i < item_list.length; i++) {\n
//connect(item_list[i], \'onclick\', function(e){e.stop();})\n //connect(item_list[i], \'onclick\', function(e){e.stop();})\n
var node = item_list[i].getElementsByTagName(\'a\')[0];\n //var node = item_list[i].getElementsByTagName(\'a\')[0];\n
disconnectAll(node, \'onclick\');\n var node = MochiKit.DOM.getFirstElementByTagAndClassName("a", null, item_list[i]);\n
connect(node, \'onclick\', selectTab);\n MochiKit.Signal.disconnectAll(node, \'onclick\');\n
MochiKit.Signal.connect(node, \'onclick\', selectTab);\n
}\n }\n
return true;\n return true;\n
}\n }\n
......
923 925
\ 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