From c1f70d9d0af05b67896caaaf6494c890af5eb806 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 26 Mar 2017 17:51:55 -0300 Subject: [PATCH] Add capslock support for inputs --- kfet/static/kfet/css/jconfirm-kfet.css | 7 +++- kfet/static/kfet/js/kfet.js | 52 +++++++++++++------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/kfet/static/kfet/css/jconfirm-kfet.css b/kfet/static/kfet/css/jconfirm-kfet.css index 0bd53ab7..6c27f77c 100644 --- a/kfet/static/kfet/css/jconfirm-kfet.css +++ b/kfet/static/kfet/css/jconfirm-kfet.css @@ -71,14 +71,19 @@ .jconfirm .capslock .glyphicon { position: absolute; + display:none; padding: 10px; right: 0px; top: 15px; font-size: 30px; - display: none ; margin-left: 60px !important; } +.capslock_on .capslock .glyphicon{ + display: inline-block !important; +} + + .jconfirm .capslock input { padding-right: 50px; padding-left: 50px; diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index c80e760a..ab3855a7 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -124,8 +124,33 @@ $(document).ready(function() { } }); } + }); +/* + * Capslock management + */ + +window.capslock = -1; +$(document).on('keypress', function(e) { + var s = String.fromCharCode(e.which); + if ((s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey)|| //caps on, shift off + (s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey)) { //caps on, shift on + $('body').addClass('capslock_on') + } else if ((s.toLowerCase() === s && s.toUpperCase() !== s && !e.shiftKey)|| //caps off, shift off + (s.toLowerCase() !== s && s.toUpperCase() === s && e.shiftKey)) { //caps off, shift on + $('body').removeClass('capslock_on') + } +}); + +$(document).on('keydown', function(e) { + if (e.which == 20) { + $('body').toggleClass('capslock_on') + } +}); + + + function dateUTCToParis(date) { return moment.tz(date, 'UTC').tz('Europe/Paris'); } @@ -287,30 +312,3 @@ function api_with_auth(settings, password) { window.lock = 0 ; }); } - -/* TODO: add capslock to all needed password inputs - * - var s = String.fromCharCode(e.which); - if ((s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey)|| //caps on, shift off - (s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey)) { //caps on, shift on - capslock = 1 ; - } else if ((s.toLowerCase() === s && s.toUpperCase() !== s && !e.shiftKey)|| //caps off, shift off - (s.toLowerCase() !== s && s.toUpperCase() === s && e.shiftKey)) { //caps off, shift on - capslock = 0 ; - } - if (capslock == 1) - $('.capslock .glyphicon').show() ; - else if (capslock == 0) - $('.capslock .glyphicon').hide() ; - }); - // Capslock key is not detected by keypress - this.$content.find('input').on('keydown', function(e) { - if (e.which == 20) { - capslock = 1-capslock ; - } - if (capslock == 1) - $('.capslock .glyphicon').show() ; - else if (capslock == 0) - $('.capslock .glyphicon').hide() ; - }); -*/