diff options
| author | hallgren <hallgren@chalmers.se> | 2011-11-21 15:24:29 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2011-11-21 15:24:29 +0000 |
| commit | d66110f84eec765bb26ebaa716bbce79d6c90913 (patch) | |
| tree | c8b07e3c7233bb6b340d348b34e1409325b0f213 /src/www/gfse/example_based.js | |
| parent | e9e029d39f5117f233823acc5a2e04f79827529e (diff) | |
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.
Diffstat (limited to 'src/www/gfse/example_based.js')
| -rw-r--r-- | src/www/gfse/example_based.js | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/www/gfse/example_based.js b/src/www/gfse/example_based.js index 966dcbecd..cd5d256b5 100644 --- a/src/www/gfse/example_based.js +++ b/src/www/gfse/example_based.js @@ -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"},[]); |
