From d3b7b45452e12d94034808db9769c75368b27825 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 1 Sep 2017 12:46:41 +0300 Subject: [PATCH] editor: toggle #options block upon clicking its title --- edit.html | 7 ++++--- edit/edit.css | 9 +++++++++ edit/edit.js | 7 ++++++- js/prefs.js | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/edit.html b/edit.html index b8d2b243..52a7d86e 100644 --- a/edit.html +++ b/edit.html @@ -144,8 +144,8 @@ -
-

+
+

@@ -195,7 +195,8 @@   -
+ +

:

diff --git a/edit/edit.css b/edit/edit.css index 877a45fd..27e78a88 100644 --- a/edit/edit.css +++ b/edit/edit.css @@ -118,6 +118,15 @@ h2 .svg-icon, label .svg-icon { margin-bottom: 0.5rem; } /* options */ +#options summary { + align-items: center; + margin-left: -13px; + cursor: pointer; + outline: none; +} +#options summary h2 { + display: inline-block; +} #options [type="number"] { max-width: 2.5rem; text-align: right; diff --git a/edit/edit.js b/edit/edit.js index 36451969..2e9e1430 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -1282,7 +1282,7 @@ function beautify(event) { } } -document.addEventListener('DOMContentLoaded', init); +onDOMready().then(init); function init() { initCodeMirror(); @@ -1395,6 +1395,11 @@ function initHooks() { $('#sections-help').addEventListener('click', showSectionHelp, false); $('#keyMap-help').addEventListener('click', showKeyMapHelp, false); $('#cancel-button').addEventListener('click', goBackToManage); + $('#options').open = prefs.get('editor.options.expanded'); + $('#options h2').addEventListener('click', () => { + setTimeout(() => prefs.set('editor.options.expanded', $('#options').open)); + }); + initLint(); if (!FIREFOX) { diff --git a/js/prefs.js b/js/prefs.js index 7567c787..e308bbfd 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -25,6 +25,7 @@ var prefs = new function Prefs() { 'manage.newUI.targets': 3, // max number of applies-to targets visible: 0 = none 'editor.options': {}, // CodeMirror.defaults.* + 'editor.options.expanded': true,// UI element state: expanded/collapsed 'editor.lineWrapping': true, // word wrap 'editor.smartIndent': true, // 'smart' indent 'editor.indentWithTabs': false, // smart indent with tabs