Commit a5bd35cd authored by Ivan Tyagov's avatar Ivan Tyagov

Remove contained MochiKit Javascript library

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42491 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fd231590
...@@ -41,90 +41,24 @@ ...@@ -41,90 +41,24 @@
<value> <unicode encoding="cdata"><![CDATA[ <value> <unicode encoding="cdata"><![CDATA[
<tal:block define="dummy python: request.RESPONSE.setHeader(\'Content-Type\', \'application/javascript;; charset=utf-8\')"/>\n <tal:block define="dummy python: request.RESPONSE.setHeader(\'Content-Type\', \'application/javascript;; charset=utf-8\')"/>\n
var loading_deferred = undefined;\n /*\n
Copyright (c) 20xx-2006 Nexedi SARL and Contributors. All Rights Reserved.\n
\n \n
function replaceContent(req) {\n This program is Free Software; you can redistribute it and/or\n
if (loading_deferred) {\n modify it under the terms of the GNU General Public License\n
loading_deferred.cancel();\n as published by the Free Software Foundation; either version 2\n
loading_deferred = undefined;\n of the License, or (at your option) any later version.\n
}\n
//var container = $(\'container\');\n
var container = MochiKit.DOM.getElement("container");\n
container.innerHTML = req.responseText;\n
addOnClickEventsToTabs(req);\n
}\n
\n \n
function showServerSideError(req) {\n This program is distributed in the hope that it will be useful,\n
if (loading_deferred) {\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n
loading_deferred.cancel();\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n
loading_deferred = undefined;\n GNU General Public License for more details.\n
}\n
//var container = $(\'container\');\n
var container = MochiKit.DOM.getElement("container");\n
container.innerHTML = \'Server side error.\';\n
addOnClickEventsToTabs(req);\n
}\n
\n \n
function showLoadingMessage() {\n You should have received a copy of the GNU General Public License\n
//var container = $(\'container\');\n along with this program; if not, write to the Free Software\n
var container = MochiKit.DOM.getElement("container");\n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
container.innerHTML = \'<div><p style="text-align: left; vertical-align: middle; font-size: large;">Loading...</p></div>\';\n */\n
loading_deferred = undefined;\n // XXX: to be overriden in othe JavaScript based styles
}\n
\n
function selectTab(e) {\n
//var tab_box = $(\'tab_box\');\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
var item = item_list[i];\n
//var node = item.getElementsByTagName(\'a\')[0];\n
var node = MochiKit.DOM.getFirstElementByTagAndClassName("a", null, item);\n
if (this == node) {\n
if (getNodeAttribute(item, \'class\') != \'selected\') {\n
MochiKit.DOM.setNodeAttribute(item, \'class\', \'selected\');\n
}\n
node.blur();\n
} else {\n
if (getNodeAttribute(item, \'class\') != \'non_selected\') {\n
MochiKit.DOM.setNodeAttribute(item, \'class\', \'non_selected\');\n
}\n
}\n
MochiKit.Signal.disconnectAll(node, \'onclick\');\n
MochiKit.Signal.connect(node, \'onclick\', function (e) { e.stop(); });\n
}\n
\n
var mapping = {\n
<tal:block \n
tal:replace="structure python: \',\\n\'.join([\'%s: \\x22%s\\x22\' %(x[\'id\'], x[\'renderer\']) for x in context.ERP5Site_getTabList(add_all_tabs=1)])"></tal:block>\n
};\n
\n
var url = mapping[this.parentNode.id];\n
var d = MochiKit.Async.doSimpleXMLHttpRequest(url);\n
d.addCallbacks(replaceContent, showServerSideError);\n
e.stop();\n
\n
loading_deferred = MochiKit.Async.callLater(0.3, showLoadingMessage);\n
\n
// Set a cookie.\n
document.cookie = \'erp5_site_selected_tab=\' + escape(this.parentNode.id);\n
}\n
\n
function addOnClickEventsToTabs(e) {\n
//var tab_box = $(\'tab_box\');\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
//connect(item_list[i], \'onclick\', function(e){e.stop();})\n
//var node = item_list[i].getElementsByTagName(\'a\')[0];\n
var node = MochiKit.DOM.getFirstElementByTagAndClassName("a", null, item_list[i]);\n
MochiKit.Signal.disconnectAll(node, \'onclick\');\n
MochiKit.Signal.connect(node, \'onclick\', selectTab);\n
}\n
return true;\n
}\n
\n
connect(window, \'onload\', addOnClickEventsToTabs);
]]></unicode> </value> ]]></unicode> </value>
</item> </item>
...@@ -142,7 +76,7 @@ connect(window, \'onload\', addOnClickEventsToTabs); ...@@ -142,7 +76,7 @@ connect(window, \'onload\', addOnClickEventsToTabs);
</item> </item>
<item> <item>
<key> <string>output_encoding</string> </key> <key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value> <value> <string>iso-8859-15</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MochiKit</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>MochiKit</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,9 +28,7 @@ ...@@ -28,9 +28,7 @@
</item> </item>
<item> <item>
<key> <string>raw</string> </key> <key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>/*\n
/*\n
Copyright (c) 20xx-2006 Nexedi SARL and Contributors. All Rights Reserved.\n Copyright (c) 20xx-2006 Nexedi SARL and Contributors. All Rights Reserved.\n
\n \n
This program is Free Software; you can redistribute it and/or\n This program is Free Software; you can redistribute it and/or\n
...@@ -62,292 +60,9 @@ function clickSaveButton(act) {\n ...@@ -62,292 +60,9 @@ function clickSaveButton(act) {\n
document.forms[0].action = act;\n document.forms[0].action = act;\n
}\n }\n
\n \n
\n
// The first input element with an "autofocus" class will get the focus,\n
// else if no element have autofocus class, the first element which is not the\n
// search field will get the focus. This is generally the title input text of\n
// a view\n
function autoFocus() {\n
var first_autofocus_expr = ".//input[@class=\'autofocus\']"\n
var FIRST_RESULT = XPathResult.FIRST_ORDERED_NODE_TYPE\n
\n
var input = document.evaluate(first_autofocus_expr, document, null, FIRST_RESULT, null).singleNodeValue;\n
if (input) {\n
input.focus();\n
}else{\n
// The following is disabled, because it is too annoying to have an auto focus at everywhere.\n
//var first_text_input_expr = ".//input[@type=\'text\'][@name != \'field_your_search_text\']"\n
//var first_text_input = document.evaluate(first_text_input_expr, document, null, FIRST_RESULT, null).singleNodeValue;\n
//if (first_text_input){\n
// first_text_input.focus();\n
//}\n
}\n
}\n
\n
function buildTables(element_list, rowPredicate, columnPredicate,\n
tableClassName) {\n
/* Generic code to build a table from elements in element_list.\n
* rowPredicate(element) -> bool\n
* When it returns a true value, a new line is started with element.\n
* When is returns a false value, element is skipped.\n
* columnPredicate(element, initial_element) -> bitfield\n
* bit 3: end_table (if true, imlies end_row)\n
* End current table.\n
* bit 2: end_row\n
* End current row.\n
* bit 1: use_element\n
* Element passed to columnPredicate will be put in current row.\n
* Hardcoded:\n
* - items in a table line must be siblings in existing DOM\n
* - table is put in place of first element of the first row\n
*/\n
var element_index = 0;\n
while (element_index < element_list.length) {\n
var row_list = [];\n
var end_table = false;\n
while ((!end_table) && element_index < element_list.length) {\n
var row_begin = element_list[element_index];\n
if (rowPredicate(row_begin)) {\n
var item_list = [row_begin];\n
var row_item = row_begin;\n
var end_line = false;\n
while ((!end_line) && (row_item = row_item.nextSibling) != null) {\n
var predicate_result = columnPredicate(row_item, row_begin)\n
if ((predicate_result & 1) != 0)\n
item_list.push(row_item);\n
end_table = ((predicate_result & 4) != 0);\n
end_line = ((predicate_result & 6) != 0);\n
}\n
row_list.push(item_list);\n
}\n
element_index++;\n
}\n
/* Do not create a table with just one cell. */\n
if ((row_list.length > 1) ||\n
(row_list.length == 1 && row_list[0].length > 1)) {\n
var first_element = row_list[0][0];\n
var container = first_element.parentNode;\n
var fake_table = document.createElement("table");\n
var i;\n
var j;\n
fake_table.className = tableClassName;\n
container.insertBefore(fake_table, first_element);\n
for (i = 0; i < row_list.length; i++) {\n
var fake_row = document.createElement("tr");\n
var row_element_list = row_list[i];\n
for (j = 0; j < row_element_list.length; j++) {\n
var fake_cell = document.createElement("td");\n
fake_cell.appendChild(row_element_list[j]);\n
fake_row.appendChild(fake_cell);\n
}\n
fake_table.appendChild(fake_row);\n
}\n
}\n
}\n
}\n
\n
function matchLeftFieldset(element) {\n
return (element.tagName == "FIELDSET" &&\n
element.className.toLowerCase().indexOf(\'left\') != -1)\n
}\n
\n
function matchRightFieldset(element, ignored) {\n
if (element.tagName == "FIELDSET" &&\n
element.className.toLowerCase().indexOf(\'right\') != -1)\n
return 7; /* End row, table and use element */\n
return 0;\n
}\n
\n
function fixLeftRightHeightAndFocus(fix_height) {\n
if (fix_height == 1) {\n
buildTables(document.getElementsByTagName(\'fieldset\'),\n
matchLeftFieldset, matchRightFieldset,\n
"fake");\n
}\n
autoFocus();\n
}\n
\n
// This function can be used to catch ENTER pressed in an input\n
// and modify respective main form action\n
// if clear_changed_flag is set to true, changed will be set to false, so no\n
// warning message about unsaved changes will be displayed\n
function submitFormOnEnter(event, form, method_name, clear_changed_flag, element){\n
if (clear_changed_flag == null){\n
clear_changed_flag = false;\n
}\n
if(event.keyCode == 13){\n
if (form == \'main_form\') {\n
form = getElement(form); // backward compatibility\n
}\n
form.action = method_name;\n
if (clear_changed_flag==true) {\n
changed = false;\n
}\n
if(element!=null){\n
// disable other form elements having same name attribute\n
forEach(getElementsByTagAndClassName(element.tagName), function (input){\n
if((input.name == element.name) && (input!=element)){input.disabled = true;}\n
});\n
}\n
form.submit();\n
}\n
}\n
\n
var old_index=0;\n
function shiftCheck(evt) {\n
evt=(evt)?evt:event;\n
var target=(evt.target)?evt.target:evt.srcElement;\n
// remove "checkbox" part from ID\n
// This part can be reused easilly by usual left column\n
var target_index= target.id.substr(8);\n
if(!evt.shiftKey) {\n
old_index= target_index\n
check_option = target.checked;\n
return false;\n
}\n
target.checked=1;\n
var low=Math.min(target_index , old_index);\n
var high=Math.max(target_index , old_index);\n
for(var i=low;i<=high;i++) {\n
document.getElementById("checkbox" + i ).checked = check_option;\n
}\n
return true;\n
}\n
\n
var indexAllCheckBoxesAtBTInstallationOnLoad = function() {\n
// This Part is used basically for Business Template Installation.\n
var inputs = window.getElementsByTagAndClassName("input", "shift_check_support");\n
for(i=0;i<=inputs.length-1;i++) { inputs[i].id = "checkbox" + i; }\n
}\n
\n
function showPopik(dom_id, what, delay){\n
var obj = getElement(dom_id);\n
if(what==true){\n
obj.style.display=\'block\';}\n
else{\n
obj.style.display=\'none\';}\n
}\n
\n
var resizeIFrameOnLoad = function() {\n
var object_list = window.getElementsByTagAndClassName("object", "auto_height");\n
for( var i=0; i<object_list.length; i++) {\n
var object_document = object_list[i];\n
var doc = object_document.contentDocument.documentElement;\n
var body = object_document.contentDocument.body;\n
object_document.style.height = doc.offsetHeight + \'px\';\n
}\n
}\n
\n
var changed = false;\n
function installUnsavedChangesWarning(warning_message) {\n function installUnsavedChangesWarning(warning_message) {\n
window.onbeforeunload = function() {\n // XXX: to be overriden in othe JavaScript based styles \n
if ((changed)&&(getFirstElementByTagAndClassName("button", "save")))\n }</string> </value>
// show an warning box only if save button do exists\n
return warning_message;\n
};\n
};\n
\n
/* Add a onchange event handler for all fields inputs.\n
This event handler set a dirty flag which cause a warning\n
while leaving the page, unless leaving by:\n
- saving (see clickSaveButton function from this file)\n
- clicking a relation field wheel\n
- clicking on a input with type submit\n
*/\n
var addOnChangeEventHandler = function() {\n
var master = document.getElementById("master");\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-container" ||\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
}\n
}\n
}\n
}\n
}\n
/* \n
* Under firefox, rewrite indented title categories using style definition.\n
* This way we can select items by pressing the first letter of their name.\n
*/\n
var rewriteIndentedSelect = function() {\n
var master = document.getElementById("master");\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
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
}\n
\n
\n
if (navigator.userAgent.toLowerCase().indexOf(\'firefox\') != -1)\n
addLoadEvent(rewriteIndentedSelect);\n
\n
addLoadEvent(resizeIFrameOnLoad);\n
addLoadEvent(addOnChangeEventHandler);\n
addLoadEvent(indexAllCheckBoxesAtBTInstallationOnLoad);\n
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -45,12 +45,7 @@ You should have received a copy of the GNU General Public License\n ...@@ -45,12 +45,7 @@ You should have received a copy of the GNU General Public License\n
along with this program; if not, write to the Free Software\n along with this program; if not, write to the Free Software\n
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
*/\n */\n
\n // XXX: to be overriden in othe JavaScript based styles \n
var fixLeftRightHeightAndFocusOnLoad = function () {\n
fixLeftRightHeightAndFocus(1);\n
};\n
\n
addLoadEvent(fixLeftRightHeightAndFocusOnLoad);\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
2011-01-20 Ivan
* Remove contained MochiKit Javascript library
2010-09-07 Kazuhiko 2010-09-07 Kazuhiko
* update FCKeditor to 2.6.6. * update FCKeditor to 2.6.6.
......
1052 1058
\ 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