Commit 72fe4442 authored by Adrian Wuillemet's avatar Adrian Wuillemet
Browse files

#65 Make language selection more intuitive

parent 927599cb
......@@ -54,8 +54,11 @@ class LanguageHelp extends ElementWrapper {
constructor(private container: HTMLElement) {
super(document.createElement('ul'));
let creator = (language: string) => this.create('li',
{"id": language, "content": language});
let creator = (language: string) => {
let option = this.create('li', {"id": language, "content": language});
option.addEventListener("click", () => BACKENDOPTIONS.setSelectedLanguage(language));
return option;
};
this.selection = new SelectionHandler(this.element, creator);
this.selection.appendSelf(this.container);
}
......
......@@ -38,7 +38,11 @@ class StringOption extends OPT<string> {
}
setContent(value: string): void {
if(this.content) {
this.element.removeChild(this.content);
}
this.content = this.create('input', {'type': 'text', "value": value});
this.element.insertBefore(this.content, this.element.firstChild);
}
}
......@@ -146,6 +150,14 @@ class BackendOptions extends ElementWrapper {
}
}
public setSelectedLanguage(language: string): void {
for (const option of this.options) {
if(option.title === 'language') {
option.setContent(language);
}
}
}
private setup(defaults: Defaults) {
Object.keys(defaults).forEach(key => {
let opt = defaults[key];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment