gfse: example-based: some usability improvements

Instead of showing nothing, show disabled buttons and some expanatory text to
provide guidance for users getting started with example-based grammar writing.
This commit is contained in:
hallgren
2011-11-21 15:24:29 +00:00
parent e9e029d39f
commit d66110f84e
4 changed files with 30 additions and 15 deletions

View File

@@ -31,10 +31,10 @@ function upload(g) {
var form=node("form",{method:"post",action:"/cloud"}, var form=node("form",{method:"post",action:"/cloud"},
[hidden("dir",dir),hidden("command","make"), [hidden("dir",dir),hidden("command","make"),
hidden(g.basename+".gf",show_abstract(g))]) hidden(g.basename+".gf",show_abstract(g))])
var files = [g.basename+".gf"] //var files = [g.basename+".gf"]
for(var i in g.concretes) { for(var i in g.concretes) {
var cname=g.basename+g.concretes[i].langcode+".gf"; var cname=g.basename+g.concretes[i].langcode+".gf";
files.push(cname); //files.push(cname);
form.appendChild(hidden(cname, form.appendChild(hidden(cname,
show_concrete(g.basename)(g.concretes[i]))); show_concrete(g.basename)(g.concretes[i])));
} }

View File

@@ -52,7 +52,7 @@ div.template:hover
.edit { color: orange; } .edit { color: orange; }
.delete { color: red; } .delete { color: red; }
.error_message,.inError { color: red; } .error_message,.inError { color: red; }
.template, .template .sep { color: #999; } .template, .template .sep, .unimportant { color: #999; }
form { display: inline-block; } form { display: inline-block; }
table.tabs { table.tabs {

View File

@@ -990,6 +990,7 @@ function inError(msg,el) {
function kw(txt) { return wrap_class("span","kw",text(txt)); } function kw(txt) { return wrap_class("span","kw",text(txt)); }
function sep(txt) { return wrap_class("span","sep",text(txt)); } function sep(txt) { return wrap_class("span","sep",text(txt)); }
function ident(txt) { return wrap_class("span","ident",text(txt)); } function ident(txt) { return wrap_class("span","ident",text(txt)); }
function unimportant(txt) { return wrap_class("small","unimportant",text(txt)); }
function indent(cs) { return div_class("indent",cs); } function indent(cs) { return div_class("indent",cs); }
function indent_sortable(cs,sort) { function indent_sortable(cs,sort) {

View File

@@ -78,15 +78,24 @@ function exb_extra(g,ci) {
function ask_poss() { ask_possibilities(g,ci) } function ask_poss() { ask_possibilities(g,ci) }
if(navigator.onLine && g.concretes.length>1 && conc.example_based && !example_based[ci]) ask_poss(); if(navigator.onLine && g.concretes.length>1 && conc.example_based && !example_based[ci]) ask_poss();
return parser[conc.langcode] && g.concretes.length>1 var sb=button("Start",ask_poss)
? indent([text("Example based editing: "), if(parser[conc.langcode] && g.concretes.length>1)
conc.example_based return indent([wrap("small",text("Example-based editing: ")),
? node("span",{},[button("Stop",stop_exb), conc.example_based
text(" Example language: "), ? node("span",{},
exblangmenu() [button("Stop",stop_exb),
]) wrap("small",text(" Example language: ")),
: button("Start",ask_poss)]) exblangmenu()
: text("") ])
: sb])
else {
sb.disabled=true;
var why= g.concretes.length>1
? " ("+concname(conc.langcode)+" is not supported yet)"
: " (Add another language to take examples from first.)"
return indent([unimportant("Example-based grammar editing: "), sb,
unimportant(why)])
}
} }
function fun_lincat(g,conc,fun) { function fun_lincat(g,conc,fun) {
@@ -158,10 +167,15 @@ function exb_linbuttons(g,ci,f) {
} }
var buttons=[]; var buttons=[];
if(conc.example_based && eb) { if(conc.example_based && eb) {
if(eb.exready[fun] && fun_lincat(g,conc,fun)) if(f.template) {
buttons.push(button("By example",by_example)) var byex=button("By example",by_example);
if(eb.testable[fun] && f.eb_lin) { if(!(eb.exready[fun] && fun_lincat(g,conc,fun)))
byex.disabled=true
buttons.push(byex)
}
else {
var b=button("Test it",test_it); var b=button("Test it",test_it);
if(!eb.testable[fun] || !f.eb_lin) b.disabled=true;
buttons.push(b) buttons.push(b)
} }
var exb_output=node("span",{"class":"exb_output"},[]); var exb_output=node("span",{"class":"exb_output"},[]);