Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* :organization: Logilab
* :copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
* :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
*/
CubicWeb.require('python.js');
CubicWeb.require('htmlhelpers.js');
CubicWeb.require('ajax.js');
function _getText(textarea) {
if (typeof(FCKeditor) != 'undefined') {
var fck = FCKeditorAPI.GetInstance(textarea.id);
if (fck) {
return fck.GetHTML();
}
}
return textarea.value;
}
/* this function is called on inlined-comment editions
* It calls the add_comment method on the jsoncontroller and reload
* the comment's component
*/
function processComment(eid, funcname) {
var buttonbar = jQuery('#comment' + eid + 'bbar').hide();
var divNode = jQuery('#comment' + eid + 'Slot');
var textarea = divNode.find('textarea')[0];
var comment = _getText(textarea);
if (funcname) {
// store original value for edit cancel
textarea.setAttribute('cubicweb:origval', comment);
var format = 'text/html'; // no select widget if fckeditor is used
var select = divNode.find('select')[0];
if (select) {
format = firstSelected(select);
}
d = asyncRemoteExec(funcname, eid, comment, format);
d.addCallback(function () {
var rooteid = getNode('commentsectionComponent').getAttribute('cubicweb:rooteid');
reloadComponent('commentsection', rql_for_eid(rooteid), 'contentnavigation');
});
} else { // this is of course terrbily inefficient since we reload the whole tree
var rooteid = getNode('commentsectionComponent').getAttribute('cubicweb:rooteid');
reloadComponent('commentsection', rql_for_eid(rooteid), 'contentnavigation');
}
}
CubicWeb.provide('ecomment.js');