From 00604882446cb478de5c5b2bc280e9d96aed7860 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Mon, 4 Nov 2019 09:11:16 +0800 Subject: [PATCH] Change theme toggle to theme select dropdown menu Signed-off-by: Yukai Huang --- public/js/lib/editor/index.js | 25 ++++--------------------- public/js/lib/editor/statusbar.html | 11 +++++++++-- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/public/js/lib/editor/index.js b/public/js/lib/editor/index.js index d4c69b14..948d68ff 100644 --- a/public/js/lib/editor/index.js +++ b/public/js/lib/editor/index.js @@ -493,33 +493,16 @@ export default class Editor { this.editor.setOption('theme', cookieTheme) } - var themeToggle = this.statusTheme.find('.ui-theme-toggle') - - const checkTheme = () => { - var theme = this.editor.getOption('theme') - if (theme === 'one-dark') { - themeToggle.removeClass('active') - } else { - themeToggle.addClass('active') - } - } - - themeToggle.click(() => { - var theme = this.editor.getOption('theme') - if (theme === 'one-dark') { - theme = 'default' - } else { - theme = 'one-dark' - } + const setTheme = theme => { this.editor.setOption('theme', theme) Cookies.set('theme', theme, { expires: 365 }) + } - checkTheme() + this.statusIndicators.find('.status-theme li').click(function () { + setTheme($(this).attr('value')) }) - - checkTheme() } setSpellcheck () { diff --git a/public/js/lib/editor/statusbar.html b/public/js/lib/editor/statusbar.html index c4c796bc..f3423adf 100644 --- a/public/js/lib/editor/statusbar.html +++ b/public/js/lib/editor/statusbar.html @@ -31,8 +31,15 @@
4
-
- +