Aggiunta informazione dei caratteri digitati per le textarea

This commit is contained in:
Luca 2021-03-25 19:25:30 +01:00
parent 47aad6e26c
commit f1215cf411
5 changed files with 29 additions and 3 deletions

View File

@ -103,8 +103,14 @@ Input.prototype.init = function () {
}
// Inizializzazione per textarea
else if (this.element.hasClass('autosize')) {
initCompleted = initTextareaInput(htmlElement);
else if (this.element.hasClass('autosize') || htmlElement.hasAttribute('maxlength')) {
if (this.element.hasClass('autosize'))
initCompleted = initTextareaInput(htmlElement);
if (htmlElement.hasAttribute('maxlength'))
initCompleted = initCharsCounter(htmlElement);
}
// Inizializzazione per select

View File

@ -26,6 +26,24 @@ function initTextareaInput(input) {
return true;
}
function initCharsCounter(input) {
let $input = $(input);
$input.maxlength({
warningClass: "label label-info",
limitReachedClass: "label label-warning",
preText: 'usati ',
separator: ' di ',
postText: ' caratteri.',
showMaxLength: false,
placement: 'bottom-right-inside',
utf8: true,
appendToParent: true
});
return true;
}
function waitCKEditor(input) {
setTimeout(function () {
initEditorInput(input);

View File

@ -115,6 +115,7 @@ const JS = gulp.parallel(() => {
'datatables.net-bs/js/dataTables.bootstrap.js',
'datatables.net-buttons-bs/js/buttons.bootstrap.js',
'smartwizard/dist/js/jquery.smartWizard.min.js',
'bootstrap-maxlength/dist/bootstrap-maxlength.js',
];
for (const i in vendor) {

View File

@ -672,7 +672,7 @@ if ($is_cliente or $is_fornitore or $is_tecnico) {
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$", "maxlength": 255 ]}
</div>
</div>

View File

@ -8,6 +8,7 @@
"bootstrap": "^3.3.7",
"bootstrap-colorpicker": "2.5.1",
"bootstrap-daterangepicker": "^2.1.25",
"bootstrap-maxlength": "1.10.0",
"chart.js": "^2.7.0",
"ckeditor4-dev": "^4.14.1",
"components-jqueryui": "^1.12.1",