diff --git a/src/www/minibar/minibar_input.js b/src/www/minibar/minibar_input.js index 7449cbbf7..af3d5054e 100644 --- a/src/www/minibar/minibar_input.js +++ b/src/www/minibar/minibar_input.js @@ -119,13 +119,19 @@ Input.prototype.get_completions=function() { } Input.prototype.show_completions=function(complete_output) { - with(this) { + var self=this; + function switch_input(lin) { + with(self) { + local.put("current",{from:lin.to,input:lin.text.split(" ")}) + from_menu.value=lin.to; + change_language() + } + } + with(self) { //debug("show_completions "); var completions=complete_output[0].completions; var emptycnt=add_completions(completions) - if(true/*emptycnt>0*/) - translations.translateFrom(current,startcat_menu.value); - else translations.clear(); + translations.translateFrom(current,startcat_menu.value,switch_input); if(surface.typed && emptycnt==completions.length) { if(surface.typed.value=="") remove_typed_input(); } diff --git a/src/www/minibar/minibar_translations.js b/src/www/minibar/minibar_translations.js index 612b5d2ea..167417844 100644 --- a/src/www/minibar/minibar_translations.js +++ b/src/www/minibar/minibar_translations.js @@ -42,9 +42,10 @@ Translations.prototype.clear=function() { this.main.innerHTML=""; } -Translations.prototype.translateFrom=function(current,startcat) { +Translations.prototype.translateFrom=function(current,startcat,lin_action) { this.current=current; this.startcat=startcat; + this.lin_action=lin_action; this.get_translations(); } @@ -59,18 +60,24 @@ Translations.prototype.get_translations=function() { } } -Translations.prototype.tdt=function(tree_btn,txt) { - with(this) { - return options.show_trees ? tda([tree_btn,txt]) : td(txt); - } -} - Translations.prototype.target_lang=function() { with(this) return langpart(to_menu.value,grammar.name); } Translations.prototype.show_translations=function(translationResults) { - with(this) { + var self=this; + function tdt(tree_btn,s,action) { + var txt=text(s); + if(action) { + txt=node("span",{onclick:action},[txt]) + //txt=button(s,action) + } + return self.options.show_trees ? tda([tree_btn,text(" "),txt]) : td(txt) + } + function act(lin) { + return self.lin_action ? function() { self.lin_action(lin) } : null + } + with(self) { var trans=main; //var to=target_lang(); // wrong var to=to_menu.value; @@ -96,16 +103,21 @@ Translations.prototype.show_translations=function(translationResults) { tr([th(text("Abstract: ")), tdt(node("span",{},[abstree_button(t.tree), alignment_button(t.tree)]), - text(" "+t.tree))])); + t.tree)])); for(var i=0;i