From d7f0e3c176ef2e91a4b01c4188ba265a73f515c4 Mon Sep 17 00:00:00 2001 From: eight Date: Wed, 13 Sep 2017 17:33:32 +0800 Subject: [PATCH] fixup! Fix: draw title --- edit/source-editor.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/edit/source-editor.js b/edit/source-editor.js index 55370998..25d81dfa 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -7,7 +7,6 @@ function createSourceEditor(style) { // draw HTML - document.title = t('editStyleTitle', [style.name]); $('#sections').innerHTML = ''; $('#name').disabled = true; $('#mozilla-format-heading').parentNode.remove(); @@ -28,9 +27,9 @@ function createSourceEditor(style) { const dirty = dirtyReporter(); dirty.onChange(() => { const DIRTY = dirty.isDirty(); - document.title = (DIRTY ? '* ' : '') + t('editStyleTitle', [style.name]); document.body.classList.toggle('dirty', DIRTY); $('#save-button').disabled = !DIRTY; + updateTitle(); }); // draw metas info @@ -259,6 +258,12 @@ function createSourceEditor(style) { CodeMirror.autoLoadMode(cm, style.preprocessor || 'css'); // beautify only works with regular CSS $('#beautify').disabled = Boolean(style.preprocessor); + updateTitle(); + } + + function updateTitle() { + // title depends on dirty and style meta + document.title = (dirty.isDirty() ? '* ' : '') + t('editStyleTitle', [style.name]); } function replaceStyle(newStyle) {