Skip to content

Commit 38cac02

Browse files
fix: focus editor after clearAll
1 parent 45898e1 commit 38cac02

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/common-function.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ requirejs.config({
1717
});
1818

1919
requirejs(['beautifier'],
20-
function(beautifier) {
20+
function (beautifier) {
2121
the.beautifier = beautifier;
2222
});
2323

@@ -43,10 +43,10 @@ function set_editor_mode() {
4343

4444
function run_tests() {
4545
$.when($.getScript("js/test/sanitytest.js"),
46-
$.getScript("js/test/generated/beautify-javascript-tests.js"),
47-
$.getScript("js/test/generated/beautify-css-tests.js"),
48-
$.getScript("js/test/generated/beautify-html-tests.js"))
49-
.done(function() {
46+
$.getScript("js/test/generated/beautify-javascript-tests.js"),
47+
$.getScript("js/test/generated/beautify-css-tests.js"),
48+
$.getScript("js/test/generated/beautify-html-tests.js"))
49+
.done(function () {
5050
var st = new SanityTest();
5151
run_javascript_tests(st, Urlencoded, the.beautifier.js, the.beautifier.html, the.beautifier.css);
5252
run_css_tests(st, Urlencoded, the.beautifier.js, the.beautifier.html, the.beautifier.css);
@@ -137,7 +137,7 @@ function unpacker_filter(source) {
137137
leading_comments += '\n';
138138
source = source.replace(/^\s+/, '');
139139

140-
var unpackers = [P_A_C_K_E_R, Urlencoded, JavascriptObfuscator /*, MyObfuscate*/ ];
140+
var unpackers = [P_A_C_K_E_R, Urlencoded, JavascriptObfuscator /*, MyObfuscate*/];
141141
for (var i = 0; i < unpackers.length; i++) {
142142
if (unpackers[i].detect(source)) {
143143
unpacked = unpackers[i].unpack(source);
@@ -380,8 +380,10 @@ function selectAll() {
380380
function clearAll() {
381381
if (the.editor) {
382382
the.editor.setValue('');
383+
the.editor.focus();
383384
} else {
384385
$('#source').val('');
386+
$('#source').focus();
385387
}
386388
}
387389

@@ -390,7 +392,7 @@ function changeToFileContent(input) {
390392
if (file) {
391393
var reader = new FileReader();
392394
reader.readAsText(file, "UTF-8");
393-
reader.onload = function(event) {
395+
reader.onload = function (event) {
394396
if (the.editor) {
395397
the.editor.setValue(event.target.result);
396398
} else {

0 commit comments

Comments
 (0)