From f107cdd86d7148ffb6200e838210ecf24d744ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 20 Nov 2020 09:05:28 +0100 Subject: [PATCH] JS: Coding style improvements --- weblate/static/editor/full.js | 26 +++++++++-------- weblate/static/loader-codemirror.js | 44 ++++++++++++++++------------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/weblate/static/editor/full.js b/weblate/static/editor/full.js index 7e7bd2f93feb..0c72fad0d014 100644 --- a/weblate/static/editor/full.js +++ b/weblate/static/editor/full.js @@ -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; @@ -367,12 +368,13 @@ .find(".check-number") .html(' ' + key + ""); - 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(""); } diff --git a/weblate/static/loader-codemirror.js b/weblate/static/loader-codemirror.js index d7d3350068b4..17b8788a95c3 100644 --- a/weblate/static/loader-codemirror.js +++ b/weblate/static/loader-codemirror.js @@ -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;