From c7a0759216d29b99f898233f03251f3826d2bc35 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 29 Aug 2017 18:21:57 +0300 Subject: [PATCH] don't run CSS linters in the config dialog json --- edit/lint.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/edit/lint.js b/edit/lint.js index 9930cae5..9fc006df 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -415,6 +415,7 @@ function setupLinterSettingsEvents(popup) { } linterConfig.save(json); linterConfig.showSavedMessage(); + popup.codebox.markClean(); updateLinter(); } else { showLinterErrorMessage(linter, t('linterJSONError')); @@ -436,6 +437,7 @@ function setupLinterSettingsEvents(popup) { function setupLinterPopup(config) { const linter = prefs.get('editor.linter'); const linterTitle = linter === 'stylelint' ? 'Stylelint' : 'CSSLint'; + function makeButton(className, text, options = {}) { return $element(Object.assign(options, { tag: 'button', @@ -448,11 +450,9 @@ function setupLinterPopup(config) { function makeLink(url, textContent) { return $element({tag: 'a', target: '_blank', href: url, textContent}); } - function setJSONMode(cm) { - cm.setOption('mode', 'application/json'); - cm.setOption('lint', 'json'); - } - const popup = showCodeMirrorPopup(t('linterConfigPopupTitle', linterTitle), $element({ + + const title = t('linterConfigPopupTitle', linterTitle); + const contents = $element({ appendChild: [ $element({ tag: 'p', @@ -467,7 +467,7 @@ function setupLinterPopup(config) { linter === 'csslint' ? ' ' + t('linterCSSLintSettings') : '' ] }), - makeButton('save', 'styleSaveLabel'), + makeButton('save', 'styleSaveLabel', {disabled: true}), makeButton('cancel', 'confirmCancel'), makeButton('reset', 'genericResetLabel', {title: t('linterResetMessage')}), $element({ @@ -476,19 +476,25 @@ function setupLinterPopup(config) { textContent: t('genericSavedMessage') }) ] - })); - const contents = $('.contents', popup); - const loadJSON = window.jsonlint ? [] : [ - 'vendor/codemirror/mode/javascript/javascript.js', - 'vendor/codemirror/addon/lint/json-lint.js', - 'vendor/jsonlint/jsonlint.js' - ]; - contents.insertBefore(popup.codebox.display.wrapper, contents.firstElementChild); + }); + const popup = showCodeMirrorPopup(title, contents, {lint: false}); + contents.parentNode.appendChild(contents); popup.codebox.focus(); popup.codebox.setValue(config); popup.codebox.clearHistory(); - onDOMscripted(loadJSON).then(() => setJSONMode(popup.codebox)); + popup.codebox.markClean(); + popup.codebox.on('change', cm => { + $('.save', popup).disabled = cm.isClean(); + }); setupLinterSettingsEvents(popup); + onDOMscripted([ + 'vendor/codemirror/mode/javascript/javascript.js', + 'vendor/codemirror/addon/lint/json-lint.js', + 'vendor/jsonlint/jsonlint.js' + ]).then(() => { + popup.codebox.setOption('mode', 'application/json'); + popup.codebox.setOption('lint', 'json'); + }); } function loadLinterAssets(name = prefs.get('editor.linter')) {