Commit f2357346 authored by Ivan Tyagov's avatar Ivan Tyagov

Use Jquery. Update dependency list.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42326 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2bf4b832
...@@ -65,7 +65,7 @@ gadget_title_dom_id = \'%s_gadget_title\' %box_dom_id\n ...@@ -65,7 +65,7 @@ gadget_title_dom_id = \'%s_gadget_title\' %box_dom_id\n
# return some JavaScript which will update respective page\n # return some JavaScript which will update respective page\n
gadget_title = request.get(\'rss_gadget_title\', box.getSpecialiseValue().getTitle())\n gadget_title = request.get(\'rss_gadget_title\', box.getSpecialiseValue().getTitle())\n
gadget_title = unicode(gadget_title).encode(\'utf-8\')[:40]\n gadget_title = unicode(gadget_title).encode(\'utf-8\')[:40]\n
javascript = \'getElement("%s").innerHTML="%s";\' %(gadget_title_dom_id, gadget_title)\n javascript = \'$("#%s").html("%s");\' %(gadget_title_dom_id, gadget_title)\n
\n \n
request.RESPONSE.setHeader("Content-Type", "application/json;; charset=utf-8")\n request.RESPONSE.setHeader("Content-Type", "application/json;; charset=utf-8")\n
result = {"body": html,\n result = {"body": html,\n
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
\n \n
<div class="teaser"\n <div class="teaser"\n
tal:attributes="class python: test(is_read, \'teaser read\', \'teaser unread\');\n tal:attributes="class python: test(is_read, \'teaser read\', \'teaser unread\');\n
onclick string:if(this.className!=\'teaser read\'){this.className=\'teaser read\';;MochiKit.Async.doSimpleXMLHttpRequest(\'Base_setRssItemReadInSelection\', {\'selection_name\':\'${selection_name}\',\'item\':\'${md5}\'})};;toggle(\'${dom_id}\');">\n onclick string:if(this.className!=\'teaser read\'){this.className=\'teaser read\';;$.get(\'Base_setRssItemReadInSelection\', {\'selection_name\':\'${selection_name}\',\'item\':\'${md5}\'})};;$(\'#${dom_id}\').toggle();">\n
<img class="thumbnail-image"\n <img class="thumbnail-image"\n
tal:condition="python: image not in ((), None, [])"\n tal:condition="python: image not in ((), None, [])"\n
tal:attributes="src python: image[0]" alt="Thumbnail"/>\n tal:attributes="src python: image[0]" alt="Thumbnail"/>\n
...@@ -78,8 +78,7 @@ ...@@ -78,8 +78,7 @@
</div>\n </div>\n
</div>\n </div>\n
\n \n
</tal:block>\n </tal:block>
]]></unicode> </value> ]]></unicode> </value>
</item> </item>
...@@ -97,7 +96,7 @@ ...@@ -97,7 +96,7 @@
</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>
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
<br/>\n <br/>\n
<br/>\n <br/>\n
<button type="button"\n <button type="button"\n
onclick="MochiKit.Visual.toggle(\'add_new_tab_dialog\');"\n onclick="$(\'#add_new_tab_dialog\').toggle();"\n
i18n:translate="" \n i18n:translate="" \n
i18n:domain="ui">Cancel</button>\n i18n:domain="ui">Cancel</button>\n
<button type="button"\n <button type="button"\n
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
<button type="button"\n <button type="button"\n
i18n:translate="" \n i18n:translate="" \n
i18n:domain="ui"\n i18n:domain="ui"\n
onclick="MochiKit.Visual.toggle(\'rename_tab_dialog\');">Cancel</button>\n onclick="$(\'#rename_tab_dialog\').toggle();">Cancel</button>\n
<button type="button"\n <button type="button"\n
i18n:translate="" \n i18n:translate="" \n
i18n:domain="ui"\n i18n:domain="ui"\n
......
...@@ -59,8 +59,7 @@ ...@@ -59,8 +59,7 @@
#\n #\n
# BBB: For the history, erp5_xhtml_appearance.js is included by default when\n # BBB: For the history, erp5_xhtml_appearance.js is included by default when\n
# js_list is not pre-defined before the global definitions.\n # js_list is not pre-defined before the global definitions.\n
\n js_list = (\'MochiKit/MochiKit.js\',\'jquery/core/jquery.js\', \'jquery/ui/js/jquery-ui.js\', \'erp5.js\', \'erp5_knowledge_box.js\',)\n
js_list = (\'MochiKit/MochiKit.js\', \'erp5.js\', \'erp5_knowledge_box.js\',)\n
return js_list\n return js_list\n
</string> </value> </string> </value>
</item> </item>
......
...@@ -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>ts92251979.92</string> </value> <value> <string>ts94401374.54</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
......
...@@ -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>ts94407027.22</string> </value> <value> <string>ts94990647.19</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -40,13 +40,10 @@ var is_knowledge_template_used = 0;\n ...@@ -40,13 +40,10 @@ var is_knowledge_template_used = 0;\n
var invisible_gadgets={};\n var invisible_gadgets={};\n
\n \n
function createCustomKnowledgePadOnServer(){\n function createCustomKnowledgePadOnServer(){\n
d = MochiKit.Async.doSimpleXMLHttpRequest("ERP5Site_createDefaultKnowledgePadListForUser", \n $.ajax({url:"ERP5Site_createDefaultKnowledgePadListForUser", \n
{\'mode\': mode,\n data:{mode: mode,\n
\'default_pad_group\': default_pad_group});\n default_pad_group: default_pad_group},\n
d.addCallback(handleServerSuccess);\n success:function(data){window.location=cancel_url + "/view?active_pad_url=" + data;}});\n
function handleServerSuccess(res){\n
response = res.responseText;\n
window.location=cancel_url + \'/view?active_pad_url=\'+response;}\n
}\n }\n
\n \n
function showCreateDefaultKnowledgePadWarningMessage(){\n function showCreateDefaultKnowledgePadWarningMessage(){\n
...@@ -55,10 +52,6 @@ function showCreateDefaultKnowledgePadWarningMessage(){\n ...@@ -55,10 +52,6 @@ function showCreateDefaultKnowledgePadWarningMessage(){\n
createCustomKnowledgePadOnServer();}\n createCustomKnowledgePadOnServer();}\n
}\n }\n
\n \n
function handleServerError(res){\n
/*alert(\'Error on server\');*/\n
};\n
\n
function createCookie(name, value, days, path) {\n function createCookie(name, value, days, path) {\n
if (days){\n if (days){\n
var date = new Date();\n var date = new Date();\n
...@@ -71,74 +64,84 @@ function createCookie(name, value, days, path) {\n ...@@ -71,74 +64,84 @@ function createCookie(name, value, days, path) {\n
\n \n
function updater(url, box_relative_url, dom_id, \n function updater(url, box_relative_url, dom_id, \n
parent_web_section_url, editable_mode, additionnal_request_params){\n parent_web_section_url, editable_mode, additionnal_request_params){\n
/* request box content from server */\n /* Get content from server */\n
request_params = {};\n request_params = {};\n
/* getting parameters for the request in the form\'s hidden inputs */\n additionnal_request_params = typeof(additionnal_request_params) != \'undefined\' ? additionnal_request_params : [];\n
inputs = MochiKit.DOM.getElement(dom_id).getElementsByTagName(\'input\');\n \n
forEach(inputs, function (input){\n // getting parameters for the request in the form\'s hidden inputs\n
if(input.type == \'hidden\'){\n input_list = $("#" + dom_id).find("input");\n
\n
function extractHiddenInputs(index){\n
element = $(this);\n
type = element.attr("type");\n
name = element.attr("name");\n
value = element.val();\n
is_list = name.substring(name.length, name.length - 5) == ":list";\n
if(type == "hidden"){\n
if(name == "gadget_form_id"){\n
// turn \'gadget_form_id\' into \'form_id\'\n // turn \'gadget_form_id\' into \'form_id\'\n
if(input.name == \'gadget_form_id\'){\n request_params["form_id"] = value;}\n
request_params[\'form_id\'] = input.value;}\n else if(is_list){\n
else if(input.name.substring(input.name.length,input.name.length-5) == \':list\'){\n if(typeof(request_params[name]) == "undefined"){\n
if(typeof(request_params[input.name]) == \'undefined\'){\n request_params[name] = new Array()}\n
request_params[input.name] = new Array()\n request_params[name].push(value);}\n
}\n
request_params[input.name].push(input.value);\n
}\n
else{\n else{\n
request_params[input.name] = input.value;\n // not list input\n
}\n request_params[name] = value;}\n
}\n }}\n
});\n \n
\n input_list.each(extractHiddenInputs);\n
/*getting parameters for request from the parameter additionnal_request_params*/\n
forEach(keys(additionnal_request_params), function (key){\n
request_params[key] = additionnal_request_params[key];\n
});\n
\n
request_params[\'box_relative_url\'] = box_relative_url;\n
request_params[\'parent_web_section_url\'] = parent_web_section_url; \n
request_params[\'is_gadget_mode:int\'] = 1; \n
request_params[\'editable_mode:int\'] = editable_mode; \n
\n \n
MochiKit.DOM.getElement(dom_id).style.opacity = 0.5;\n // getting parameters for request from the parameter additionnal_request_params\n
d = MochiKit.Async.doSimpleXMLHttpRequest(url, request_params);\n $.each(additionnal_request_params, \n
d.addCallbacks(handleServerSuccess, handleServerError);\n function (key, value){request_params[key] = additionnal_request_params[key];});\n
function handleServerSuccess(res){\n \n
content_type = res.getResponseHeader(\'Content-Type\');\n request_params["box_relative_url"] = box_relative_url;\n
request_params["parent_web_section_url"] = parent_web_section_url; \n
request_params["is_gadget_mode:int"] = 1; \n
request_params["editable_mode:int"] = editable_mode; \n
\n
// set transperancy to show an activity is going on\n
$("#" + dom_id).css("opacity", 0.5);\n
$.ajax({url:url,\n
data: request_params,\n
success: handleServerSuccess,\n
error: handleServerError,\n
// it\'s important for Zope to have traditional way of encoding an URL\n
traditional: 1});\n
\n
function handleServerSuccess(data, text_status, xhr){\n
content_type = xhr.getResponseHeader(\'Content-Type\');\n
if(content_type.search("application/json")!=-1){\n if(content_type.search("application/json")!=-1){\n
/* server returned JSON which may contain HTML & JavaScript */\n // server returned JSON which may contain HTML & JavaScript\n
text = res.responseText \n html = data[\'body\'];\n
json_dict = evalJSON(text);\n eval(data[\'javascript\']);}\n
html = json_dict[\'body\'];\n
eval(json_dict[\'javascript\']);}\n
else{\n else{\n
/* server returned HTML */\n /* server returned HTML */\n
html = res.responseText;}\n html = data;}\n
/* set HTML as returned from server */\n $("#" + dom_id).html(html);\n
MochiKit.DOM.getElement(dom_id).innerHTML = html;\n $("#" + dom_id).css("opacity", 1.0);\n
MochiKit.DOM.getElement(dom_id).style.opacity = 1.0;};\n }\n
\n \n
function handleServerError(res){\n function handleServerError(res){\n
MochiKit.DOM.getElement(dom_id).innerHTML = \'Server side error.\';\n $("#" + dom_id).html("Server side error.");\n
MochiKit.DOM.getElement(dom_id).style.opacity = 1.0;};\n $("#" + dom_id).css("opacity", 1.0);\n
}\n
}\n }\n
\n \n
\n
function checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group){\n function checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group){\n
/* check if activities are over and refresh current page */\n /* check if activities are over and refresh current page */\n
window.setInterval(\n window.setInterval(\n
function () {\n function () {\n
d = MochiKit.Async.doSimpleXMLHttpRequest(\'ERP5Site_hasUserActivity\',\n $.ajax({url:"ERP5Site_hasUserActivity",\n
{\'js_call\': 1,\n data: {js_call: 1,\n
\'mode\': mode,\n mode: mode,\n
\'default_pad_group\': default_pad_group});\n default_pad_group: default_pad_group},\n
d.addCallback(handleServerSuccess);\n success: function (data){if(data=="False"){window.location=return_url;}}\n
function handleServerSuccess(res){\n })},\n
if(res.responseText==\'False\'){window.location=return_url;}\n
}}, \n
timeout);\n timeout);\n
}\n };\n
\n \n
function stickPadOnWebSection(create_url,\n function stickPadOnWebSection(create_url,\n
knowledge_pad_url,\n knowledge_pad_url,\n
...@@ -146,32 +149,27 @@ function stickPadOnWebSection(create_url,\n ...@@ -146,32 +149,27 @@ function stickPadOnWebSection(create_url,\n
cancel_url){\n cancel_url){\n
/* stick pad on Web Section and then check if \n /* stick pad on Web Section and then check if \n
activities are over and refresh current page */\n activities are over and refresh current page */\n
d = MochiKit.Async.doSimpleXMLHttpRequest(create_url, \n $.ajax({url: create_url,\n
{\'knowledge_pad_url\': knowledge_pad_url,\n data: {knowledge_pad_url: knowledge_pad_url,\n
\'cancel_url\': cancel_url});\n cancel_url: cancel_url},\n
d.addCallbacks(handleServerSuccess, handleServerError);\n success: function(data){window.location=cancel_url + "?active_pad_url=" + data;}\n
function handleServerSuccess(res){\n });\n
window.location=cancel_url+\'?active_pad_url=\'+res.responseText;};\n }\n
};\n
\n \n
function createDefaultPadOnServer(timeout, create_url,\n function createDefaultPadOnServer(timeout, create_url,\n
default_pad_group, return_url, mode){\n default_pad_group, return_url, mode){\n
/* create default tab on server and then check if \n /* create default tab on server and then check if \n
activities are over and refresh current page */\n activities are over and refresh current page */\n
d = MochiKit.Async.doSimpleXMLHttpRequest(create_url, \n $.ajax({url: create_url, \n
{\'default_pad_group\': default_pad_group,\n data: {default_pad_group: default_pad_group,\n
\'mode\': mode});\n mode: mode},\n
d.addCallbacks(handleServerSuccess, handleServerError);\n success: function(data){checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group);}});\n
function handleServerSuccess(res){\n }\n
checkForActivitiesOnServer(timeout, return_url, mode, default_pad_group);};\n
};\n
\n \n
// This function can be used to submit gadget preferences form whenever\n
// an enter is pressed in form\n
function submitGadgetPreferenceFormOnEnter(event, form_fields_main_prefix, box_relative_url){\n function submitGadgetPreferenceFormOnEnter(event, form_fields_main_prefix, box_relative_url){\n
if(event.keyCode == 13){\n /* This function can be used to submit gadget preferences form whenever\n
submitSynchronousGadgetPreferenceForm(form_fields_main_prefix, box_relative_url);\n an enter is pressed in form */\n
}\n if(event.keyCode == 13){submitSynchronousGadgetPreferenceForm(form_fields_main_prefix, box_relative_url);}\n
}\n }\n
\n \n
function submitSynchronousGadgetPreferenceForm(\n function submitSynchronousGadgetPreferenceForm(\n
...@@ -180,21 +178,11 @@ function submitSynchronousGadgetPreferenceForm(\n ...@@ -180,21 +178,11 @@ function submitSynchronousGadgetPreferenceForm(\n
/* this will add respective gadget knowledge box relative url and\n /* this will add respective gadget knowledge box relative url and\n
gadget ERP5 preference form field_prefix (so multiple gadgets can \n gadget ERP5 preference form field_prefix (so multiple gadgets can \n
safely coexist in one HTML page with one HTML form */\n safely coexist in one HTML page with one HTML form */\n
appendChildNodes(document.forms[0], \n
INPUT({\'value\':box_relative_url, \n
\'name\': \'box_relative_url\', \n
\'type\':\'hidden\'}));\n
appendChildNodes(document.forms[0], \n
INPUT({\'value\':form_fields_main_prefix, \n
\'name\': \'form_fields_main_prefix\', \n
\'type\':\'hidden\'}));\n
// append current return URL so we know where to redirect user\n
redirect_url = window.location.protocol + "//" + window.location.host + window.location.pathname\n redirect_url = window.location.protocol + "//" + window.location.host + window.location.pathname\n
appendChildNodes(document.forms[0], \n $("form").append(\'<input type="hidden" name="box_relative_url" value="\' +box_relative_url + \'">\');\n
INPUT({\'value\':redirect_url, \n $("form").append(\'<input type="hidden" name="form_fields_main_prefix" value="\' +form_fields_main_prefix + \'">\');\n
\'name\': "gadget_redirect_url", \n $("form").append(\'<input type="hidden" name="gadget_redirect_url" value="\' +redirect_url + \'">\');\n
\'type\':\'hidden\'}));\n clickSaveButton("KnowledgeBox_baseEdit"); \n
clickSaveButton(\'KnowledgeBox_baseEdit\');\n
};\n };\n
\n \n
function submitAsynchronousGadgetPreferenceForm(\n function submitAsynchronousGadgetPreferenceForm(\n
...@@ -203,78 +191,78 @@ function submitAsynchronousGadgetPreferenceForm(\n ...@@ -203,78 +191,78 @@ function submitAsynchronousGadgetPreferenceForm(\n
box_relative_url, \n box_relative_url, \n
visual_block_dom_id, \n visual_block_dom_id, \n
form_fields_main_prefix){\n form_fields_main_prefix){\n
// iterate over all possible form elements within edit form,\n /* Iterate over all possible form elements within edit form,\n
// collect them and send to server\n collect them and send to server*/\n
var request_str = "?box_relative_url=" + box_relative_url+ "&form_fields_main_prefix=" + form_fields_main_prefix + "&";\n var request_str = "box_relative_url=" + box_relative_url+ "&form_fields_main_prefix=" + form_fields_main_prefix + "&";\n
forEach(MochiKit.DOM.getElementsByTagAndClassName(\'input\', null, form_dom_id) , function (item) {\n \n
if (item.type == "checkbox"){\n //input tags\n
if (item.checked){request_str+=item.name + \':boolean=True&\';}\n $("#" + form_dom_id).find("input").each(\n
else {request_str+=item.name + \':boolean=False&\';}}\n function (index) {\n
if (item.type == "radio"){\n element = $(this);\n
if (item.checked){request_str+=item.name + \'=\'+item.value+\'&\';}}\n type = element.attr("type");\n
if (item.type == "text"){request_str+=item.name + \'=\' + item.value + \'&\';}\n name = element.attr("name");\n
if (item.type == "password"){request_str+=item.name + \'=\' + item.value + \'&\';}\n is_checked = element.attr("checked");\n
});\n value = element.val()\n
forEach(MochiKit.DOM.getElementsByTagAndClassName(\'select\', null, form_dom_id), function (item) {\n if (type == "checkbox"){\n
//support multifield in gadget edit form\n if (is_checked){request_str+=name + ":boolean=True&";}\n
if (item.multiple){\n else {request_str+=name + ":boolean=False&";}}\n
forEach(MochiKit.DOM.getElementsByTagAndClassName(\'option\', null, item), function (selection) {\n if (type == "radio" && is_checked){request_str+=name + "="+value+"&";}\n
if(selection.selected){\n if (type == "text" || type == "password"){request_str+=name + "=" + value + "&";}\n
request_str+=item.name + \'=\' + selection.value + \'&\';\n } );\n
}\n \n
});\n // select tags\n
}else{\n $("#" + form_dom_id).find("select").each(\n
request_str+=item.name + \'=\' + item.value + \'&\';\n function (index) {\n
}\n element = $(this);\n
});\n name = element.attr("name");\n
\n is_multiple = element.attr("multiple");\n
/* save form preferences to remote server*/\n value = element.val() \n
url = "KnowledgeBox_baseEdit" + request_str;\n if (is_multiple){\n
d = MochiKit.Async.doSimpleXMLHttpRequest(url);\n //support multifield selects in gadget edit form\n
d.addCallback(handleServerSuccess);\n element.children("option").each(\n
function handleServerSuccess(res){\n function (index) {\n
/* update content view area back from server */\n option = $(this);\n
if(option.attr("selected")){request_str+=element.attr("name") + \'=\' + option.val() + \'&\';}\n
}); }\n
else{request_str+=name + \'=\' + value + \'&\';} });\n
\n
// save form preferences to remote server\n
$.ajax({url: "KnowledgeBox_baseEdit?" + request_str,\n
success: function (data){\n
updater(view_form_url, box_relative_url, visual_block_dom_id);\n updater(view_form_url, box_relative_url, visual_block_dom_id);\n
MochiKit.Visual.toggle(form_dom_id);}\n $("#" + form_dom_id).toggle();} });\n
};\n }\n
\n \n
function updateServerBoxColumnLayout(container){\n function updateServerBoxColumnLayout(event, ui){\n
// read columns structure from DOM ..\n /* read columns structure from DOM and save it to server */\n
var columns_arr = new Array;\n var columns_arr = new Array;\n
var columns = MochiKit.DOM.getElementsByTagAndClassName("div", "portal-column");\n var columns = $("div.portal-column");\n
// sort alphabetically as it\'s required to get proper layout from DOM\n // sort alphabetically as it\'s required to get proper layout from DOM\n
columns.sort(keyComparator("id")); \n columns.sort(function(a, b) {\n
for (var i = 0; i < columns.length; i++){\n var compA = $(a).attr("id").toUpperCase();\n
column_items = MochiKit.DOM.getElementsByTagAndClassName("div", "block", columns[i]);\n var compB = $(b).attr("id").toUpperCase();\n
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;})\n
\n
columns.each(function(column_index, column){\n
column = $(this);\n
var items_arr = new Array;\n var items_arr = new Array;\n
for (var j = 0; j < column_items.length; j++){\n column_items = column.find("div.block");\n
items_arr[j] = column_items[j].id;};\n column_items.each(function(box_index, box){\n
columns_arr[i] = items_arr.join(\'|\')\n items_arr[box_index] = column_items[box_index].id;}); \n
};\n columns_arr[column_index] = items_arr.join(\'|\') });\n
var layout = columns_arr.join(\'##\');\n \n
var layout = columns_arr.join("##");\n
// .. and send it to server only if it\'s different\n // .. and send it to server only if it\'s different\n
// XXX: This may bloat ZODB as everry change is a chnage to an ZODB object.\n
if (layout!=last_layout){\n if (layout!=last_layout){\n
last_layout = layout;\n last_layout = layout;\n
MochiKit.Async.doSimpleXMLHttpRequest("KnowledgePad_saveBoxColumnLayout", {user_layout: layout});\n $.ajax({url: "KnowledgePad_saveBoxColumnLayout", \n
}\n data: {user_layout: layout}});}\n
return\n
}\n
\n
function addBoxToServer(url, dom_id, gadget_relative_url){\n
/* add gadget to knowledge pad */\n
d = MochiKit.Async.doSimpleXMLHttpRequest(url, {gadget_relative_url: gadget_relative_url});\n
d.addCallback(handleServerSuccess);\n
function handleServerSuccess(res){\n
button = MochiKit.DOM.getElement(dom_id);\n
button.innerHTML = res.responseText;\n
button.disabled = true;}\n
}\n }\n
\n \n
function showAddNewPadPopup(){\n function showAddNewPadPopup(){\n
MochiKit.Visual.toggle(\'add_new_tab_dialog\');\n $("#add_new_tab_dialog").toggle();\n
// set focus on new Pad title after toggle effect is over \n // set focus on new Pad title after toggle effect is over \n
setTimeout("MochiKit.DOM.getElement(\'new_pad_title\').focus()", 500 );\n setTimeout("$(\'#new_pad_title\').focus()", 500 );\n
}\n }\n
\n \n
function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_id){\n function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_id){\n
...@@ -282,55 +270,53 @@ function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_ ...@@ -282,55 +270,53 @@ function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_
active_knowledge_pad_relative_url = knowledge_pad_relative_url;\n active_knowledge_pad_relative_url = knowledge_pad_relative_url;\n
active_knowledge_pad_title_dom_id = knowledge_pad_title_dom_id;\n active_knowledge_pad_title_dom_id = knowledge_pad_title_dom_id;\n
// init rename dialog input field to current active pad\n // init rename dialog input field to current active pad\n
MochiKit.DOM.getElement("new_knowledge_pad_title").value = MochiKit.DOM.getElement(knowledge_pad_title_dom_id).innerHTML;\n $("#new_knowledge_pad_title")[0].value = $("#"+knowledge_pad_title_dom_id)[0].innerHTML;\n
// show rename dialog\n // show rename dialog\n
MochiKit.Visual.toggle("rename_tab_dialog");\n $("#rename_tab_dialog").toggle();\n
// set focus on new Pad title after toggle effect is over \n // set focus on new Pad title after toggle effect is over \n
setTimeout("MochiKit.DOM.getElement(\'new_knowledge_pad_title\').focus()", 500 );\n setTimeout("$(\'#new_knowledge_pad_title\').focus()", 500);\n
}\n }\n
\n \n
function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
/* Load Pad from server */\n /* Load Pad from server */\n
// show some animation\n // show some animation\n
MochiKit.DOM.getElement("loading-wrapper").style.display="block";\n $("#loading-wrapper").first().show()\n
\n $.ajax({url: "KnowledgePag_getPadAsJSON", \n
d = MochiKit.Async.loadJSONDoc(\'KnowledgePag_getPadAsJSON\', \n data: {pad_relative_url: pad_relative_url,\n
{\'pad_relative_url\':pad_relative_url,\n mode: mode},\n
\'mode\':mode});\n dataType: "json",\n
d.addCallbacks(handleServerSuccess, metadataFetchFailed);\n success: handleServerSuccess});\n
\n
// set old pad to not selected\n // set old pad to not selected\n
pads_container = MochiKit.DOM.getElement("tabs");\n old_selected_pad = $("#tabs ul").children("li.tab_selected").first()\n
old_selected_pad = MochiKit.DOM.getFirstElementByTagAndClassName("li", "tab_selected", pads_container);\n old_selected_pad.removeClass("tab_selected");\n
old_selected_pad.setAttribute("class", "tab");\n old_selected_pad.addClass("tab");\n
pad_actions = MochiKit.DOM.getFirstElementByTagAndClassName("div", "pad-actions", old_selected_pad);\n \n
pad_actions.style.display="none";\n pad_actions = old_selected_pad.children("div.pad-actions").first();\n
pad_actions.hide();\n
\n \n
// set new selected pad class \n // set new selected pad class \n
new_selected_pad = MochiKit.DOM.getElement(selected_pad_dom_id);\n new_selected_pad = $("#" + selected_pad_dom_id).first();\n
new_selected_pad.setAttribute("class", "tab tab_selected");\n new_selected_pad.addClass("tab_selected");\n
\n \n
// enable "settings" for this pad and hide instant switch\n // enable "settings" for this pad and hide instant switch\n
pad_actions = getFirstElementByTagAndClassName("div", "pad-actions", new_selected_pad);\n pad_actions = new_selected_pad.children("div.pad-actions").first()\n
pad_actions.style.display="block";\n pad_actions.show()\n
\n \n
// set new active pad\n // set new active pad\n
active_knowledge_pad_relative_url = pad_relative_url;\n active_knowledge_pad_relative_url = pad_relative_url;\n
\n \n
function metadataFetchFailed(meta){}\n //function metadataFetchFailed(meta){}\n
\n function handleServerSuccess(data){\n
function handleServerSuccess(meta){\n body = data.body\n
body = meta.body\n javascript = data.javascript\n
javascript = meta.javascript\n body_element = $("#pad-body-wrapper")[0]\n
body_element = MochiKit.DOM.getElement(\'pad-body-wrapper\');\n
body_element.innerHTML = body;\n body_element.innerHTML = body;\n
// init new Pad\n // init new Pad\n
initialize();\n initialize();\n
// execute JS code provided by server\n // execute JS code provided by server\n
eval(javascript);\n eval(javascript);\n
// give some timeout as we can be sometimes two fast loading a tab\n // give some timeout as we can be sometimes two fast loading a tab\n
setTimeout("MochiKit.DOM.getElement(\'loading-wrapper\').style.display=\'none\';", 250 );\n setTimeout("$(\'#loading-wrapper\').first().hide();", 250 );};\n
}\n
}\n }\n
\n \n
function addNewPad(cancel_url, knowledge_pad_relative_url, mode){\n function addNewPad(cancel_url, knowledge_pad_relative_url, mode){\n
...@@ -346,17 +332,15 @@ function addPadOnServerOnEnter(event, create_url, mode, cancel_url){\n ...@@ -346,17 +332,15 @@ function addPadOnServerOnEnter(event, create_url, mode, cancel_url){\n
/* Catch and submit form when ENTER is pressed */\n /* Catch and submit form when ENTER is pressed */\n
if(event.keyCode == 13){\n if(event.keyCode == 13){\n
addPadOnServer(create_url, mode, cancel_url);\n addPadOnServer(create_url, mode, cancel_url);\n
return false;\n return false;}\n
}\n
}\n }\n
\n \n
function addPadOnServer(create_url,\n function addPadOnServer(create_url,\n
mode,\n mode,\n
cancel_url){\n cancel_url){\n
/* add pad on server */\n /* add pad on server */\n
pad_title = MochiKit.DOM.getElement(\'new_pad_title\');\n pad_title_value = $("#new_pad_title").first().val();\n
pad_title_value = pad_title.value\n window.location = create_url + "?redirect_url=" + cancel_url + "&mode=" + mode + "&pad_title=" + pad_title_value;\n
window.location = create_url + \'?redirect_url=\' + cancel_url + \'&mode=\' + mode + \'&pad_title=\'+pad_title_value ;\n
};\n };\n
\n \n
function removeKnowledgePadFromServer(knowledge_pad_relative_url, mode){\n function removeKnowledgePadFromServer(knowledge_pad_relative_url, mode){\n
...@@ -367,15 +351,13 @@ function removeKnowledgePadFromServer(knowledge_pad_relative_url, mode){\n ...@@ -367,15 +351,13 @@ function removeKnowledgePadFromServer(knowledge_pad_relative_url, mode){\n
var user_choice = true;\n var user_choice = true;\n
user_choice = confirm("Are you sure you want to remove this pad from your home?");\n user_choice = confirm("Are you sure you want to remove this pad from your home?");\n
if (user_choice==true){\n if (user_choice==true){\n
location.href="ERP5Site_deleteKnowledgePad?knowledge_pad_relative_url=" + knowledge_pad_relative_url+"&mode="+mode;}\n location.href="ERP5Site_deleteKnowledgePad?knowledge_pad_relative_url=" + knowledge_pad_relative_url+"&mode="+mode;} }\n
}\n
}\n }\n
\n \n
function renameKnowledgePadToServerOnEnter(event){\n function renameKnowledgePadToServerOnEnter(event){\n
if(event.keyCode == 13){\n if(event.keyCode == 13){\n
renameKnowledgePadToServer();\n renameKnowledgePadToServer();\n
return false;\n return false;}\n
}\n
return true;\n return true;\n
}\n }\n
\n \n
...@@ -384,118 +366,114 @@ function renameKnowledgePadToServer(){\n ...@@ -384,118 +366,114 @@ function renameKnowledgePadToServer(){\n
showCreateDefaultKnowledgePadWarningMessage();}\n showCreateDefaultKnowledgePadWarningMessage();}\n
else{\n else{\n
// rename it locally and update server asynchonously\n // rename it locally and update server asynchonously\n
title_element = MochiKit.DOM.getElement(active_knowledge_pad_title_dom_id)\n title_element = $("#"+active_knowledge_pad_title_dom_id).first()\n
input_element = MochiKit.DOM.getElement("new_knowledge_pad_title")\n input_element = $("#new_knowledge_pad_title")\n
var knowledge_pad_title = input_element.value;\n var knowledge_pad_title = input_element.val();\n
title_element.innerHTML = knowledge_pad_title;\n title_element.html(knowledge_pad_title);\n
MochiKit.Async.doSimpleXMLHttpRequest("ERP5Site_renameKnowledgePad", \n $.ajax({url: "ERP5Site_renameKnowledgePad", \n
{knowledge_pad_relative_url: active_knowledge_pad_relative_url,\n data: {knowledge_pad_relative_url: active_knowledge_pad_relative_url,\n
knowledge_pad_title: knowledge_pad_title});\n knowledge_pad_title: knowledge_pad_title}}); \n
}\n }\n
//anyway toggle show dialog\n $("#rename_tab_dialog").toggle();\n
MochiKit.Visual.toggle("rename_tab_dialog");\n
}\n }\n
\n \n
function initialize(){\n function initialize(){\n
// define sortable columns\n // initialize sortable columns\n
if (is_knowledge_template_used==0){\n if (is_knowledge_template_used==0){\n
// allow drag and drop only if we are dealing with a pad we can modify\n // allow drag and drop only if we are dealing with a pad we can modify\n
var sortables = MochiKit.DOM.getElementsByTagAndClassName(\'div\', \'portal-column\');\n sortable_list = $("div.portal-column");\n
forEach(sortables, function (item) {\n function makeSortables(index){\n
element = $(this);\n
if (element.attr("class") == "portal-column"){\n
// eliminate undraggable columns by checking exact match\n // eliminate undraggable columns by checking exact match\n
if (item.className==\'portal-column\'){\n element.sortable({handle: "h3.handle",\n
MochiKit.Sortable.create(item.id, {"constraint" : false,\n connectWith: sortable_list,\n
"containment" : sortables,\n placeholder: "block-hover",\n
"handle": "handle",\n forcePlaceholderSize: 1,\n
"only": "block",\n opacity: 0.8,\n
"tag": "div",\n containment: "document",\n
"scroll": "true",\n delay: 100,\n
"hoverclass": "block-hover",\n stop: updateServerBoxColumnLayout});} }\n
"dropOnEmpty": "true",\n if (sortable_list!=null) sortable_list.each(makeSortables);\n
"onUpdate": updateServerBoxColumnLayout,\n }\n
"starteffect" : MochiKit.Base.noop,\n
"endeffect" : MochiKit.Base.noop\n
});\n
};\n
})}\n
\n \n
// enable show/hide tabs\n // enable show/hide tabs\n
tabs = MochiKit.DOM.getElement(\'tabs\');\n tabs = $("#tabs");\n
tabs_switcher = MochiKit.DOM.getElement("tabs_switcher");\n tabs_switcher = $("#tabs_switcher"); \n
add_gadget = MochiKit.DOM.getElement("add_new_gadget_link")\n add_gadget = $("#add_new_gadget_link");\n
if(tabs_switcher){\n \n
connect(tabs_switcher, \'onclick\', function (){\n function toggleTabNavigation(){\n
/* Toggle tabs navigation */\n
var is_tabs_visible=0;\n var is_tabs_visible=0;\n
if(tabs.style.display!=\'block\'){\n if(tabs.css("display")!="block"){\n
is_tabs_visible=1;\n is_tabs_visible=1;\n
MochiKit.DOM.getElement("tab_switcher_visible").style.display = "block";\n $("#tab_switcher_visible").show();\n
MochiKit.DOM.getElement("tab_switcher_hidden").style.display = "none";\n $("#tab_switcher_hidden").hide();}\n
add_gadget.className = "border_bottom1px";\n
tabs_switcher.className = "border_bottom1px";\n
}\n
else{\n else{\n
MochiKit.DOM.getElement("tab_switcher_hidden").style.display = "block";\n $("#tab_switcher_visible").hide();\n
MochiKit.DOM.getElement("tab_switcher_visible").style.display = "none";\n $("#tab_switcher_hidden").show();}\n
add_gadget.className = "border_bottom0px";\n tabs.toggle();\n
tabs_switcher.className = "border_bottom0px";\n createCookie("is_tabs_visible", is_tabs_visible, 365); }\n
}\n \n
MochiKit.Visual.toggle(tabs);\n function bindGadgetHandlers(index, box){\n
createCookie("is_tabs_visible", is_tabs_visible, 365);\n /* Bind all gadgets handlers */\n
});}\n box = $(this)\n
\n var edit = box.find("a.block-edit-form").first();\n
// for each box (gadget) add respective event handlers\n var edit_form = box.find("div.edit-form").first();\n
var boxes = MochiKit.DOM.getElementsByTagAndClassName("div", "block");\n var remove = box.find("a.block-remove").first(); \n
forEach(boxes, function (box) {\n var minimize = box.find("a.block-minimize").first(); \n
var edit = MochiKit.DOM.getFirstElementByTagAndClassName(\'a\',\n var minimize_wrapper = box.find("div.minimize_wrapper").first(); \n
\'block-edit-form\', box);\n
var edit_form = MochiKit.DOM.getFirstElementByTagAndClassName(\'div\', \n
\'edit-form\', box);\n
var remove = MochiKit.DOM.getFirstElementByTagAndClassName(\'a\', \n
\'block-remove\', box);\n
var minimize = MochiKit.DOM.getFirstElementByTagAndClassName(\'a\', \n
\'block-minimize\', box);\n
var minimize_wrapper = MochiKit.DOM.getFirstElementByTagAndClassName(\'div\', \n
\'minimize_wrapper\', box);\n
if(minimize){\n if(minimize){\n
connect(minimize, \'onclick\', function (){\n minimize.bind("click", function (){\n
if (is_knowledge_template_used){\n if (is_knowledge_template_used){showCreateDefaultKnowledgePadWarningMessage();}\n
showCreateDefaultKnowledgePadWarningMessage();}\n
else{\n else{\n
// togle DOM element (locally)\n minimize_wrapper.toggle();\n
MochiKit.Visual.toggle(minimize_wrapper);\n box_id = box.attr("id")\n
js_dom_id = box.id + \'_content\';\n js_dom_id = box_id + "_content";\n
js_code = invisible_gadgets[js_dom_id];\n js_code = invisible_gadgets[js_dom_id];\n
if (js_code!=undefined){\n if (js_code!=undefined){\n
eval(js_code);\n eval(js_code);\n
// gadget is now visible, i.e. no need to query server just toggle locally dom\n // gadget is now visible, i.e. no need to query server just toggle locally dom\n
delete invisible_gadgets[js_dom_id];}\n delete invisible_gadgets[js_dom_id];}\n
// update server \n $.ajax({url: "KnowledgeBox_toggleVisibility", \n
MochiKit.Async.doSimpleXMLHttpRequest("KnowledgeBox_toggleVisibility", \n data: {box_relative_url: box_id}});\n
{box_relative_url: box.id});}});\n
}\n
if(edit){\n
connect(edit, \'onclick\', function (){\n
if (is_knowledge_template_used){\n
showCreateDefaultKnowledgePadWarningMessage();}\n
else{MochiKit.Visual.toggle(edit_form);}});\n
}\n }\n
});}\n
\n \n
if(edit){\n
edit.bind("click", function (){\n
if (is_knowledge_template_used){showCreateDefaultKnowledgePadWarningMessage();}\n
else{edit_form.toggle()}});}\n
\n
if(remove){\n if(remove){\n
connect(remove, \'onclick\', function (){\n remove.bind("click", function (){\n
if (is_knowledge_template_used){\n if (is_knowledge_template_used){showCreateDefaultKnowledgePadWarningMessage();}\n
showCreateDefaultKnowledgePadWarningMessage();}\n
else{\n else{\n
user_choice = confirm("Are you sure you want to remove this gadget from your personalized page?");\n user_choice = confirm("Are you sure you want to remove this gadget from your personalized page?");\n
if (user_choice==true){\n if (user_choice==true){\n
MochiKit.Visual.toggle(box);\n box_id = box.attr("id");\n
MochiKit.Async.doSimpleXMLHttpRequest("KnowledgePad_deleteBox", \n box.toggle();\n
{box_relative_url: box.id});}}});\n $.ajax({url: "KnowledgePad_deleteBox", \n
data: {box_relative_url: box_id}});}\n
}});}\n
}\n
\n
// tabs navigation\n
if(tabs_switcher){tabs_switcher.bind("click", toggleTabNavigation);}\n
\n
// for each box (gadget) add respective event handlers\n
gadget_list = $("div.block");\n
if (gadget_list!=null){\n
gadget_list.each(bindGadgetHandlers);\n
// when dom is loaded we need to remove all gadget\'s scripts otherwise currently when a gadget is moved\n
// its HTML is getting executed again, thus making unecessary calls to server, etc ...\n
gadget_list.each(\n
function (index, box){ $(this).find("script").remove();});\n
}\n }\n
});\n
}\n }\n
\n \n
// call function after load of document\n // call function after load of document\n
MochiKit.DOM.addLoadEvent(initialize);\n $(document).ready(initialize);\n
]]></string> </value> ]]></string> </value>
...@@ -506,7 +484,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n ...@@ -506,7 +484,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>20374</int> </value> <value> <int>17664</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
2011-01-14 Ivan
* Use Jquery
2010-12-13 nicolas.dumazet 2010-12-13 nicolas.dumazet
* Migrate Tools to portal type classes * Migrate Tools to portal type classes
......
erp5_base erp5_base
erp5_jquery
erp5_jquery_ui
\ No newline at end of file
671 674
\ 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