theme buttons fix

This commit is contained in:
Evert Prants 2016-10-01 18:28:53 +03:00
parent d35c203974
commit f5e1f2a295
2 changed files with 39 additions and 24 deletions

View File

@ -959,23 +959,10 @@ class Buffer {
} }
} }
class Settings extends Buffer { class ThemeSelector {
constructor() { constructor(settings, variable) {
super("", "settings", "Settings", "applet"); this.settings = settings;
this.tab = null; this.variable = variable;
this.isOpen = false;
this.timeout = null;
this.themeSelection = "";
clientdom.settings.save.onclick = (e) => {
this.saveSpecified();
}
clientdom.settings.open.onclick = (e) => {
this.open();
}
this.theme_buttons();
} }
set_active_selection(name) { set_active_selection(name) {
@ -994,17 +981,45 @@ class Settings extends Buffer {
} }
} }
theme_buttons() { bindButton(button, theme) {
button.onclick = (e) => {
this.settings.themeSelection = theme;
this.set_active_selection(theme);
}
}
render() {
clientdom.settings.available_themes.innerHTML = "";
for(let n in window.themes.available) { for(let n in window.themes.available) {
let theme = window.themes.available[n]; let theme = window.themes.available[n];
let button = composer.theme_selection(n, theme); let button = composer.theme_selection(n, theme);
clientdom.settings.available_themes.appendChild(button); clientdom.settings.available_themes.appendChild(button);
button.onclick = (e) => { this.bindButton(button, n);
this.themeSelection = n; }
this.set_active_selection(this.themeSelection); }
} }
class Settings extends Buffer {
constructor() {
super("", "settings", "Settings", "applet");
this.tab = null;
this.isOpen = false;
this.timeout = null;
this.themeSelection = "";
this.themeSelector = new ThemeSelector(this);
this.themeSelector.render();
clientdom.settings.save.onclick = (e) => {
this.saveSpecified();
}
clientdom.settings.open.onclick = (e) => {
this.open();
} }
} }
@ -1012,7 +1027,7 @@ class Settings extends Buffer {
if(this.themeSelection != '') { if(this.themeSelection != '') {
window.themes.change_theme(this.themeSelection); window.themes.change_theme(this.themeSelection);
irc.config.theme = this.themeSelection; irc.config.theme = this.themeSelection;
this.set_active_selection(this.themeSelection); this.themeSelector.set_active_selection(this.themeSelection);
} }
} }

View File

@ -26,7 +26,7 @@ window.themes = {
nick_pallete: { nick_pallete: {
H: [1, 360], H: [1, 360],
S: [30, 100], S: [30, 100],
L: [40, 90] L: [50, 100]
}, },
stylesheet: "theme_night", stylesheet: "theme_night",
default: false, default: false,