commit
ff0e07d150
41
edit.js
41
edit.js
|
@ -828,7 +828,6 @@ function gotoLintIssue(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function beautify(event) {
|
function beautify(event) {
|
||||||
var undoCount = 1;
|
|
||||||
if (exports.css_beautify) { // thanks to csslint's definition of 'exports'
|
if (exports.css_beautify) { // thanks to csslint's definition of 'exports'
|
||||||
doBeautify();
|
doBeautify();
|
||||||
} else {
|
} else {
|
||||||
|
@ -844,15 +843,6 @@ function beautify(event) {
|
||||||
|
|
||||||
var section = querySelectorParent(event.target, "#sections > div");
|
var section = querySelectorParent(event.target, "#sections > div");
|
||||||
var scope = section ? [getCodeMirrorForSection(section)] : editors;
|
var scope = section ? [getCodeMirrorForSection(section)] : editors;
|
||||||
scope.forEach(function(cm) {
|
|
||||||
setTimeout(function() {
|
|
||||||
var text = cm.getValue();
|
|
||||||
var newText = exports.css_beautify(text, options);
|
|
||||||
if (newText != text) {
|
|
||||||
cm.setValue(newText);
|
|
||||||
}
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
showHelp(t("styleBeautify"), "<div class='beautify-options'>" +
|
showHelp(t("styleBeautify"), "<div class='beautify-options'>" +
|
||||||
optionHtml(".selector1,", "selector_separator_newline") +
|
optionHtml(".selector1,", "selector_separator_newline") +
|
||||||
|
@ -867,8 +857,31 @@ function beautify(event) {
|
||||||
var undoButton = document.querySelector("#help-popup button[role='undo']");
|
var undoButton = document.querySelector("#help-popup button[role='undo']");
|
||||||
undoButton.textContent = t(scope.length == 1 ? "undo" : "undoGlobal");
|
undoButton.textContent = t(scope.length == 1 ? "undo" : "undoGlobal");
|
||||||
undoButton.addEventListener("click", function() {
|
undoButton.addEventListener("click", function() {
|
||||||
scope.forEach(CodeMirror.commands.undo);
|
var undoable = false;
|
||||||
undoButton.disabled = --undoCount == 0;
|
scope.forEach(function(cm) {
|
||||||
|
if (cm.beautifyChange && cm.beautifyChange[cm.changeGeneration()]) {
|
||||||
|
delete cm.beautifyChange[cm.changeGeneration()];
|
||||||
|
cm.undo();
|
||||||
|
undoable |= cm.beautifyChange[cm.changeGeneration()];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
undoButton.disabled = !undoable;
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.forEach(function(cm) {
|
||||||
|
setTimeout(function() {
|
||||||
|
var text = cm.getValue();
|
||||||
|
var newText = exports.css_beautify(text, options);
|
||||||
|
if (newText != text) {
|
||||||
|
if (!cm.beautifyChange || !cm.beautifyChange[cm.changeGeneration()]) {
|
||||||
|
// clear the list if last change wasn't a css-beautify
|
||||||
|
cm.beautifyChange = {};
|
||||||
|
}
|
||||||
|
cm.setValue(newText);
|
||||||
|
cm.beautifyChange[cm.changeGeneration()] = true;
|
||||||
|
undoButton.disabled = false;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector(".beautify-options").addEventListener("change", function(event) {
|
document.querySelector(".beautify-options").addEventListener("change", function(event) {
|
||||||
|
@ -877,8 +890,6 @@ function beautify(event) {
|
||||||
prefs.setPref("editor.beautify", options);
|
prefs.setPref("editor.beautify", options);
|
||||||
event.target.parentNode.setAttribute("newline", value.toString());
|
event.target.parentNode.setAttribute("newline", value.toString());
|
||||||
doBeautify();
|
doBeautify();
|
||||||
undoCount++;
|
|
||||||
undoButton.disabled = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function optionHtml(label, optionName, indent) {
|
function optionHtml(label, optionName, indent) {
|
||||||
|
@ -1236,7 +1247,7 @@ function showLintHelp() {
|
||||||
showHelp(t("issues"), t("issuesHelp") + "<ul>" +
|
showHelp(t("issues"), t("issuesHelp") + "<ul>" +
|
||||||
CSSLint.getRules().map(function(rule) {
|
CSSLint.getRules().map(function(rule) {
|
||||||
return "<li><b>" + rule.name + "</b><br>" + rule.desc + "</li>";
|
return "<li><b>" + rule.name + "</b><br>" + rule.desc + "</li>";
|
||||||
}).join("") + "</ul"
|
}).join("") + "</ul>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user