Commit 4e991ee2 authored by Fabien Morin's avatar Fabien Morin

check if master is not null, this may happen in some web_sites using other...

check if master is not null, this may happen in some web_sites using other templates than erp5_xhtml one and then make javascript errors.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36975 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b506f816
......@@ -259,40 +259,42 @@ while leaving the page, unless leaving by:\n
*/\n
var addOnChangeEventHandler = function() {\n
var master = document.getElementById("master");\n
divs = master.getElementsByTagName("div");\n
for (i=0; i<divs.length; i++) {\n
if (divs[i].getAttribute("class") == "input") {\n
nodes = divs[i].childNodes;\n
if (master) {\n
divs = master.getElementsByTagName("div");\n
for (i=0; i<divs.length; i++) {\n
if (divs[i].getAttribute("class") == "input") {\n
nodes = divs[i].childNodes;\n
\n
for (j=0; j<nodes.length; j++) {\n
if (nodes[j].nodeName == "INPUT" ||\n
nodes[j].nodeName == "SELECT" ||\n
nodes[j].nodeName == "TEXTAREA") {\n
if (nodes[j].value == "update..." ||\n
(nodes[j].nodeName == "INPUT" &&\n
nodes[j].type == \'submit\')) {\n
// this is a relation field wheel or a submit form button\n
nodes[j].onclick = function() { changed = false;};\n
} else {\n
if (!nodes[j].onchange) {\n
nodes[j].onchange = function() { changed = true; };\n
}\n
}\n
} \n
/* Listbox or MatrixBox */\n
if (nodes[j].nodeName == "DIV" && (\n
nodes[j].getAttribute("class") == "listbox" ||\n
nodes[j].getAttribute("class") == "MatrixContent")) {\n
trs = nodes[j].getElementsByTagName(\'td\');\n
for (k=0; k<trs.length; k++){\n
if (trs[k].getAttribute("class") == "listbox_search_line") {\n
continue;\n
for (j=0; j<nodes.length; j++) {\n
if (nodes[j].nodeName == "INPUT" ||\n
nodes[j].nodeName == "SELECT" ||\n
nodes[j].nodeName == "TEXTAREA") {\n
if (nodes[j].value == "update..." ||\n
(nodes[j].nodeName == "INPUT" &&\n
nodes[j].type == \'submit\')) {\n
// this is a relation field wheel or a submit form button\n
nodes[j].onclick = function() { changed = false;};\n
} else {\n
if (!nodes[j].onchange) {\n
nodes[j].onchange = function() { changed = true; };\n
}\n
}\n
inputs = trs[k].getElementsByTagName(\'input\');\n
for (l=0; l<inputs.length; l++){\n
if (inputs[l].getAttribute("type") != "hidden" &&\n
!inputs[l].onchange) {\n
inputs[l].onchange = function() { changed = true; };\n
} \n
/* Listbox or MatrixBox */\n
if (nodes[j].nodeName == "DIV" && (\n
nodes[j].getAttribute("class") == "listbox" ||\n
nodes[j].getAttribute("class") == "MatrixContent")) {\n
trs = nodes[j].getElementsByTagName(\'td\');\n
for (k=0; k<trs.length; k++){\n
if (trs[k].getAttribute("class") == "listbox_search_line") {\n
continue;\n
}\n
inputs = trs[k].getElementsByTagName(\'input\');\n
for (l=0; l<inputs.length; l++){\n
if (inputs[l].getAttribute("type") != "hidden" &&\n
!inputs[l].onchange) {\n
inputs[l].onchange = function() { changed = true; };\n
}\n
}\n
}\n
}\n
......@@ -307,31 +309,33 @@ var addOnChangeEventHandler = function() {\n
*/\n
var rewriteIndentedSelect = function() {\n
var master = document.getElementById("master");\n
selects = master.getElementsByTagName("select");\n
for (i=0; i<selects.length; i++) {\n
options = selects[i].childNodes;\n
for (j=0; j<options.length; j++) {\n
if (options[j].nodeName != "OPTION") {\n
continue;\n
}\n
text = options[j].innerHTML;\n
if (text.substring(0, 1) == \'\\n\') {\n
text = text.substring(1, text.length);\n
}\n
level = 0;\n
if (text.substring(0, 6) == \'&nbsp;\') {\n
for (idx=0; idx <= text.length; idx+=6) {\n
if (text.substring(idx, idx+6) == \'&nbsp;\') {\n
level += 1;\n
} else {\n
break;\n
if (master){\n
selects = master.getElementsByTagName("select");\n
for (i=0; i<selects.length; i++) {\n
options = selects[i].childNodes;\n
for (j=0; j<options.length; j++) {\n
if (options[j].nodeName != "OPTION") {\n
continue;\n
}\n
text = options[j].innerHTML;\n
if (text.substring(0, 1) == \'\\n\') {\n
text = text.substring(1, text.length);\n
}\n
level = 0;\n
if (text.substring(0, 6) == \'&nbsp;\') {\n
for (idx=0; idx <= text.length; idx+=6) {\n
if (text.substring(idx, idx+6) == \'&nbsp;\') {\n
level += 1;\n
} else {\n
break;\n
}\n
}\n
}\n
}\n
if (level >= 1) {\n
level = level / 4.;\n
options[j].innerHTML = text.replace(/^(&nbsp;)+/, "");\n
options[j].style.paddingLeft = level+"em";\n
if (level >= 1) {\n
level = level / 4.;\n
options[j].innerHTML = text.replace(/^(&nbsp;)+/, "");\n
options[j].style.paddingLeft = level+"em";\n
}\n
}\n
}\n
}\n
......
958
\ No newline at end of file
959
\ 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