From a984d1fd6f1579f28d5909b87b2df25c65e9b38e Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 26 Jul 2020 21:40:28 +0200 Subject: [PATCH] Clarity --- kfet/static/kfet/js/account.js | 9 +++++---- kfet/static/kfet/js/kfet.js | 2 +- kfet/static/kfet/js/kpsul.js | 7 +++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kfet/static/kfet/js/account.js b/kfet/static/kfet/js/account.js index ac98e1dd..a3f23e1c 100644 --- a/kfet/static/kfet/js/account.js +++ b/kfet/static/kfet/js/account.js @@ -17,7 +17,8 @@ var Account = Backbone.Model.extend({ }, reset: function () { - // On n'utilise pas .clear() car on ne veut pas clear le trigramme + // Réinitialise les attributs du modèle à leurs défaults, sauf le trigramme qui est bind à l'input. + // On n'utilise pas .clear() car on ne veut pas clear le trigramme. this.set(this.defaults) }, @@ -30,7 +31,7 @@ var Account = Backbone.Model.extend({ }, view: function () { - if (!this.is_valid()) { + if (!this.is_empty_account()) { view_class = EmptyAccountView } else if (this.get("trigramme") == 'LIQ') { view_class = LIQView @@ -44,7 +45,7 @@ var Account = Backbone.Model.extend({ this.view().render(); }, - is_valid: function () { + is_empty_account: function () { return (this.id != 0) }, }) @@ -132,7 +133,7 @@ var EmptyAccountView = AccountView.extend({ le compte est invalide */ buttons = ''; trigramme = this.model.get("trigramme") - if (trigramme.is_valid_tri()) { + if (trigramme.is_valid_trigramme()) { trigramme = encodeURIComponent(trigramme); var url_base = django_urls["kfet.account.create"](); var url = `${url_base}?trigramme=${trigramme}`; diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index 32493088..1ff3c583 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -6,7 +6,7 @@ String.prototype.format_trigramme = function () { return this.toUpperCase().substr(0, 3) } -String.prototype.is_valid_tri = function () { +String.prototype.is_valid_trigramme = function () { var pattern = /^[^a-z]{3}$/; return pattern.test(this); } diff --git a/kfet/static/kfet/js/kpsul.js b/kfet/static/kfet/js/kpsul.js index ae37939c..cb0b9fe8 100644 --- a/kfet/static/kfet/js/kpsul.js +++ b/kfet/static/kfet/js/kpsul.js @@ -27,8 +27,7 @@ class AccountManager { // Raccourci LIQ this._$input.on("keydown", function (e) { - // keycode 40: Down Arrow - if (e.keyCode == 40) { + if (e.key == "ArrowDown") { that.set("LIQ") } }) @@ -39,7 +38,7 @@ class AccountManager { }); this._$container.on('keydown', function (e) { - if (e.which == 70 && e.ctrlKey) { + if (e.key == "f" && e.ctrlKey) { // Ctrl + F : universal search shortcut that.search.open(); e.preventDefault(); @@ -55,7 +54,7 @@ class AccountManager { update() { var trigramme = this._$input.val().format_trigramme(); this.account.set({ "trigramme": trigramme }) - if (trigramme.is_valid_tri()) { + if (trigramme.is_valid_trigramme()) { this.account.fetch({ "success": this._on_success.bind(this), "error": this.reset.bind(this, false),