From b69b8349498f217e0c6ea8a915ace36450b0ee22 Mon Sep 17 00:00:00 2001 From: eight Date: Wed, 4 Oct 2017 16:47:56 +0800 Subject: [PATCH] Fix: handle editor.options.expanded --- edit/edit.js | 19 +++++++++++-------- edit/source-editor.js | 4 +++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/edit/edit.js b/edit/edit.js index 5c044742..ebd2c0ac 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -1313,6 +1313,16 @@ function initWithSectionStyle({style, codeIsUpdated}) { } } +function setupOptionsExpand() { + $('#options').open = prefs.get('editor.options.expanded'); + $('#options h2').addEventListener('click', () => { + setTimeout(() => prefs.set('editor.options.expanded', $('#options').open)); + }); + prefs.subscribe(['editor.options.expanded'], (key, value) => { + $('#options').open = value; + }); +} + function initHooks() { if (initHooks.alreadyDone) { return; @@ -1332,14 +1342,7 @@ function initHooks() { $('#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)); - }); - prefs.subscribe(['editor.options.expanded'], (key, value) => { - $('#options').open = value; - }); - + setupOptionsExpand(); initLint(); if (!FIREFOX) { diff --git a/edit/source-editor.js b/edit/source-editor.js index 635038d3..7b4f5188 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -1,6 +1,6 @@ /* global CodeMirror dirtyReporter initLint beautify showKeyMapHelp */ /* global showToggleStyleHelp goBackToManage updateLintReportIfEnabled */ -/* global hotkeyRerouter setupAutocomplete */ +/* global hotkeyRerouter setupAutocomplete setupOptionsExpand */ /* global editors */ 'use strict'; @@ -20,6 +20,8 @@ function createSourceEditor(style) { ]}) ); + setupOptionsExpand(); + // draw CodeMirror $('#sections textarea').value = style.sourceCode; const cm = CodeMirror.fromTextArea($('#sections textarea'));