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() { function initHooks() {
if (initHooks.alreadyDone) { if (initHooks.alreadyDone) {
return; return;
@ -1332,14 +1342,7 @@ function initHooks() {
$('#keyMap-help').addEventListener('click', showKeyMapHelp, false); $('#keyMap-help').addEventListener('click', showKeyMapHelp, false);
$('#cancel-button').addEventListener('click', goBackToManage); $('#cancel-button').addEventListener('click', goBackToManage);
$('#options').open = prefs.get('editor.options.expanded'); setupOptionsExpand();
$('#options h2').addEventListener('click', () => {
setTimeout(() => prefs.set('editor.options.expanded', $('#options').open));
});
prefs.subscribe(['editor.options.expanded'], (key, value) => {
$('#options').open = value;
});
initLint(); initLint();
if (!FIREFOX) { if (!FIREFOX) {

View File

@ -1,6 +1,6 @@
/* global CodeMirror dirtyReporter initLint beautify showKeyMapHelp */ /* global CodeMirror dirtyReporter initLint beautify showKeyMapHelp */
/* global showToggleStyleHelp goBackToManage updateLintReportIfEnabled */ /* global showToggleStyleHelp goBackToManage updateLintReportIfEnabled */
/* global hotkeyRerouter setupAutocomplete */ /* global hotkeyRerouter setupAutocomplete setupOptionsExpand */
/* global editors */ /* global editors */
'use strict'; 'use strict';
@ -20,6 +20,8 @@ function createSourceEditor(style) {
]}) ]})
); );
setupOptionsExpand();
// draw CodeMirror // draw CodeMirror
$('#sections textarea').value = style.sourceCode; $('#sections textarea').value = style.sourceCode;
const cm = CodeMirror.fromTextArea($('#sections textarea')); const cm = CodeMirror.fromTextArea($('#sections textarea'));