Skip to content

Commit 56c31d5

Browse files
committed
refactor: #1610 Rimozione dipendenze js simili
1 parent 3dd0ca7 commit 56c31d5

7 files changed

Lines changed: 436 additions & 243 deletions

File tree

assets/src/js/base/custom.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,8 @@ $(document).ready(function () {
9393
});
9494
}, 1000);
9595

96-
// Plugin readmore.js
97-
$('.readmore').each( function(){
98-
height = $(this).data('height') ? parseInt($(this).data('height')) : 50;
99-
100-
$(this).readmore({
101-
collapsedHeight: height,
102-
moreLink: '<a href="#">' + globals.translations.readmore + '</a>',
103-
lessLink: '<a href="#">' + globals.translations.readless + '</a>',
104-
beforeToggle: function(){ setTimeout( 'alignMaxHeight(".module-header .card");', 300 ); },
105-
});
106-
});
96+
// Inizializza il text shortener (readmore.js)
97+
initTextShortener();
10798

10899
alignMaxHeight(".module-header .card");
109100

@@ -139,7 +130,7 @@ function sendWhatsAppMessage(phoneNumber, message) {
139130
function alignMaxHeight(element){
140131
// Azzera l'altezza fissa
141132
$(element).css('height', 'auto');
142-
133+
143134
max_height = 0;
144135
$(element).each( function(){
145136
if($(this).height() > max_height){
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Funzione per standardizzare l'accorciamento del testo
3+
* Utilizza readmore.js come libreria standard per tutto il progetto
4+
*/
5+
6+
/**
7+
* Inizializza readmore.js su elementi con classe .shorten
8+
* Mantiene la compatibilità con il vecchio sistema jquery.shorten
9+
*/
10+
function initTextShortener() {
11+
// Converti elementi che usano jquery.shorten a readmore.js
12+
$('.shorten').each(function() {
13+
// Ottieni eventuali opzioni personalizzate dall'elemento
14+
const showChars = $(this).data('show-chars') || 70;
15+
16+
// Inizializza readmore.js con opzioni compatibili
17+
$(this).readmore({
18+
collapsedHeight: 0, // Collassa completamente
19+
heightMargin: 0, // Nessun margine
20+
moreLink: '<a href="#">' + (globals.translations.readmore || 'Mostra tutto') + '</a>',
21+
lessLink: '<a href="#">' + (globals.translations.readless || 'Comprimi') + '</a>',
22+
beforeToggle: function(trigger, element, expanded) {
23+
// Compatibilità con jquery.shorten
24+
if (!expanded) {
25+
// Limita il testo visibile
26+
const text = $(element).text();
27+
if (text.length > showChars) {
28+
const visibleText = text.substr(0, showChars);
29+
const hiddenText = text.substr(showChars, text.length - showChars);
30+
31+
$(element).html(
32+
'<span class="shortcontent">' + visibleText + '...</span>' +
33+
'<span class="allcontent">' + text + '</span>'
34+
);
35+
36+
$(element).find('.allcontent').hide();
37+
}
38+
} else {
39+
// Mostra tutto il testo
40+
const originalText = $(element).find('.allcontent').text();
41+
if (originalText) {
42+
$(element).html(originalText);
43+
}
44+
}
45+
}
46+
});
47+
});
48+
49+
// Inizializza readmore.js su elementi con classe .readmore
50+
$('.readmore').each(function() {
51+
const height = $(this).data('height') ? parseInt($(this).data('height')) : 50;
52+
53+
$(this).readmore({
54+
collapsedHeight: height,
55+
moreLink: '<a href="#">' + (globals.translations.readmore || 'Leggi tutto') + '</a>',
56+
lessLink: '<a href="#">' + (globals.translations.readless || 'Chiudi') + '</a>',
57+
beforeToggle: function() {
58+
setTimeout('alignMaxHeight(".module-header .card");', 300);
59+
}
60+
});
61+
});
62+
}
63+
64+
// Inizializza quando il documento è pronto
65+
$(document).ready(function() {
66+
initTextShortener();
67+
});

gulpfile.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ const JS = gulp.parallel(() => {
107107
'inputmask/dist/min/jquery.inputmask.bundle.min.js',
108108
'jquery-form/src/jquery.form.js',
109109
'jquery-ui-touch-punch/jquery.ui.touch-punch.js',
110-
'jquery.shorten/src/jquery.shorten.js',
111110
'numeral/numeral.js',
112111
'parsleyjs/dist/parsley.js',
113112
'select2/dist/js/select2.min.js',
@@ -309,7 +308,7 @@ function wacom(){
309308
config.development + '/' + config.paths.js + '/wacom/common/libs/signature_sdk.wasm'
310309
])
311310
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/wacom/'));
312-
311+
313312
// Poi processiamo i file JS che lo utilizzano
314313
const jsStream = gulp.src(allFiles, {
315314
allowEmpty: true
@@ -358,7 +357,7 @@ function srcFonts() {
358357
}
359358

360359
function ckeditor() {
361-
360+
362361
const ckeditorCore = gulp.src([
363362
config.nodeDirectory + '/ckeditor4/{adapters,lang,skins,plugins,core}/**/*.{js,json,css,png,gif,html}',
364363
config.nodeDirectory + '/ckeditor4/*.{js,css}',
@@ -550,7 +549,7 @@ function release(done) {
550549

551550
// Aggiunta del file per il controllo di integrità del database
552551
var bufferStream = new Readable();
553-
552+
554553
bufferStream.push(shell.exec('php update/structure.php', {
555554
silent: true
556555
}).stdout);
@@ -573,7 +572,7 @@ function release(done) {
573572
bufferStream.push(null);
574573
archive.append(bufferStream, { name: 'REVISION' });
575574

576-
// Opzioni sulla release
575+
// Opzioni sulla release
577576
inquirer.prompt([{
578577
type: 'input',
579578
name: 'version',
@@ -588,23 +587,23 @@ function release(done) {
588587

589588
let version = result.version;
590589

591-
// Aggiungi 'beta' solo se l'opzione beta è selezionata
590+
// Aggiungi 'beta' solo se l'opzione beta è selezionata
592591
if (result.beta) {
593592
version += 'beta';
594593
}
595594

596-
// Creazione di un stream leggibile con la versione
595+
// Creazione di un stream leggibile con la versione
597596
const bufferStream = new Readable({
598597
read() {
599598
this.push(version);
600599
this.push(null);
601600
}
602601
});
603602

604-
// Aggiunta della versione corrente nel file VERSION
603+
// Aggiunta della versione corrente nel file VERSION
605604
archive.append(bufferStream, { name: 'VERSION' });
606605

607-
// Completamento dello ZIP
606+
// Completamento dello ZIP
608607
archive.finalize();
609608

610609
done();

0 commit comments

Comments
 (0)