Bug: kupusilvatools.js: "Code source is not allowed inside a header" error
Marc Petitmermet <[email protected]> Sun, 11 Nov 2007 12:54:52 +0100
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Message-ID | <[email protected]> |
i was creating a new code source with LookupWindowField or
ReferenceLookupWindowField. and then i was fighting with the error
"Code source is not allowed inside a header". inside what header,
please? i have the code source within the body. i also noted that i
don't get the error all the times.
so here is my analysis which is hopefully too wrong;-)
i finally could figure out in which case i get an error and in which
not. in kupu, a code source is represented with a line containing the
title and a line containing the parameters and the yellow background.
to edit the parameters of a code source, one has to click with the
mouse somewhere in yellow area. at random one sometimes clicks on the
line with the title and sometimes on the line with the parameters. and
every time i click on the line with the title of the code source i get
the "Code source is not allowed inside a header". no error when
clicking on the parameter line.
the error probably lies in the
SilvaExternalSourceTool.prototype.startExternalSourceAddEdit function
in the javascript Silva/kupu/kupusilvatools.js. this function checks
if you place a code source within a header or table which is not
allowed. therefore, it verifies the parenting tags. and here lies the
error: the paraenting tags are <h4></h4> in kupu when clicking in the
line with the tile and this is not allowed and therefore the error.
SilvaExternalSourceTool.prototype.startExternalSourceAddEdit =
function() {
// you should not be allowed to add external sources inside
// headers or table cells
var selNode = this.editor.getSelectedNode();
var not_allowed_parent_tags = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
for (i=0; i < not_allowed_parent_tags.length; i++){
if (selNode.tagName == not_allowed_parent_tags[i]){
alert('Code source is not allowed inside a header.')
return
}
}
[snip]
to avoid this error selNode should not be the parant node but the
great parent node which is the enclosing <div> of the code source:
<div parameter="value" class="externalsource" source_id="mycodesource">
<h4>Silva Code Source «foo»</h4> parameter: value<br></div>
if my analysis is correct a simple change in the line
var selNode = this.editor.getSelectedNode();
should fix this error. i don't know javascript at all so i leave it to
you developers;-)
regards,
marc