Fix: handle editor.options.expanded

This commit is contained in:
eight 2017-10-04 16:47:56 +08:00
parent bb508b6933
commit b69b834949
2 changed files with 14 additions and 9 deletions

View File

@ -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) {

View File

@ -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'));