Add capslock support for inputs

This commit is contained in:
Ludovic Stephan 2017-03-26 17:51:55 -03:00
parent 6d92df4155
commit c1f70d9d0a
2 changed files with 31 additions and 28 deletions

View file

@ -71,14 +71,19 @@
.jconfirm .capslock .glyphicon { .jconfirm .capslock .glyphicon {
position: absolute; position: absolute;
display:none;
padding: 10px; padding: 10px;
right: 0px; right: 0px;
top: 15px; top: 15px;
font-size: 30px; font-size: 30px;
display: none ;
margin-left: 60px !important; margin-left: 60px !important;
} }
.capslock_on .capslock .glyphicon{
display: inline-block !important;
}
.jconfirm .capslock input { .jconfirm .capslock input {
padding-right: 50px; padding-right: 50px;
padding-left: 50px; padding-left: 50px;

View file

@ -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) { function dateUTCToParis(date) {
return moment.tz(date, 'UTC').tz('Europe/Paris'); return moment.tz(date, 'UTC').tz('Europe/Paris');
} }
@ -287,30 +312,3 @@ function api_with_auth(settings, password) {
window.lock = 0 ; 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() ;
});
*/