Skip to content

Commit

Permalink
JS: Coding style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Nov 20, 2020
1 parent 9a26161 commit f107cdd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
26 changes: 14 additions & 12 deletions weblate/static/editor/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
window.location = $("#button-end").attr("href");
return false;
});
Mousetrap.bindGlobal(["alt+pagedown", "mod+down", "alt+down"], function (
e
) {
window.location = $("#button-next").attr("href");
return false;
});
Mousetrap.bindGlobal(
["alt+pagedown", "mod+down", "alt+down"],
function (e) {
window.location = $("#button-next").attr("href");
return false;
}
);
Mousetrap.bindGlobal(["alt+pageup", "mod+up", "alt+up"], function (e) {
window.location = $("#button-prev").attr("href");
return false;
Expand Down Expand Up @@ -367,12 +368,13 @@
.find(".check-number")
.html(' <kbd title="' + title + '">' + key + "</kbd>");

Mousetrap.bindGlobal(["mod+i " + key, "mod+i mod+" + key], function (
e
) {
$this.find(".check-dismiss-single").click();
return false;
});
Mousetrap.bindGlobal(
["mod+i " + key, "mod+i mod+" + key],
function (e) {
$this.find(".check-dismiss-single").click();
return false;
}
);
} else {
$(this).find(".check-number").html("");
}
Expand Down
44 changes: 24 additions & 20 deletions weblate/static/loader-codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,33 @@
});
}

CodeMirror.registerHelper("hint", "userSuggestions", function (
editor,
callback
) {
var cur = editor.getCursor();
var curLine = editor.getLine(cur.line);
CodeMirror.registerHelper(
"hint",
"userSuggestions",
function (
editor,
callback
) {
var cur = editor.getCursor();
var curLine = editor.getLine(cur.line);

var end = cur.ch;
var start = curLine.lastIndexOf("@") + 1;
// Extract the current word from the current line using 'start' / 'end' value pair
var curWord = start !== end && curLine.slice(start, end);
var end = cur.ch;
var start = curLine.lastIndexOf("@") + 1;
// Extract the current word from the current line using 'start' / 'end' value pair
var curWord = start !== end && curLine.slice(start, end);

if (curWord && curWord.length > 2) {
// If there is current word set, We can filter out users from the
// main list and display them
getUserList(
curWord,
CodeMirror.Pos(cur.line, start),
CodeMirror.Pos(cur.line, end),
callback
);
if (curWord && curWord.length > 2) {
// If there is current word set, We can filter out users from the
// main list and display them
getUserList(
curWord,
CodeMirror.Pos(cur.line, start),
CodeMirror.Pos(cur.line, end),
callback
);
}
}
});
);

CodeMirror.hint.userSuggestions.async = true;

Expand Down

0 comments on commit f107cdd

Please sign in to comment.