1
0
forked from GitHub/gf-core

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"},
[hidden("dir",dir),hidden("command","make"),
hidden(g.basename+".gf",show_abstract(g))])
var files = [g.basename+".gf"]
//var files = [g.basename+".gf"]
for(var i in g.concretes) {
var cname=g.basename+g.concretes[i].langcode+".gf";
files.push(cname);
//files.push(cname);
form.appendChild(hidden(cname,
show_concrete(g.basename)(g.concretes[i])));
}

View File

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

View File

@@ -990,6 +990,7 @@ function inError(msg,el) {
function kw(txt) { return wrap_class("span","kw",text(txt)); }
function sep(txt) { return wrap_class("span","sep",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_sortable(cs,sort) {

View File

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