Skip to content

Commit

Permalink
Initial add of span parent field in interface for span elements that …
Browse files Browse the repository at this point in the history
…can be nested (issue #3 e/f)
  • Loading branch information
proycon committed Nov 8, 2016
1 parent b0b0bc2 commit 40e8500
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions flat/style/flat.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,18 @@ function applysuggestion(e,i) {
}
}

function renderparentspanfield(index, annotation, nestableparents) {
//This is a nestable span element
var s = "<div class=\"spanparenteditor\">Parent span: " +
"<select name=\"spanparent" + index + "\">" +
"<option value=\"\">(none/root)</option>";
for (var i = 0; i < nestableparents; i++) {
//TODO: collect possibilities
}
s = s + "</div>";
return s;
}


function showeditor(element) {
/* show and populate the editor for a particular element */
Expand Down Expand Up @@ -672,6 +684,13 @@ function showeditor(element) {
ho_result = renderhigherorderfields(editfields, annotation);
s = s + ho_result.output;


var nestablespan = folia_nestablespan(annotation.type);
if (nestablespan.length > 0) {
s = s + renderparentspanfield(editfields, annotation, nestablespan);

}

s = s + "</td></tr>";

//Set up the data structure for this annotation input, changes in the forms will be reflected back into this (all items are pushed to the editdata list)
Expand Down
13 changes: 13 additions & 0 deletions flat/style/folia.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var foliaelements = {};
//Maps FoLiA XML tag to element classes, FLAT works tag-based
var foliatag2class = {};

//Maps span elements (tags) to parent span elements in which they can be
//nested, hard coded for now.. TODO: derive from spec
var folianestablespan = {'su': ['su'], 'semrole': ['predicate'] };

//element classes are internal class names for the FoLiA elements and not to be confused with FoLiA's notion of a class.

function folia_parse(element, ancestors) {
Expand Down Expand Up @@ -111,6 +115,15 @@ function folia_isspanrole(tag) {
return false;
}

function folia_nestablespan(tag) {
//Is this span element nestable in another span element?
//Returns a list of possible parents
if (folianestablespan[tag] !== undefined) {
return folianestablespan[tag];
} else {
return [];
}
}

function folia_isstructure(tag) {
//Is the element a first order span element?
Expand Down

0 comments on commit 40e8500

Please sign in to comment.