From 3c244ff27f015df6cfa918c9ba3e192f4d5b62ff Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 4 Apr 2013 14:04:31 +0000 Subject: [PATCH] minibar/syntax editor integration improvements Work in progress on preserving the start category and selected target languages when switching between the minibar and the syntax editor. --- src/www/js/support.js | 26 ++++++++++++++++ src/www/minibar/minibar_input.js | 1 - src/www/minibar/minibar_online.js | 12 ++++++-- src/www/minibar/minibar_translations.js | 41 +++++++++---------------- src/www/syntax-editor/editor.html | 1 + src/www/syntax-editor/editor_menu.js | 7 +---- src/www/syntax-editor/editor_online.js | 5 ++- 7 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/www/js/support.js b/src/www/js/support.js index e8b7e7878..27207ac2e 100644 --- a/src/www/js/support.js +++ b/src/www/js/support.js @@ -259,6 +259,25 @@ function toggleHidden(el) { el.classList.add("hidden") } +// Update the selected options in a menu that allow multiple selections +function updateMultiMenu(menu,selection) { + var set=toSet(selection) + var os=menu.options + for(var i=0;i0) { t.toLangs=toLangs t.toSet=toSet(toLangs) - var os=to_menu.options - for(var i=0;i + diff --git a/src/www/syntax-editor/editor_menu.js b/src/www/syntax-editor/editor_menu.js index ea20710a4..33ce23ae4 100644 --- a/src/www/syntax-editor/editor_menu.js +++ b/src/www/syntax-editor/editor_menu.js @@ -77,12 +77,7 @@ function EditorMenu(editor,opts) { if (t.options.show_to_menu) { appendChildren(t.container, [text(" To: "), t.ui.to_toggle, t.ui.to_menu]); t.ui.to_menu.onchange = function(){ - var languages = new Array(); - for (i in t.ui.to_menu.options) { - var opt = t.ui.to_menu.options[i]; - if (opt.selected) - languages.push(opt.value); - } + var languages = multiMenuSelections(t.ui.to_menu) t.gm.change_languages(languages); } } diff --git a/src/www/syntax-editor/editor_online.js b/src/www/syntax-editor/editor_online.js index 913bec05a..dc2325737 100644 --- a/src/www/syntax-editor/editor_online.js +++ b/src/www/syntax-editor/editor_online.js @@ -35,8 +35,11 @@ if(window.Minibar) // Minibar loaded? initial_grammar: editor.menu.ui.grammar_menu.value, // hmm initial: { from: langFrom, - input: s.split(" ") // is it that easy? + input: s.split(" "), // is it that easy? + startcat: editor.menu.ui.startcat_menu.value // hmm }, + initial_toLangs: multiMenuSelections(editor.menu.ui.to_menu), // hmm + // get us back to the editor! abstract_action: function(tree) { var opts = {