minibar: click on a linearization to obtain a table with all variants and forms

Click again to hide the table.
This commit is contained in:
hallgren
2013-03-27 16:35:56 +00:00
parent e4809aba37
commit 6076ed6ca0
2 changed files with 34 additions and 4 deletions

View File

@@ -87,3 +87,6 @@ div.browse, table.browse td {
background: white;
padding: 2px;
}
table.lintable { display: inline-table; border-collapse: collapse; }
table.lintable td { border: 1px solid black; padding: 2px; }

View File

@@ -75,14 +75,41 @@ Translations.prototype.show_translations=function(translationResults) {
function tdt(tree_btn,s,action) {
var txt=text(s);
if(action) {
txt=node("span",{onclick:action},[txt])
txt=wrap("span",[txt])
txt.onclick=action
//txt=button(s,action)
}
return self.options.show_trees ? tda([tree_btn,text(" "),txt]) : td(txt)
return self.options.show_trees ? td([tree_btn,text(" "),txt]) : td(txt)
}
function act(lin) {
return self.lin_action ? function() { self.lin_action(lin) } : null
}
function show_lin(tree_btn,lin,tree) {
function draw_table(lintable) {
function draw_texts(texts) {
return texts.map(function(s) { return wrap("div",text(s)) })
}
function draw_row(row) {
return tr([td(text(row.params)),td(draw_texts(row.texts))])
}
return wrap_class("table","lintable",lintable.map(draw_row))
}
function get_tabular() {
var t=this
var pa=this.parentNode
function show_table(lins) {
if(lins.length==1) {
var ta=draw_table(lins[0].table)
replaceNode(ta,t)
ta.onclick=function() { replaceNode(t,ta) }
t.onclick=function() { replaceNode(ta,t) }
}
}
self.server.pgf_call("linearizeTable",{"tree":tree,"to":lin.to},
show_table)
}
return tdt(tree_btn,lin.text,get_tabular)
}
with(self) {
var trans=main;
//var to=target_lang(); // wrong
@@ -139,8 +166,8 @@ Translations.prototype.show_translations=function(translationResults) {
button(langcode,act(lin[i])))
//hdr.disabled=lin[i].to==current.from
var btn=parsetree_button(t.tree,lin[i].to)
tbody.appendChild(tr([th(hdr),
tdt(btn,lin[i].text)]));
tbody.appendChild(
tr([th(hdr),show_lin(btn,lin[i],t.tree)]));
}
}
trans.appendChild(wrap("table",tbody));