1 |
"use strict";
|
1 |
"use strict";
|
2 |
|
2 |
|
3 |
/*************************************
|
3 |
/*************************************
|
4 |
* Fonctions de Style et Affichage *
|
4 |
* Fonctions de Style et Affichage *
|
5 |
* des éléments "spéciaux" *
|
5 |
* des éléments "spéciaux" *
|
6 |
*************************************/
|
6 |
*************************************/
|
7 |
|
7 |
|
8 |
// Logique d'affichage pour le input type=file
|
8 |
// Logique d'affichage pour le input type=file
|
9 |
function inputFile() {
|
9 |
function inputFile() {
|
10 |
// Initialisation des variables
|
10 |
// Initialisation des variables
|
11 |
var $fileInput = $( '.input-file' ),
|
11 |
var $fileInput = $( '.input-file' ),
|
12 |
$button = $( '.label-file' ),
|
12 |
$button = $( '.label-file' ),
|
13 |
thisId = '';
|
13 |
thisId = '';
|
14 |
// Action lorsque la "barre d'espace" ou "Entrée" est pressée
|
14 |
// Action lorsque la "barre d'espace" ou "Entrée" est pressée
|
15 |
$( '.label-file' ).keydown( function( event ) {
|
15 |
$( '.label-file' ).keydown( function( event ) {
|
16 |
if ( event.keyCode == 13 || event.keyCode == 32 ) {
|
16 |
if ( event.keyCode == 13 || event.keyCode == 32 ) {
|
17 |
$( '#' + $( this ).attr( 'for' ) + '.input-file' ).focus();
|
17 |
$( '#' + $( this ).attr( 'for' ) + '.input-file' ).focus();
|
18 |
}
|
18 |
}
|
19 |
});
|
19 |
});
|
20 |
// Action lorsque le label est cliqué
|
20 |
// Action lorsque le label est cliqué
|
21 |
$( '.label-file' ).click( function(event) {
|
21 |
$( '.label-file' ).click( function(event) {
|
22 |
$( '#' + $( this ).attr( 'for' ) + '.input-file' ).focus();
|
22 |
$( '#' + $( this ).attr( 'for' ) + '.input-file' ).focus();
|
23 |
return false;
|
23 |
return false;
|
24 |
});
|
24 |
});
|
25 |
// Affiche un retour visuel dès que input:file change
|
25 |
// Affiche un retour visuel dès que input:file change
|
26 |
$fileInput.change( function( event ) {
|
26 |
$fileInput.change( function( event ) {
|
27 |
// Il est possible de supprimer un fichier
|
27 |
// Il est possible de supprimer un fichier
|
28 |
// donc on vérifie que le 'change' est un ajout ou modification
|
28 |
// donc on vérifie que le 'change' est un ajout ou modification
|
29 |
if( !$.isEmptyObject( event.target.files[0] ) ) {
|
29 |
if( !$.isEmptyObject( event.target.files[0] ) ) {
|
30 |
var file = event.target.files[0],
|
30 |
var file = event.target.files[0],
|
31 |
$theReturn = $( '.' + $( this ).attr( 'id' ) );
|
31 |
$theReturn = $( '.' + $( this ).attr( 'id' ) );
|
32 |
// Affichage du nom du fichier
|
32 |
// Affichage du nom du fichier
|
33 |
$theReturn.text( file.name );
|
33 |
$theReturn.text( file.name );
|
34 |
// Si le fichier est une image on l'affiche
|
34 |
// Si le fichier est une image on l'affiche
|
35 |
if( file.type.match( 'image' ) ) {
|
35 |
if( file.type.match( 'image' ) ) {
|
36 |
// Chemin temporaire de l'image et affichage
|
36 |
// Chemin temporaire de l'image et affichage
|
37 |
var tmppath = URL.createObjectURL( file );
|
37 |
var tmppath = URL.createObjectURL( file );
|
38 |
$theReturn.removeClass( 'hidden' ).append( '<img src="' + tmppath + '" width="50%">' );
|
38 |
$theReturn.removeClass( 'hidden' ).append( '<img src="' + tmppath + '" width="50%">' );
|
39 |
}
|
39 |
}
|
40 |
}
|
40 |
}
|
41 |
});
|
41 |
});
|
42 |
// Annuler le téléchargement
|
42 |
// Annuler le téléchargement
|
43 |
$( '.remove-file' ).click( function() {
|
43 |
$( '.remove-file' ).click( function() {
|
44 |
var $thisFileInput = $( this ).prev( '.input-file-container' ).find( '.input-file' );
|
44 |
var $thisFileInput = $( this ).prev( '.input-file-container' ).find( '.input-file' );
|
45 |
$thisFileInput.wrap( '<form>' ).closest( 'form' ).get(0).reset();
|
45 |
$thisFileInput.wrap( '<form>' ).closest( 'form' ).get(0).reset();
|
46 |
$thisFileInput.triggerHandler( 'change' );
|
46 |
$thisFileInput.triggerHandler( 'change' );
|
47 |
$thisFileInput.unwrap();
|
47 |
$thisFileInput.unwrap();
|
48 |
$( this ).next( '.file-return' ).addClass( 'hidden' ).empty();
|
48 |
$( this ).next( '.file-return' ).addClass( 'hidden' ).empty();
|
49 |
});
|
49 |
});
|
50 |
}
|
50 |
}
|
51 |
|
51 |
|
52 |
// Style et affichage des list-checkboxes
|
52 |
// Style et affichage des list-checkboxes
|
53 |
function inputListCheckbox() {
|
53 |
function inputListCheckbox() {
|
54 |
// On écoute le click sur une list-checkbox ('.selectBox')
|
54 |
// On écoute le click sur une list-checkbox ('.selectBox')
|
55 |
// à tout moment de son insertion dans le dom
|
55 |
// à tout moment de son insertion dans le dom
|
56 |
$('#zone-appli').on( 'click' , '.selectBox' , function() {
|
56 |
$('#zone-appli').on( 'click' , '.selectBox' , function() {
|
57 |
$( '.checkboxes[data-id="' + $(this).attr( 'data-id' ) + '"]' ).toggleClass( 'hidden' );
|
57 |
$( '.checkboxes[data-id="' + $(this).attr( 'data-id' ) + '"]' ).toggleClass( 'hidden' );
|
58 |
});
|
58 |
});
|
59 |
}
|
59 |
}
|
60 |
|
60 |
|
61 |
// Mettre la première lettre en majuscule, les autres en minuscule
|
61 |
// Mettre la première lettre en majuscule, les autres en minuscule
|
62 |
function capitalize( string ) {
|
62 |
function capitalize( string ) {
|
63 |
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
63 |
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
64 |
}
|
64 |
}
|
65 |
|
65 |
|
66 |
/***********************************************************
|
66 |
/***********************************************************
|
67 |
* Fonctions pour la création des champs supplémentaires *
|
67 |
* Fonctions pour la création des champs supplémentaires *
|
68 |
***********************************************************/
|
68 |
***********************************************************/
|
69 |
|
69 |
|
70 |
// Logique globale pour l'ajout de nouveaux champs
|
70 |
// Logique globale pour l'ajout de nouveaux champs
|
71 |
function onClickAddNewFields( fieldIndex ) {
|
71 |
function onClickAddNewFields( fieldIndex ) {
|
72 |
// Bouton ajouter un champ
|
72 |
// Bouton ajouter un champ
|
73 |
$( '#add-fields' ).click( function() {
|
73 |
$( '#add-fields' ).click( function() {
|
74 |
// Affichage du formulaire pour un champ
|
74 |
// Affichage du formulaire pour un champ
|
75 |
displayNewField( fieldIndex );
|
75 |
displayNewField( fieldIndex );
|
76 |
// Affichage du nom du champ
|
76 |
// Affichage du nom du champ
|
77 |
onChangeDisplayFieldLabel( fieldIndex );
|
77 |
onChangeDisplayFieldLabel( fieldIndex );
|
- |
|
78 |
// Empêcher de créer plus d'une fois la même clé
|
- |
|
79 |
onChangeCheckKeyUnique();
|
78 |
// Affichage des images/nom des documents importés dans les champs ajoutés
|
80 |
// Affichage des images/nom des documents importés dans les champs ajoutés
|
79 |
inputFile();
|
81 |
inputFile();
|
80 |
// Recueil des informations correspondantes au nouveau champ
|
82 |
// Recueil des informations correspondantes au nouveau champ
|
81 |
onChangeFieldTypeCollectDetails( fieldIndex );
|
83 |
onChangeFieldTypeCollectDetails( fieldIndex );
|
82 |
// Suppression d'un champ
|
84 |
// Suppression d'un champ
|
83 |
onClickRemoveField();
|
85 |
onClickRemoveField();
|
84 |
|
86 |
|
85 |
fieldIndex++;
|
87 |
fieldIndex++;
|
86 |
});
|
88 |
});
|
87 |
}
|
89 |
}
|
88 |
|
90 |
|
89 |
// Création/affichage du formulaire d'un nouveau champ
|
91 |
// Création/affichage du formulaire d'un nouveau champ
|
90 |
function displayNewField( fieldIndex ) {
|
92 |
function displayNewField( fieldIndex ) {
|
91 |
// Html du formulaire du nouveaux champs inséré dans le dom
|
93 |
// Html du formulaire du nouveaux champs inséré dans le dom
|
92 |
$( '#new-fields' ).append(
|
94 |
$( '#new-fields' ).append(
|
93 |
'<fieldset data-id="' + fieldIndex + '" class="new-field">'+
|
95 |
'<fieldset data-id="' + fieldIndex + '" class="new-field">'+
|
94 |
'<h3>Nouveau champ :<br><strong class="field-title" data-id="' + fieldIndex + '"></strong></h3>'+
|
96 |
'<h3>Nouveau champ :<br><strong class="field-title" data-id="' + fieldIndex + '"></strong></h3>'+
|
95 |
// Nom du champ
|
97 |
// Nom du champ
|
96 |
'<label for="field-name" title="Donnez un titre à votre champ">Nom du champ *</label>'+
|
98 |
'<label for="field-name" title="Donnez un titre à votre champ">Nom du champ *</label>'+
|
97 |
'<input type="text" name="field-name" data-id="' + fieldIndex + '" class="field-name" placeholder="Titre de votre champ" title="Donnez un titre à votre champ" required>'+
|
99 |
'<input type="text" name="field-name" data-id="' + fieldIndex + '" class="field-name" placeholder="Titre de votre champ" title="Donnez un titre à votre champ" required>'+
|
98 |
// Clé du champ
|
100 |
// Clé du champ
|
99 |
'<label for="field-key" title="Nom du champ dans la base de données">'+
|
101 |
'<label for="field-key" title="Nom du champ dans la base de données">'+
|
100 |
'Clé du champ en camelCase (ecritureChameau)<br>'+
|
102 |
'Clé du champ en camelCase (ecritureChameau)<br>'+
|
101 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i> '+
|
103 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i> '+
|
102 |
'Pas d\'accents ou de cédille, pas de caractères spéciaux. *'+
|
104 |
'Pas d\'accents ou de cédille, pas de caractères spéciaux. *'+
|
103 |
'</label>'+
|
105 |
'</label>'+
|
104 |
'<input type="text" name="field-key" data-id="' + fieldIndex + '" class="field-key" placeholder="Clé du champ" title="Nom du champ dans la base de données" required>'+
|
106 |
'<input type="text" name="field-key" data-id="' + fieldIndex + '" class="field-key" placeholder="Clé du champ" title="Nom du champ dans la base de données" required>'+
|
105 |
// Type de champ
|
107 |
// Type de champ
|
106 |
'<label for="field-element" title="Quel type de champ">Type de champ *</label>'+
|
108 |
'<label for="field-element" title="Quel type de champ">Type de champ *</label>'+
|
107 |
'<div class="select-wrapper add-field-select" data-id="' + fieldIndex + '">'+
|
109 |
'<div class="select-wrapper add-field-select" data-id="' + fieldIndex + '">'+
|
108 |
'<select name="field-element" data-id="' + fieldIndex + '" class="field-element">'+
|
110 |
'<select name="field-element" data-id="' + fieldIndex + '" class="field-element">'+
|
109 |
'<option value="text">Champ texte</option>'+
|
111 |
'<option value="text">Champ texte</option>'+
|
110 |
'<option value="email">Champ email</option>'+
|
112 |
'<option value="email">Champ email</option>'+
|
111 |
'<option value="textarea">Champ rédaction</option>'+
|
113 |
'<option value="textarea">Champ rédaction</option>'+
|
112 |
'<option value="select">Menu déroulant</option>'+
|
114 |
'<option value="select">Menu déroulant</option>'+
|
113 |
'<option value="checkbox">Cases à cocher</option>'+
|
115 |
'<option value="checkbox">Cases à cocher</option>'+
|
114 |
'<option value="list-checkbox">Liste de cases à cocher</option>'+
|
116 |
'<option value="list-checkbox">Liste de cases à cocher</option>'+
|
115 |
'<option value="radio">Boutons radio</option>'+
|
117 |
'<option value="radio">Boutons radio</option>'+
|
116 |
'<option value="date">Calendrier</option>'+
|
118 |
'<option value="date">Calendrier</option>'+
|
117 |
'<option value="file">Téléchargement</option>'+
|
119 |
'<option value="file">Téléchargement</option>'+
|
118 |
'<option value="range">Curseur (entre 2 bornes)</option>'+
|
120 |
'<option value="range">Curseur (entre 2 bornes)</option>'+
|
119 |
'<option value="number">Nombre</option>'+
|
121 |
'<option value="number">Nombre</option>'+
|
120 |
'</select>'+
|
122 |
'</select>'+
|
121 |
'</div>'+
|
123 |
'</div>'+
|
122 |
// Checkbox "champ requis"
|
124 |
// Checkbox "champ requis"
|
123 |
'<label for="field-is_mandatory" title="Ce champ est obligatoire">Champ requis ?</label>'+
|
125 |
'<label for="field-is_mandatory" title="Ce champ est obligatoire">Champ requis ?</label>'+
|
124 |
'<input type="checkbox" name="field-is_mandatory" data-id="' + fieldIndex + '" class="field-is_mandatory">'+
|
126 |
'<input type="checkbox" name="field-is_mandatory" data-id="' + fieldIndex + '" class="field-is_mandatory">'+
|
125 |
// Unité des valeurs
|
127 |
// Unité des valeurs
|
126 |
'<label for="field-unit" title="Unité de mesure de vos valeurs">Unités ( cm, kg, ha, etc.)</label>'+
|
128 |
'<label for="field-unit" title="Unité de mesure de vos valeurs">Unités ( cm, kg, ha, etc.)</label>'+
|
127 |
'<input type="text" name="field-unit" data-id="' + fieldIndex + '" class="field-unit" placeholder="symbole de vos unités">'+
|
129 |
'<input type="text" name="field-unit" data-id="' + fieldIndex + '" class="field-unit" placeholder="symbole de vos unités">'+
|
128 |
// Tooltip
|
130 |
// Tooltip
|
129 |
'<label for="field-description" title="Ajoutez une info-bulle">Info-bulle</label>'+
|
131 |
'<label for="field-description" title="Ajoutez une info-bulle">Info-bulle</label>'+
|
130 |
'<input type="text" name="field-description" data-id="' + fieldIndex + '" class="field-description" placeholder="Quelques mots">'+
|
132 |
'<input type="text" name="field-description" data-id="' + fieldIndex + '" class="field-description" placeholder="Quelques mots">'+
|
131 |
// Import d'une image ou d'un pdf d'aide à afficher en popup
|
133 |
// Import d'une image ou d'un pdf d'aide à afficher en popup
|
132 |
'<div class="input-file-container">'+
|
134 |
'<div class="input-file-container">'+
|
133 |
'<input type="file" class="input-file field-help" name="field-help" data-id="' + fieldIndex + '" id="help-doc-' + fieldIndex + '" accept="application/pdf, image/*, video/*">'+
|
135 |
'<input type="file" class="input-file field-help" name="field-help" data-id="' + fieldIndex + '" id="help-doc-' + fieldIndex + '" accept="application/pdf, image/*, video/*">'+
|
134 |
'<label for="field-help" class="label-file"><i class="fas fa-download"></i> Popup aide image/pdf</label>'+
|
136 |
'<label for="field-help" class="label-file"><i class="fas fa-download"></i> Popup aide image/pdf</label>'+
|
135 |
'</div>'+
|
137 |
'</div>'+
|
136 |
'<div class="remove-file button" name="remove-file" data-id="' + fieldIndex + '" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>'+
|
138 |
'<div class="remove-file button" name="remove-file" data-id="' + fieldIndex + '" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>'+
|
137 |
'<div class="file-return help-doc-' + fieldIndex + ' hidden"></div>'+
|
139 |
'<div class="file-return help-doc-' + fieldIndex + ' hidden"></div>'+
|
138 |
// Boutons supprimer
|
140 |
// Boutons supprimer
|
139 |
'<label for="remove-field">Supprimer</label>'+
|
141 |
'<label for="remove-field">Supprimer</label>'+
|
140 |
'<div class="remove-field button" name="remove-field" data-id="' + fieldIndex + '" title="Supprimer un champ"><i class="fa fa-skull" aria-hidden="true"></i></div>'+
|
142 |
'<div class="remove-field button" name="remove-field" data-id="' + fieldIndex + '" title="Supprimer un champ"><i class="fa fa-skull" aria-hidden="true"></i></div>'+
|
141 |
'</fieldset>'
|
143 |
'</fieldset>'
|
142 |
);
|
144 |
);
|
143 |
// Animation de l'affichage
|
145 |
// Animation de l'affichage
|
144 |
$( 'fieldset.new-field[data-id="' + fieldIndex + '"]').hide().show( 200 );
|
146 |
$( 'fieldset.new-field[data-id="' + fieldIndex + '"]').hide().show( 200 );
|
145 |
}
|
147 |
}
|
146 |
|
148 |
|
147 |
// Affichage du nom du champ dès qu'il est renseigné
|
149 |
// Affichage du nom du champ dès qu'il est renseigné
|
148 |
function onChangeDisplayFieldLabel( fieldIndex ) {
|
150 |
function onChangeDisplayFieldLabel( fieldIndex ) {
|
149 |
$('.field-name[data-id="' + fieldIndex + '"]').change( function() {
|
151 |
$('.field-name[data-id="' + fieldIndex + '"]').change( function() {
|
150 |
$( '.field-title[data-id="' + fieldIndex + '"]' ).text( $( this ).val() );
|
152 |
$( '.field-title[data-id="' + fieldIndex + '"]' ).text( $( this ).val() );
|
151 |
});
|
153 |
});
|
152 |
}
|
154 |
}
|
153 |
|
155 |
|
154 |
// Supprimer un nouveau champ
|
156 |
// Supprimer un nouveau champ
|
155 |
function onClickRemoveField ( keyFlag , nameFlag ) {
|
157 |
function onClickRemoveField ( keyFlag , nameFlag ) {
|
156 |
$( '.remove-field' ).click( function() {
|
158 |
$( '.remove-field' ).click( function() {
|
157 |
$(this).closest('fieldset').hide( 200 , function () {
|
159 |
$(this).closest('fieldset').hide( 200 , function () {
|
158 |
$(this).remove();
|
160 |
$(this).remove();
|
159 |
});
|
161 |
});
|
160 |
});
|
162 |
});
|
161 |
}
|
163 |
}
|
162 |
|
164 |
|
163 |
|
165 |
|
164 |
/**** Recueil des informations et détails qui dépendent du type de champ choisi ****/
|
166 |
/**** Recueil des informations et détails qui dépendent du type de champ choisi ****/
|
165 |
|
167 |
|
166 |
// Logique de recueil d'informations en fonction du type de champ choisi
|
168 |
// Logique de recueil d'informations en fonction du type de champ choisi
|
167 |
function onChangeFieldTypeCollectDetails( fieldIndex ) {
|
169 |
function onChangeFieldTypeCollectDetails( fieldIndex ) {
|
168 |
// On insère les champs par défaut de recueil d'informations
|
170 |
// On insère les champs par défaut de recueil d'informations
|
169 |
displayFieldDetailsCollect(
|
171 |
displayFieldDetailsCollect(
|
170 |
fieldIndex,
|
172 |
fieldIndex,
|
171 |
// Placeholder (champ type text par défaut)
|
173 |
// Placeholder (champ type text par défaut)
|
172 |
'<label for="aide-saisie" title="Aidez les utilisateurs en deux ou 3 mots ou chiffres à comprendre ce que doit contenir le champ">Texte d\'aide à la saisie</label>'+
|
174 |
'<label for="aide-saisie" title="Aidez les utilisateurs en deux ou 3 mots ou chiffres à comprendre ce que doit contenir le champ">Texte d\'aide à la saisie</label>'+
|
173 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'
|
175 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'
|
174 |
);
|
176 |
);
|
175 |
// Sinon :
|
177 |
// Sinon :
|
176 |
$( '.field-element[data-id="' + fieldIndex + '"]' ).change( function() {
|
178 |
$( '.field-element[data-id="' + fieldIndex + '"]' ).change( function() {
|
177 |
// On intialise l'index pour les listes la variable qui contiendra un id pour chaque option
|
179 |
// On intialise l'index pour les listes la variable qui contiendra un id pour chaque option
|
178 |
var valueIndex = 0;
|
180 |
var valueIndex = 0;
|
179 |
// Si on hésite on qu'on se trompe dans la liste :
|
181 |
// Si on hésite on qu'on se trompe dans la liste :
|
180 |
// les champs de détails de l'option précédente doivent être supprimés
|
182 |
// les champs de détails de l'option précédente doivent être supprimés
|
181 |
$( '.field-details[data-id="' + fieldIndex + '"]' ).hide( 200 , function () {
|
183 |
$( '.field-details[data-id="' + fieldIndex + '"]' ).hide( 200 , function () {
|
182 |
$(this).remove();
|
184 |
$(this).remove();
|
183 |
});
|
185 |
});
|
184 |
|
186 |
|
185 |
// Html de recueil de données en fonction de l'élément choisi
|
187 |
// Html de recueil de données en fonction de l'élément choisi
|
186 |
switch( $( this ).val() ) {
|
188 |
switch( $( this ).val() ) {
|
187 |
case 'file':
|
189 |
case 'file':
|
188 |
break;
|
190 |
break;
|
189 |
|
191 |
|
190 |
case 'number':
|
192 |
case 'number':
|
191 |
case 'range':
|
193 |
case 'range':
|
192 |
displayFieldDetailsCollect(
|
194 |
displayFieldDetailsCollect(
|
193 |
fieldIndex,
|
195 |
fieldIndex,
|
194 |
'<p class="message"><i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i> Ne pas oublier de changer, si nécessaire, les valeurs step, min et max</p>' +
|
196 |
'<p class="message"><i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i> Ne pas oublier de changer, si nécessaire, les valeurs step, min et max</p>' +
|
195 |
// Placeholder
|
197 |
// Placeholder
|
196 |
'<label for="aide-saisie" title="Deux ou 3 mots ou chiffres pour comprendre ce que doit contenir le champ (ex: min 20, 10 par 10, etc.)">Texte d\'aide à la saisie</label>'+
|
198 |
'<label for="aide-saisie" title="Deux ou 3 mots ou chiffres pour comprendre ce que doit contenir le champ (ex: min 20, 10 par 10, etc.)">Texte d\'aide à la saisie</label>'+
|
197 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'+
|
199 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'+
|
198 |
// Valeur par défaut
|
200 |
// Valeur par défaut
|
199 |
'<label for="default" title="Valeur par défaut">Valeur par défaut</label>'+
|
201 |
'<label for="default" title="Valeur par défaut">Valeur par défaut</label>'+
|
200 |
'<input type="number" name="default" data-id="' + fieldIndex + '" class="default" step="0.01">'+
|
202 |
'<input type="number" name="default" data-id="' + fieldIndex + '" class="default" step="0.01">'+
|
201 |
// Incrémentation ( attribut step="" )
|
203 |
// Incrémentation ( attribut step="" )
|
202 |
'<label for="step" title="De 10 en 10, de 0.5 en 0.5, etc.">Incrémentation (step) :<br>defaut = +1</label>'+
|
204 |
'<label for="step" title="De 10 en 10, de 0.5 en 0.5, etc.">Incrémentation (step) :<br>defaut = +1</label>'+
|
203 |
'<input type="number" name="step" data-id="' + fieldIndex + '" class="step" step="0.01" value="1">'+
|
205 |
'<input type="number" name="step" data-id="' + fieldIndex + '" class="step" step="0.01" value="1">'+
|
204 |
// Min
|
206 |
// Min
|
205 |
'<label for="min" title="valeur min">Valeur minimale</label>'+
|
207 |
'<label for="min" title="valeur min">Valeur minimale</label>'+
|
206 |
'<input type="number" name="min" data-id="' + fieldIndex + '" class="min" step="0.01" value="0">'+
|
208 |
'<input type="number" name="min" data-id="' + fieldIndex + '" class="min" step="0.01" value="0">'+
|
207 |
// Max
|
209 |
// Max
|
208 |
'<label for="max" title="valeur max">Valeur maximale</label>'+
|
210 |
'<label for="max" title="valeur max">Valeur maximale</label>'+
|
209 |
'<input type="number" name="max" data-id="' + fieldIndex + '" class="max" step="0.01" value="1">'
|
211 |
'<input type="number" name="max" data-id="' + fieldIndex + '" class="max" step="0.01" value="1">'
|
210 |
);
|
212 |
);
|
211 |
break;
|
213 |
break;
|
212 |
|
214 |
|
213 |
case 'date':
|
215 |
case 'date':
|
214 |
displayFieldDetailsCollect(
|
216 |
displayFieldDetailsCollect(
|
215 |
fieldIndex,
|
217 |
fieldIndex,
|
216 |
// Date min
|
218 |
// Date min
|
217 |
'<label for="min" title="date min">Date minimale</label>'+
|
219 |
'<label for="min" title="date min">Date minimale</label>'+
|
218 |
'<input type="date" name="min" data-id="' + fieldIndex + '" class="min">'+
|
220 |
'<input type="date" name="min" data-id="' + fieldIndex + '" class="min">'+
|
219 |
// Date max
|
221 |
// Date max
|
220 |
'<label for="max" title="date max">Date maximale</label>'+
|
222 |
'<label for="max" title="date max">Date maximale</label>'+
|
221 |
'<input type="date" name="max" data-id="' + fieldIndex + '" class="max">'
|
223 |
'<input type="date" name="max" data-id="' + fieldIndex + '" class="max">'
|
222 |
);
|
224 |
);
|
223 |
break;
|
225 |
break;
|
224 |
|
226 |
|
225 |
case 'select':
|
227 |
case 'select':
|
226 |
case 'checkbox':
|
228 |
case 'checkbox':
|
227 |
case 'list-checkbox':
|
229 |
case 'list-checkbox':
|
228 |
case 'radio':
|
230 |
case 'radio':
|
229 |
displayFieldDetailsCollect(
|
231 |
displayFieldDetailsCollect(
|
230 |
fieldIndex,
|
232 |
fieldIndex,
|
231 |
'<p class="message">Ajoutez les valeurs de \"' + $( this ).children( 'option:selected' ).text() + '\"</p>'+
|
233 |
'<p class="message">Ajoutez les valeurs de \"' + $( this ).children( 'option:selected' ).text() + '\"</p>'+
|
232 |
// Bouton ajout d'une valeur à la liste
|
234 |
// Bouton ajout d'une valeur à la liste
|
233 |
'<label for="add-value" class="add-value" data-id="' + fieldIndex + '" title="Ajouter une valeur à la liste">Ajouter une valeur</label>'+
|
235 |
'<label for="add-value" class="add-value" data-id="' + fieldIndex + '" title="Ajouter une valeur à la liste">Ajouter une valeur</label>'+
|
234 |
'<div class="button add-value-button" name="add-value" data-id="' + fieldIndex + '" title="Ajouter une valeur à la liste"><i class="fa fa-puzzle-piece" aria-hidden="true"></i></div>'+
|
236 |
'<div class="button add-value-button" name="add-value" data-id="' + fieldIndex + '" title="Ajouter une valeur à la liste"><i class="fa fa-puzzle-piece" aria-hidden="true"></i></div>'+
|
235 |
// checkbox ajouter une valeur "Autre:"
|
237 |
// checkbox ajouter une valeur "Autre:"
|
236 |
'<label for="option-other-value" title="Ajouter une option \'Autre:\' à la fin">Valeur "Autre"</label>'+
|
238 |
'<label for="option-other-value" title="Ajouter une option \'Autre:\' à la fin">Valeur "Autre"</label>'+
|
237 |
'<input type="checkbox" name="option-other-value" data-id="' + fieldIndex + '" class="option-other-value" title="Ajouter une option \'Autre\' à la fin">'
|
239 |
'<input type="checkbox" name="option-other-value" data-id="' + fieldIndex + '" class="option-other-value" title="Ajouter une option \'Autre\' à la fin">'
|
238 |
);
|
240 |
);
|
239 |
break;
|
241 |
break;
|
240 |
|
242 |
|
241 |
case 'email':
|
243 |
case 'email':
|
242 |
case 'text':
|
244 |
case 'text':
|
243 |
case 'textarea':
|
245 |
case 'textarea':
|
244 |
default:
|
246 |
default:
|
245 |
displayFieldDetailsCollect(
|
247 |
displayFieldDetailsCollect(
|
246 |
fieldIndex,
|
248 |
fieldIndex,
|
247 |
// Placeholder
|
249 |
// Placeholder
|
248 |
'<label for="aide-saisie" title="Aidez les utilisateurs en deux ou 3 mots ou chiffres à comprendre ce que doit contenir le champ">Texte d\'aide à la saisie</label>'+
|
250 |
'<label for="aide-saisie" title="Aidez les utilisateurs en deux ou 3 mots ou chiffres à comprendre ce que doit contenir le champ">Texte d\'aide à la saisie</label>'+
|
249 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'
|
251 |
'<input type="text" name="aide-saisie" data-id="' + fieldIndex + '" class="aide-saisie" placeholder="Ce que doit contenir le champ">'
|
250 |
);
|
252 |
);
|
251 |
break;
|
253 |
break;
|
252 |
}
|
254 |
}
|
253 |
// Ajout des valeurs possibles
|
255 |
// Ajout des valeurs possibles
|
254 |
// lorsque le champ est une liste ou case à cocher
|
256 |
// lorsque le champ est une liste ou case à cocher
|
255 |
onClickAddNewValueToList( fieldIndex , valueIndex );
|
257 |
onClickAddNewValueToList( fieldIndex , valueIndex );
|
256 |
});
|
258 |
});
|
257 |
}
|
259 |
}
|
258 |
|
260 |
|
259 |
// Insertion dans le dom des champs de recueil d'informations
|
261 |
// Insertion dans le dom des champs de recueil d'informations
|
260 |
function displayFieldDetailsCollect( fieldIndex , fieldDetails ) {
|
262 |
function displayFieldDetailsCollect( fieldIndex , fieldDetails ) {
|
261 |
$( '.add-field-select[data-id="' + fieldIndex + '"]' ).after(
|
263 |
$( '.add-field-select[data-id="' + fieldIndex + '"]' ).after(
|
262 |
'<div class="field-details" data-id="' + fieldIndex + '">' +
|
264 |
'<div class="field-details" data-id="' + fieldIndex + '">' +
|
263 |
fieldDetails +
|
265 |
fieldDetails +
|
264 |
'</div>'
|
266 |
'</div>'
|
265 |
).hide().show( 200);
|
267 |
).hide().show( 200);
|
266 |
}
|
268 |
}
|
267 |
|
269 |
|
268 |
/**** Ajout des valeurs (options) des "champs de listes" (select, checkbox, radio, etc.) ****/
|
270 |
/**** Ajout des valeurs (options) des "champs de listes" (select, checkbox, radio, etc.) ****/
|
269 |
|
271 |
|
270 |
// Ajout des options des listes (deroulantes, cases à cocher etc.)
|
272 |
// Ajout des options des listes (deroulantes, cases à cocher etc.)
|
271 |
function onClickAddNewValueToList( fieldIndex , valueIndex ) {
|
273 |
function onClickAddNewValueToList( fieldIndex , valueIndex ) {
|
272 |
$( '.add-value-button[data-id="' + fieldIndex + '"]' ).click( function() {
|
274 |
$( '.add-value-button[data-id="' + fieldIndex + '"]' ).click( function() {
|
273 |
$( '.add-value[data-id="' + fieldIndex + '"]' ).before(
|
275 |
$( '.add-value[data-id="' + fieldIndex + '"]' ).before(
|
274 |
'<div class="new-value" data-list-value-id="' + valueIndex +'">'+
|
276 |
'<div class="new-value" data-list-value-id="' + valueIndex +'">'+
|
275 |
// Recueil d'une valeur de la liste
|
277 |
// Recueil d'une valeur de la liste
|
276 |
'<label for="list-value">Valeur *:</label>'+
|
278 |
'<label for="list-value">Valeur *:</label>'+
|
277 |
'<input type="text" name="list-value" data-id="' + fieldIndex + '" class="list-value" data-list-value-id="' + valueIndex +'" placeholder="Une des valeurs de la liste" required>'+
|
279 |
'<input type="text" name="list-value" data-id="' + fieldIndex + '" class="list-value" data-list-value-id="' + valueIndex +'" placeholder="Une des valeurs de la liste" required>'+
|
278 |
// Checkbox valeur par défaut+bouton supprimer
|
280 |
// Checkbox valeur par défaut+bouton supprimer
|
279 |
'<div class="row">'+
|
281 |
'<div class="row">'+
|
280 |
'<div class="col-md-5">'+
|
282 |
'<div class="col-md-5">'+
|
281 |
// Valeur par défaut
|
283 |
// Valeur par défaut
|
282 |
'<label for="is-defaut-value" title="Ceci est la valeur par défaut">Valeur par défaut</label>'+
|
284 |
'<label for="is-defaut-value" title="Ceci est la valeur par défaut">Valeur par défaut</label>'+
|
283 |
'<input type="checkbox" name="is-defaut-value" data-id="' + fieldIndex + '" class="is-defaut-value" title="entrez une valeur pour activer cette case" data-list-value-id="' + valueIndex +'" disabled >'+
|
285 |
'<input type="checkbox" name="is-defaut-value" data-id="' + fieldIndex + '" class="is-defaut-value" title="entrez une valeur pour activer cette case" data-list-value-id="' + valueIndex +'" disabled >'+
|
284 |
'</div>'+
|
286 |
'</div>'+
|
285 |
'<div class="col-md-5">'+
|
287 |
'<div class="col-md-5">'+
|
286 |
// Bouton supprimer une option
|
288 |
// Bouton supprimer une option
|
287 |
'<label for="remove-value">supprimer valeur</label>'+
|
289 |
'<label for="remove-value">supprimer valeur</label>'+
|
288 |
'<div class="remove-value button" name="remove-value" data-id="' + fieldIndex + '" data-list-value-id="' + valueIndex + '" title="Supprimer une valeur"><i class="fa fa-trash" aria-hidden="true"></i></div>'+
|
290 |
'<div class="remove-value button" name="remove-value" data-id="' + fieldIndex + '" data-list-value-id="' + valueIndex + '" title="Supprimer une valeur"><i class="fa fa-trash" aria-hidden="true"></i></div>'+
|
289 |
'</div>'+
|
291 |
'</div>'+
|
290 |
'</div>'+
|
292 |
'</div>'+
|
291 |
'</div>'
|
293 |
'</div>'
|
292 |
).hide().show( 200);
|
294 |
).hide().show( 200);
|
293 |
// Activer la checkbox de valeur par default uniquement si une valeur est entrée
|
295 |
// Activer la checkbox de valeur par default uniquement si une valeur est entrée
|
294 |
onInputListValueLabelEnableDefaultCheckbox( valueIndex );
|
296 |
onInputListValueLabelEnableDefaultCheckbox( valueIndex );
|
295 |
// Une seule valeur par défaut pour select et radio
|
297 |
// Une seule valeur par défaut pour select et radio
|
296 |
onClickDefaultValueRemoveOthers( fieldIndex );
|
298 |
onClickDefaultValueRemoveOthers( fieldIndex );
|
297 |
// Supprimer une valeur
|
299 |
// Supprimer une valeur
|
298 |
onClickRemoveListValue( fieldIndex );
|
300 |
onClickRemoveListValue( fieldIndex );
|
299 |
|
301 |
|
300 |
valueIndex++;
|
302 |
valueIndex++;
|
301 |
});
|
303 |
});
|
302 |
}
|
304 |
}
|
303 |
|
305 |
|
304 |
// Activer la checkbox de valeur par default uniquement si une valeur est entrée
|
306 |
// Activer la checkbox de valeur par default uniquement si une valeur est entrée
|
305 |
function onInputListValueLabelEnableDefaultCheckbox( valueIndex ) {
|
307 |
function onInputListValueLabelEnableDefaultCheckbox( valueIndex ) {
|
306 |
$( '.new-value[data-list-value-id="' + valueIndex + '"] .list-value' ).on( 'input' , function() {
|
308 |
$( '.new-value[data-list-value-id="' + valueIndex + '"] .list-value' ).on( 'input' , function() {
|
307 |
if( $(this).val() !== '' ) {
|
309 |
if( $(this).val() !== '' ) {
|
308 |
$( '.is-defaut-value[data-list-value-id="' + valueIndex + '"]' ).removeAttr( 'disabled');
|
310 |
$( '.is-defaut-value[data-list-value-id="' + valueIndex + '"]' ).removeAttr( 'disabled');
|
309 |
} else {
|
311 |
} else {
|
310 |
$( '.is-defaut-value[data-list-value-id="' + valueIndex + '"]' ).attr( 'disabled', true ).removeAttr( 'checked' );
|
312 |
$( '.is-defaut-value[data-list-value-id="' + valueIndex + '"]' ).attr( 'disabled', true ).removeAttr( 'checked' );
|
311 |
}
|
313 |
}
|
312 |
});
|
314 |
});
|
313 |
}
|
315 |
}
|
314 |
|
316 |
|
315 |
// Pour les éléments "select" et "radio" il ne peut y avoir qu'une valeur par défaut cochée
|
317 |
// Pour les éléments "select" et "radio" il ne peut y avoir qu'une valeur par défaut cochée
|
316 |
function onClickDefaultValueRemoveOthers( fieldIndex ) {
|
318 |
function onClickDefaultValueRemoveOthers( fieldIndex ) {
|
317 |
var selectedFieldElement = $( '.field-element[data-id="' + fieldIndex + '"]' ).val();
|
319 |
var selectedFieldElement = $( '.field-element[data-id="' + fieldIndex + '"]' ).val();
|
318 |
|
320 |
|
319 |
if( selectedFieldElement === 'select' || selectedFieldElement === 'radio' ) {
|
321 |
if( selectedFieldElement === 'select' || selectedFieldElement === 'radio' ) {
|
320 |
$( '.is-defaut-value[data-id="' + fieldIndex + '"]' ).click( function() {
|
322 |
$( '.is-defaut-value[data-id="' + fieldIndex + '"]' ).click( function() {
|
321 |
if( $( this ).attr( 'checked' ) ) {
|
323 |
if( $( this ).attr( 'checked' ) ) {
|
322 |
// Décocher tous les autres
|
324 |
// Décocher tous les autres
|
323 |
$( '.is-defaut-value[data-id="' + fieldIndex + '"]:checked' ).not( $( this) ).removeAttr( 'checked' );
|
325 |
$( '.is-defaut-value[data-id="' + fieldIndex + '"]:checked' ).not( $( this) ).removeAttr( 'checked' );
|
324 |
}
|
326 |
}
|
325 |
});
|
327 |
});
|
326 |
}
|
328 |
}
|
327 |
}
|
329 |
}
|
328 |
|
330 |
|
329 |
// Bouton supprimer une valeur
|
331 |
// Bouton supprimer une valeur
|
330 |
function onClickRemoveListValue( fieldIndex ) {
|
332 |
function onClickRemoveListValue( fieldIndex ) {
|
331 |
$( '.remove-value.button[data-id="' + fieldIndex + '"]' ).click( function() {
|
333 |
$( '.remove-value.button[data-id="' + fieldIndex + '"]' ).click( function() {
|
332 |
$( '.new-value[data-list-value-id="' + $( this ).attr( 'data-list-value-id' ) + '"]' ).hide( 200 , function () {
|
334 |
$( '.new-value[data-list-value-id="' + $( this ).attr( 'data-list-value-id' ) + '"]' ).hide( 200 , function () {
|
333 |
$(this).remove();
|
335 |
$(this).remove();
|
334 |
});
|
336 |
});
|
335 |
});
|
337 |
});
|
336 |
}
|
338 |
}
|
337 |
|
339 |
|
338 |
/*********************************************
|
340 |
/*********************************************
|
339 |
* Validation et envoi des nouveaux champs *
|
341 |
* Validation et envoi des nouveaux champs *
|
340 |
*********************************************/
|
342 |
*********************************************/
|
- |
|
343 |
|
- |
|
344 |
// Empêcher de créer plus d'une fois la même clé
|
- |
|
345 |
function onChangeCheckKeyUnique() {
|
- |
|
346 |
if( 1 < $( '.field-key' ).length ) {
|
- |
|
347 |
let notUnique = false;
|
- |
|
348 |
|
- |
|
349 |
$( '.field-key' ).change( function () {
|
- |
|
350 |
// On force le type de thisString en number pour comparer à l'index du for (plus bas)
|
- |
|
351 |
let thisIndex = Number( $( this ).attr( 'data-id' ) ),
|
- |
|
352 |
thisFieldKey = $( '.field-key[data-id="' + thisIndex + '"]' ),
|
- |
|
353 |
count = $( '.field-key' ).length;
|
- |
|
354 |
|
- |
|
355 |
for(var index = 0 ; index < count ; index++) {
|
- |
|
356 |
let loopFieldKey = $( '.field-key[data-id="' + index + '"]' );
|
- |
|
357 |
// Si cet index ne correspond pas à un champ supprimé
|
- |
|
358 |
// On compare la valeur avec les autres champs
|
- |
|
359 |
if( 0 < loopFieldKey.length && thisIndex !== index && thisFieldKey.val() === loopFieldKey.val()) {
|
- |
|
360 |
notUnique = true;
|
- |
|
361 |
}
|
- |
|
362 |
}
|
- |
|
363 |
if( notUnique ) {
|
- |
|
364 |
// Le champ est signalé en rouge
|
- |
|
365 |
thisFieldKey.addClass( 'invalid' );
|
- |
|
366 |
// Un message d'alerte apparait sous le champ
|
- |
|
367 |
if( 0 === $( '.invalid-field-key[data-id="' + thisIndex + '"]' ).length ) {
|
- |
|
368 |
thisFieldKey.after(
|
- |
|
369 |
'<p class="message invalid-field-key" data-id="' + thisIndex + '">' +
|
- |
|
370 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
- |
|
371 |
' Vous avez déjà utilisé cette clé!' +
|
- |
|
372 |
'</p>'
|
- |
|
373 |
);
|
- |
|
374 |
}
|
- |
|
375 |
// Un message d'alerte apparait au dessus des boutons prévisualiser/valider
|
- |
|
376 |
if( 0 === $( '.invalid-field-key-bottom' ).length ) {
|
- |
|
377 |
$( '#new-fields' ).append(
|
- |
|
378 |
'<p class="message invalid-field-key-bottom">' +
|
- |
|
379 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
- |
|
380 |
' Une clé a été utilisée plusieurs fois' +
|
- |
|
381 |
'</p>'
|
- |
|
382 |
);
|
- |
|
383 |
}
|
- |
|
384 |
// Les boutons prévisualiser/valider sont désactivés et signalés en rouge
|
- |
|
385 |
$( '#preview-field , #validate-new-fields' ).addClass( 'invalid' ).css( 'pointer-events', 'none' );
|
- |
|
386 |
// Si on est ok on retire toutes les alertes
|
- |
|
387 |
} else {
|
- |
|
388 |
thisFieldKey.removeClass( 'invalid' );
|
- |
|
389 |
$( '#preview-field , #validate-new-fields' ).removeClass( 'invalid' );
|
- |
|
390 |
$( '.invalid-field-key[data-id="' + thisIndex + '"]' ).hide( 200 , function () {
|
- |
|
391 |
$( this ).remove();
|
- |
|
392 |
});
|
- |
|
393 |
$( '.invalid-field-key-bottom' ).hide( 200 , function () {
|
- |
|
394 |
$( this ).remove();
|
- |
|
395 |
});
|
- |
|
396 |
$( '#preview-field' )[0].style.removeProperty( 'pointer-events' );
|
- |
|
397 |
$( '#validate-new-fields' )[0].style.removeProperty( 'pointer-events' )
|
- |
|
398 |
}
|
- |
|
399 |
// Réinitialisation
|
- |
|
400 |
notUnique = false;
|
- |
|
401 |
});
|
- |
|
402 |
}
|
- |
|
403 |
}
|
341 |
|
404 |
|
342 |
//Activation/Désactivation des boutons valider/prévisualiser
|
405 |
//Activation/Désactivation des boutons valider/prévisualiser
|
343 |
function activatePreviewAndValidateButtons() {
|
406 |
function activatePreviewAndValidateButtons() {
|
344 |
var invalidElementInfos = false, // true si aucune option n'a été entrée pour un élément de liste (select, radio, etc.)
|
407 |
var invalidElementInfos = false, // true si aucune option n'a été entrée pour un élément de liste (select, radio, etc.)
|
345 |
invalidTextInfos = false; // true si au moins un input required n'est pas renseigné
|
408 |
invalidTextInfos = false; // true si au moins un input required n'est pas renseigné
|
346 |
// Clique sur le bouton prévisualiser ou valider
|
409 |
// Clique sur le bouton prévisualiser ou valider
|
347 |
$('#preview-field , #validate-new-fields').on( 'click' , function() {
|
410 |
$('#preview-field , #validate-new-fields').on( 'click' , function() {
|
348 |
// S'il n'y a pas (plus) de bloc nouveau champ
|
411 |
// S'il n'y a pas (plus) de bloc nouveau champ
|
349 |
if( 0 === $( 'fieldset' ).length ) {
|
412 |
if( 0 === $( 'fieldset' ).length ) {
|
350 |
return;
|
413 |
return;
|
351 |
}
|
414 |
}
|
352 |
var count = $( 'fieldset' ).last().attr('data-id');
|
415 |
var count = $( 'fieldset' ).last().attr('data-id');
|
353 |
// si on a déjà des avertissements on les supprime
|
416 |
// si on a déjà des avertissements on les supprime
|
354 |
if( 0 < $( '.validation-warning' ).length ) {
|
417 |
if( 0 < $( '.validation-warning' ).length ) {
|
355 |
// Supprimer les messages
|
418 |
// Supprimer les messages
|
356 |
$( '.validation-warning' ).each( function() {
|
419 |
$( '.validation-warning' ).each( function() {
|
357 |
$( this ).hide( 200 , function () {
|
420 |
$( this ).hide( 200 , function () {
|
358 |
$( this ).remove();
|
421 |
$( this ).remove();
|
359 |
});
|
422 |
});
|
360 |
});
|
423 |
});
|
361 |
// Supprimer les bordures en rouge vif
|
424 |
// Supprimer les bordures en rouge vif
|
362 |
$('.add-value-button , input[required]' ).each( function() {
|
425 |
$('.add-value-button , input[required]' ).each( function() {
|
363 |
$( this ).removeClass( 'invalid' );
|
426 |
$( this ).removeClass( 'invalid' );
|
364 |
});
|
427 |
});
|
365 |
}
|
428 |
}
|
366 |
// Parcourir tous les blocs d'infos de champs supplémentaires
|
429 |
// Parcourir tous les blocs d'infos de champs supplémentaires
|
367 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
430 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
368 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
431 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
369 |
// Certains indices peuvent correspondre à un champ supprimé
|
432 |
// Certains indices peuvent correspondre à un champ supprimé
|
370 |
if( 0 < $( thisFieldset ).length ) {
|
433 |
if( 0 < $( thisFieldset ).length ) {
|
371 |
var $fieldElement = $( '.field-element' , thisFieldset ),
|
434 |
var $fieldElement = $( '.field-element' , thisFieldset ),
|
372 |
fieldElementVal = $fieldElement.val(),
|
435 |
fieldElementVal = $fieldElement.val(),
|
373 |
isList = ( // true si c'est un élément "liste"
|
436 |
isList = ( // true si c'est un élément "liste"
|
374 |
fieldElementVal === 'list-checkbox' ||
|
437 |
fieldElementVal === 'list-checkbox' ||
|
375 |
fieldElementVal === 'checkbox' ||
|
438 |
fieldElementVal === 'checkbox' ||
|
376 |
fieldElementVal === 'radio' ||
|
439 |
fieldElementVal === 'radio' ||
|
377 |
fieldElementVal === 'select'
|
440 |
fieldElementVal === 'select'
|
378 |
);
|
441 |
);
|
379 |
// Si aucune option n'a été créée pour un élément "liste"
|
442 |
// Si aucune option n'a été créée pour un élément "liste"
|
380 |
if( isList && 0 === $( '.list-value' , thisFieldset ).length ) {
|
443 |
if( isList && 0 === $( '.list-value' , thisFieldset ).length ) {
|
381 |
invalidElementInfos = true;
|
444 |
invalidElementInfos = true;
|
382 |
// Le bouton "Ajouter une valeur" est signalé en rouge
|
445 |
// Le bouton "Ajouter une valeur" est signalé en rouge
|
383 |
$( '.add-value-button' , thisFieldset ).addClass( 'invalid' );
|
446 |
$( '.add-value-button' , thisFieldset ).addClass( 'invalid' );
|
384 |
}
|
447 |
}
|
385 |
}
|
448 |
}
|
386 |
}
|
449 |
}
|
387 |
// Si au moins un champ "required" n'est pas rempli
|
450 |
// Si au moins un champ "required" n'est pas rempli
|
388 |
$( 'input[required]' , thisFieldset ).each( function() {
|
451 |
$( 'input[required]' , thisFieldset ).each( function() {
|
389 |
if( 0 === $( this ).val().length ) {
|
452 |
if( 0 === $( this ).val().length ) {
|
390 |
invalidTextInfos = true;
|
453 |
invalidTextInfos = true;
|
391 |
// Le champ est signalé en rouge
|
454 |
// Le champ est signalé en rouge
|
392 |
$( this ).addClass( 'invalid' );
|
455 |
$( this ).addClass( 'invalid' );
|
393 |
}
|
456 |
}
|
394 |
});
|
457 |
});
|
395 |
// Si la saisie est invalide
|
458 |
// Si la saisie est invalide
|
396 |
if( invalidElementInfos || invalidTextInfos ) {
|
459 |
if( invalidElementInfos || invalidTextInfos ) {
|
397 |
// Désactivation des boutons valider et prévisualiser
|
460 |
// Désactivation des boutons valider et prévisualiser
|
398 |
$( '#preview-field , #validate-new-fields' ).addClass( 'invalid' );
|
461 |
$( '#preview-field , #validate-new-fields' ).addClass( 'invalid' );
|
399 |
// Message pour les options des "listes"
|
462 |
// Message pour les options des "listes"
|
400 |
if( invalidElementInfos ) {
|
463 |
if( invalidElementInfos ) {
|
401 |
$( '#new-fields' ).append(
|
464 |
$( '#new-fields' ).append(
|
402 |
'<p class="validation-warning message">' +
|
465 |
'<p class="validation-warning message">' +
|
403 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
466 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
404 |
' Vérifiez les boutons<br>"<i class="fa fa-puzzle-piece" aria-hidden="true" style="color:#4bbacb"></i> Ajouter une valeur" signalés en rouge:' +
|
467 |
' Vérifiez les boutons<br>"<i class="fa fa-puzzle-piece" aria-hidden="true" style="color:#4bbacb"></i> Ajouter une valeur" signalés en rouge:' +
|
405 |
' il faut au moins une valeur pour les éléments "menu déroulant", "boutons radio", "cases à cocher" ou "liste de cases à cocher", ' +
|
468 |
' il faut au moins une valeur pour les éléments "menu déroulant", "boutons radio", "cases à cocher" ou "liste de cases à cocher", ' +
|
406 |
'</p>'
|
469 |
'</p>'
|
407 |
);
|
470 |
);
|
408 |
}
|
471 |
}
|
409 |
// Message pour les champs
|
472 |
// Message pour les champs
|
410 |
if( invalidTextInfos ) {
|
473 |
if( invalidTextInfos ) {
|
411 |
$( '#new-fields' ).append(
|
474 |
$( '#new-fields' ).append(
|
412 |
'<p class="validation-warning message">' +
|
475 |
'<p class="validation-warning message">' +
|
413 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
476 |
'<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
|
414 |
' Des informations sont manquantes pour certains champs,' +
|
477 |
' Des informations sont manquantes pour certains champs,' +
|
415 |
' vérifiez ceux signalés en rouge' +
|
478 |
' vérifiez ceux signalés en rouge' +
|
416 |
'</p>'
|
479 |
'</p>'
|
417 |
);
|
480 |
);
|
418 |
}
|
481 |
}
|
419 |
} else {
|
482 |
} else {
|
420 |
$( '#preview-field , #validate-new-fields' ).removeClass( 'invalid' );
|
483 |
$( '#preview-field , #validate-new-fields' ).removeClass( 'invalid' );
|
421 |
if( $( this ).is( '#validate-new-fields') ) {
|
484 |
if( $( this ).is( '#validate-new-fields') ) {
|
422 |
// Lancement de l'enregistrement des valeurs à transmettre
|
485 |
// Lancement de l'enregistrement des valeurs à transmettre
|
423 |
onClickStoreNewFields();
|
486 |
onClickStoreNewFields();
|
424 |
} else if( $( this ).is( '#preview-field') ) {
|
487 |
} else if( $( this ).is( '#preview-field') ) {
|
425 |
// Lancement de la prévisualisation
|
488 |
// Lancement de la prévisualisation
|
426 |
newFieldsPreview();
|
489 |
newFieldsPreview();
|
427 |
}
|
490 |
}
|
428 |
}
|
491 |
}
|
429 |
// Réinitialisation des drapeaux de saisie invalide
|
492 |
// Réinitialisation des drapeaux de saisie invalide
|
430 |
invalidElementInfos = false;
|
493 |
invalidElementInfos = false;
|
431 |
invalidTextInfos = false;
|
494 |
invalidTextInfos = false;
|
432 |
});
|
495 |
});
|
433 |
}
|
496 |
}
|
434 |
|
497 |
|
435 |
// Enregistrement des valeurs à transmettre
|
498 |
// Enregistrement des valeurs à transmettre
|
436 |
function onClickStoreNewFields() {
|
499 |
function onClickStoreNewFields() {
|
437 |
// Lorsqu'on valide
|
500 |
// Lorsqu'on valide
|
438 |
var resultArrayIndex = 0;
|
501 |
var resultArrayIndex = 0;
|
439 |
var count = $( 'fieldset' ).last().attr('data-id');
|
502 |
var count = $( 'fieldset' ).last().attr('data-id');
|
440 |
var helpFileExists = false;
|
503 |
var helpFileExists = false;
|
441 |
|
504 |
|
442 |
// Savoir si au moins un fichier "aide" est enregistré
|
505 |
// Savoir si au moins un fichier "aide" est enregistré
|
443 |
$( '.field-help' ).each( function () {
|
506 |
$( '.field-help' ).each( function () {
|
444 |
if( '' !== $( this ).val() ){
|
507 |
if( '' !== $( this ).val() ){
|
445 |
helpFileExists = true;
|
508 |
helpFileExists = true;
|
446 |
}
|
509 |
}
|
447 |
})
|
510 |
})
|
448 |
// dans ce cas intégrer dans le formulaire à soumettre un bloc
|
511 |
// dans ce cas intégrer dans le formulaire à soumettre un bloc
|
449 |
// qui contiendra une copie de chacun de ces input[type="file"]
|
512 |
// qui contiendra une copie de chacun de ces input[type="file"]
|
450 |
if( helpFileExists ){
|
513 |
if( helpFileExists ){
|
451 |
$('#submit-button').before( '<div id="help-doc-submit" class="hidden"></div>' );
|
514 |
$('#submit-button').before( '<div id="help-doc-submit" class="hidden"></div>' );
|
452 |
}
|
515 |
}
|
453 |
|
516 |
|
454 |
// On déroule les blocs de champs supplémentaires
|
517 |
// On déroule les blocs de champs supplémentaires
|
455 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
518 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
456 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
519 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
457 |
// Certains indices peuvent correspondre à un champ supprimé
|
520 |
// Certains indices peuvent correspondre à un champ supprimé
|
458 |
if( 0 < $( thisFieldset ).length ) {
|
521 |
if( 0 < $( thisFieldset ).length ) {
|
459 |
// initialisation du tableau de résultats
|
522 |
// initialisation du tableau de résultats
|
460 |
datasToSubmit[ resultArrayIndex ] = { fieldValues:{} };
|
523 |
datasToSubmit[ resultArrayIndex ] = { fieldValues:{} };
|
461 |
// Ajout de la clé au tableau de resultats
|
524 |
// Ajout de la clé au tableau de resultats
|
462 |
datasToSubmit[ resultArrayIndex ].key = $( '.field-key' , thisFieldset ).val();
|
525 |
datasToSubmit[ resultArrayIndex ].key = $( '.field-key' , thisFieldset ).val();
|
463 |
// Ajout de le nom au tableau de resultats
|
526 |
// Ajout de le nom au tableau de resultats
|
464 |
datasToSubmit[ resultArrayIndex ].name = $( '.field-name' , thisFieldset ).val();
|
527 |
datasToSubmit[ resultArrayIndex ].name = $( '.field-name' , thisFieldset ).val();
|
465 |
// Recueil de l'élément choisi pour le tableau de resultats
|
528 |
// Recueil de l'élément choisi pour le tableau de resultats
|
466 |
datasToSubmit[ resultArrayIndex ].element = $( '.field-element' , thisFieldset ).val();
|
529 |
datasToSubmit[ resultArrayIndex ].element = $( '.field-element' , thisFieldset ).val();
|
467 |
// Ajout de la valeur 'requis' ou non au tableau de resultats
|
530 |
// Ajout de la valeur 'requis' ou non au tableau de resultats
|
468 |
datasToSubmit[ resultArrayIndex ].mandatory = false;
|
- |
|
469 |
// Ajout de "champ requis"
|
- |
|
470 |
if( $( '.field-is_mandatory' , thisFieldset ).is( ':checked' ) ) {
|
531 |
datasToSubmit[ resultArrayIndex ].mandatory = $( '.field-is_mandatory' , thisFieldset ).is( ':checked' );
|
471 |
datasToSubmit[ resultArrayIndex ].mandatory = true;
|
- |
|
472 |
}
|
- |
|
473 |
// Ajout de l'unité au tableau de resultats
|
532 |
// Ajout de l'unité au tableau de resultats
|
474 |
if ( $( '.field-unit' , thisFieldset ).val() ) {
|
- |
|
475 |
datasToSubmit[ resultArrayIndex ].unit = $( '.field-unit' , thisFieldset ).val();
|
533 |
datasToSubmit[ resultArrayIndex ].unit = $( '.field-unit' , thisFieldset ).val() || null;
|
476 |
}
|
- |
|
477 |
// Ajout du tooltip au tableau de resultats
|
534 |
// Ajout du tooltip au tableau de resultats
|
478 |
if ( $( '.field-description' , thisFieldset ).val() ) {
|
- |
|
479 |
datasToSubmit[ resultArrayIndex ].description = $( '.field-description' , thisFieldset ).val();
|
535 |
datasToSubmit[ resultArrayIndex ].description = $( '.field-description' , thisFieldset ).val() || null;
|
480 |
}
|
- |
|
481 |
// Ajout du nom du document d'aide au tableau de resultats
|
536 |
// Ajout du nom du document d'aide au tableau de resultats
|
482 |
if ( $('.file-return.help-doc-' + index ).text() ) {
|
- |
|
483 |
datasToSubmit[ resultArrayIndex ].help = $( '.file-return.help-doc-' + index ).text();
|
537 |
datasToSubmit[ resultArrayIndex ].help = $( '.file-return.help-doc-' + index ).text() || null;
|
484 |
}
|
- |
|
485 |
// Collecte les des données dépendantes de l'élément choisi
|
538 |
// Collecte les des données dépendantes de l'élément choisi
|
486 |
// sous forme d'un tableau de resultats
|
539 |
// sous forme d'un tableau de resultats
|
487 |
onSelectCollectDataValuesToSubmit( datasToSubmit[ resultArrayIndex ] , thisFieldset );
|
540 |
onSelectCollectDataValuesToSubmit( datasToSubmit[ resultArrayIndex ] , thisFieldset );
|
488 |
if( $.isEmptyObject(datasToSubmit[ resultArrayIndex ].fieldValues) ){
|
541 |
if( $.isEmptyObject(datasToSubmit[ resultArrayIndex ].fieldValues) ){
|
489 |
delete datasToSubmit[ resultArrayIndex ].fieldValues;
|
542 |
delete datasToSubmit[ resultArrayIndex ].fieldValues;
|
490 |
}
|
543 |
}
|
491 |
|
544 |
|
492 |
// Copie d'un champ de fichier d'aide dans le bloc d'envoi
|
545 |
// Copie d'un champ de fichier d'aide dans le bloc d'envoi
|
493 |
if( '' !== $( '.field-help' , thisFieldset ).val() ) {
|
546 |
if( '' !== $( '.field-help' , thisFieldset ).val() ) {
|
494 |
$( '.field-help' , thisFieldset ).clone()
|
547 |
$( '.field-help' , thisFieldset ).clone()
|
495 |
.attr( 'id' , datasToSubmit[ resultArrayIndex ].key )// l'id prend la valeur de la clé
|
548 |
.attr( 'id' , datasToSubmit[ resultArrayIndex ].key )// l'id prend la valeur de la clé
|
496 |
.css( 'position' , 'static' )// Retrouver facilement le bloc dans la page
|
549 |
.css( 'position' , 'static' )// Retrouver facilement le bloc dans la page
|
497 |
.appendTo( '#help-doc-submit' );
|
550 |
.appendTo( '#help-doc-submit' );
|
498 |
}
|
551 |
}
|
499 |
|
552 |
|
500 |
resultArrayIndex++;
|
553 |
resultArrayIndex++;
|
501 |
}
|
554 |
}
|
502 |
}
|
555 |
}
|
503 |
var resultsArrayJson = JSON.stringify( datasToSubmit );
|
556 |
var resultsArrayJson = JSON.stringify( datasToSubmit );
|
504 |
|
557 |
|
505 |
console.log(resultsArrayJson);
|
558 |
console.log(resultsArrayJson);
|
506 |
// console.log(datasToSubmit);
|
559 |
// console.log(datasToSubmit);
|
507 |
// Désactivation de tous les champs et boutons (nouveaux champs)
|
560 |
// Désactivation de tous les champs et boutons (nouveaux champs)
|
508 |
$( '#new-fields, #new-fields .button , #add-fields , #preview-field' ).addClass( 'disabled' );
|
561 |
$( '#new-fields, #new-fields .button , #add-fields , #preview-field' ).addClass( 'disabled' );
|
509 |
$( '#validate-new-fields' ).addClass( 'validated' );
|
562 |
$( '#validate-new-fields' ).addClass( 'validated' );
|
510 |
$( '.validate-new-fields' ).text( 'Champs validés' );
|
563 |
$( '.validate-new-fields' ).text( 'Champs validés' );
|
511 |
// Mise à disposition des données pour le bouron submit
|
564 |
// Mise à disposition des données pour le bouron submit
|
512 |
$('#submit-button').before(
|
565 |
$('#submit-button').before(
|
513 |
'<input type="hidden" name="champs-supp" id="champs-supp" value=\'' + resultsArrayJson + '\'>'
|
566 |
'<input type="hidden" name="champs-supp" id="champs-supp" value=\'' + resultsArrayJson + '\'>'
|
514 |
);
|
567 |
);
|
515 |
}
|
568 |
}
|
516 |
|
569 |
|
517 |
// Renseigne le tableau de resultat
|
570 |
// Renseigne le tableau de resultat
|
518 |
// pour les données dépendant de l'élément choisi
|
571 |
// pour les données dépendant de l'élément choisi
|
519 |
function onSelectCollectDataValuesToSubmit( datasToSubmitObject , thisFieldset ) {
|
572 |
function onSelectCollectDataValuesToSubmit( datasToSubmitObject , thisFieldset ) {
|
520 |
switch( datasToSubmitObject.element ) {
|
573 |
switch( datasToSubmitObject.element ) {
|
521 |
// case 'file' :
|
574 |
// case 'file' :
|
522 |
// Rien à faire, pas de détails à transmettre
|
575 |
// Rien à faire, pas de détails à transmettre
|
523 |
case 'select':
|
576 |
case 'select':
|
524 |
case 'checkbox':
|
577 |
case 'checkbox':
|
525 |
case 'list-checkbox':
|
578 |
case 'list-checkbox':
|
526 |
case 'radio':
|
579 |
case 'radio':
|
527 |
datasToSubmitObject.fieldValues.listValue = [];
|
580 |
datasToSubmitObject.fieldValues.listValue = [];
|
528 |
// Ajout des valeurs de liste
|
581 |
// Ajout des valeurs de liste
|
529 |
onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset );
|
582 |
onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset );
|
530 |
// S'il y a une valeur 'autre' on l'indique à la fin de la liste
|
583 |
// S'il y a une valeur 'autre' on l'indique à la fin de la liste
|
531 |
if( $('.option-other-value' , thisFieldset ).attr( 'checked' ) && datasToSubmitObject.fieldValues.listValue.indexOf( 'other' ) === -1 ) {
|
584 |
if( $('.option-other-value' , thisFieldset ).attr( 'checked' ) && datasToSubmitObject.fieldValues.listValue.indexOf( 'other' ) === -1 ) {
|
532 |
datasToSubmitObject.fieldValues.listValue.push( 'other' );
|
585 |
datasToSubmitObject.fieldValues.listValue.push( 'other' );
|
533 |
}
|
586 |
}
|
534 |
break;
|
587 |
break;
|
535 |
|
588 |
|
536 |
case 'number':
|
589 |
case 'number':
|
537 |
case 'range':
|
590 |
case 'range':
|
538 |
// Placeholder
|
591 |
// Placeholder
|
539 |
if( $( '.aide-saisie' , thisFieldset ).val() ) {
|
- |
|
540 |
datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val();
|
592 |
datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val() || null;
|
541 |
}
|
- |
|
542 |
// Valeur par défaut
|
593 |
// Valeur par défaut
|
543 |
if( $( '.default' , thisFieldset ).val() ) {
|
- |
|
544 |
datasToSubmitObject.fieldValues.default = $( '.default' , thisFieldset ).val();
|
594 |
datasToSubmitObject.fieldValues.default = $( '.default' , thisFieldset ).val() || null;
|
545 |
}
|
- |
|
546 |
// Incrémentation ( attribut step="" )
|
595 |
// Incrémentation ( attribut step="" )
|
547 |
if( $( '.step' , thisFieldset ).val() ) {
|
- |
|
548 |
datasToSubmitObject.fieldValues.step = $( '.step' , thisFieldset ).val();
|
596 |
datasToSubmitObject.fieldValues.step = $( '.step' , thisFieldset ).val() || null;
|
549 |
}
|
- |
|
550 |
// Min
|
597 |
// Min
|
551 |
if( $( '.min' , thisFieldset ).val() ) {
|
- |
|
552 |
datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val();
|
598 |
datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val() || null;
|
553 |
}
|
- |
|
554 |
// Max
|
599 |
// Max
|
555 |
if( $( '.max' , thisFieldset ).val() ) {
|
- |
|
556 |
datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val();
|
600 |
datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val() || null;
|
557 |
}
|
- |
|
558 |
break;
|
601 |
break;
|
559 |
|
602 |
|
560 |
case 'date':
|
603 |
case 'date':
|
561 |
// Min
|
604 |
// Min
|
562 |
if( $( '.min' , thisFieldset ).val() ) {
|
- |
|
563 |
datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val();
|
605 |
datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val() || null;
|
564 |
}
|
- |
|
565 |
// Max
|
606 |
// Max
|
566 |
if( $( '.max' , thisFieldset ).val() ) {
|
- |
|
567 |
datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val();
|
607 |
datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val() || null;
|
568 |
}
|
- |
|
569 |
break;
|
608 |
break;
|
570 |
|
609 |
|
571 |
case 'email':
|
610 |
case 'email':
|
572 |
case 'text':
|
611 |
case 'text':
|
573 |
case 'textarea':
|
612 |
case 'textarea':
|
574 |
default:
|
613 |
default:
|
575 |
// Placeholder
|
614 |
// Placeholder
|
576 |
if( $( '.aide-saisie' , thisFieldset ).val() ) {
|
- |
|
577 |
datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val();
|
615 |
datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val() || null;
|
578 |
}
|
- |
|
579 |
break;
|
616 |
break;
|
580 |
}
|
617 |
}
|
581 |
return datasToSubmitObject;
|
618 |
return datasToSubmitObject;
|
582 |
}
|
619 |
}
|
583 |
|
620 |
|
584 |
// Ajout d'une valeur d'un élément liste (select, checkbox etc.)
|
621 |
// Ajout d'une valeur d'un élément liste (select, checkbox etc.)
|
585 |
// dans le tableau de resultats
|
622 |
// dans le tableau de resultats
|
586 |
function onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset ) {
|
623 |
function onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset ) {
|
587 |
$( '.list-value' , thisFieldset ).each( function() {
|
624 |
$( '.list-value' , thisFieldset ).each( function() {
|
588 |
var selectedFieldElement = $( '.field-element' , thisFieldset ).val();
|
625 |
var selectedFieldElement = $( '.field-element' , thisFieldset ).val();
|
- |
|
626 |
|
589 |
if( $( this ).val() ){
|
627 |
if( $( this ).val() ){
|
- |
|
628 |
// Is-default-value non cochée
|
590 |
if( !$( '.is-defaut-value[data-list-value-id="' + $( this ).attr('data-list-value-id') + '"]' , thisFieldset ).attr( 'checked' ) ) {
|
629 |
if( !$( '.is-defaut-value[data-list-value-id="' + $( this ).attr( 'data-list-value-id' ) + '"]' , thisFieldset ).attr( 'checked' ) ) {
|
591 |
datasToSubmitObject.fieldValues.listValue.push( $( this ).val() );
|
630 |
datasToSubmitObject.fieldValues.listValue.push( $( this ).val() );
|
- |
|
631 |
// Is-default-value cochée pour select/radio
|
592 |
} else if( 'select' === selectedFieldElement || 'radio' === selectedFieldElement ) {
|
632 |
} else if( 'select' === selectedFieldElement || 'radio' === selectedFieldElement ) {
|
- |
|
633 |
// Une seule valeur par defaut, devient la première valeur du tableau + '#'
|
593 |
datasToSubmitObject.fieldValues.listValue.unshift( $( this ).val() + '#' );
|
634 |
datasToSubmitObject.fieldValues.listValue.unshift( $( this ).val() + '#' );
|
- |
|
635 |
// Is-default-value cochée pour checkbox/list-checkbox
|
594 |
} else {
|
636 |
} else {
|
- |
|
637 |
// On ajoute simplement la valeur au tableau + '#'
|
595 |
datasToSubmitObject.fieldValues.listValue.push( $( this ).val() + '#' );
|
638 |
datasToSubmitObject.fieldValues.listValue.push( $( this ).val() + '#' );
|
596 |
}
|
639 |
}
|
597 |
}
|
640 |
}
|
598 |
});
|
641 |
});
|
599 |
}
|
642 |
}
|
600 |
|
643 |
|
601 |
/************************************************
|
644 |
/************************************************
|
602 |
* Fonction d'affichage des champs classiques *
|
645 |
* Fonction d'affichage des champs classiques *
|
603 |
************************************************/
|
646 |
************************************************/
|
604 |
|
- |
|
605 |
// Affichage des infos dès que disponibles
|
647 |
|
606 |
// pour les champs classiques
|
- |
|
607 |
function renderFields( $source , $taget ) {
|
- |
|
608 |
|
- |
|
609 |
if($source.val()) {
|
- |
|
610 |
$taget.text( $source.val() );
|
- |
|
611 |
}
|
- |
|
612 |
$source.change( function () {
|
- |
|
613 |
$taget.text( $( this ).val() );
|
- |
|
614 |
});
|
- |
|
615 |
}
|
- |
|
616 |
|
648 |
// Prévisualisation
|
617 |
function DisplayClassicFields() {
|
649 |
function DisplayClassicFields() {
|
618 |
// Affichage du titre du widget
|
650 |
// Affichage du titre du widget
|
619 |
renderFields( $('#titre') , $( '.widget-renderer h1' ) );
|
651 |
renderFields( $('#titre') , $( '.widget-renderer h1' ) );
|
620 |
// Affichage du nom du projet
|
652 |
// Affichage du nom du projet
|
621 |
renderFields( $('#projet') , $( '.projet-description' ));
|
653 |
renderFields( $('#projet') , $( '.projet-description' ));
|
622 |
// Affichage de la description
|
654 |
// Affichage de la description
|
623 |
renderFields( $('#description') , $( '.preview-description' ) );
|
655 |
renderFields( $('#description') , $( '.preview-description' ) );
|
624 |
// Affichage du logo s'il existe déjà
|
656 |
// Affichage du logo s'il existe déjà
|
625 |
if( $('#logo').val() ) {
|
657 |
if( $('#logo').val() || $('#logo')[0].defaultValue ) {
|
626 |
$( '#preview-logo' ).prop( 'src' , $( '#group-settings-form .logo img' ).prop('src') );
|
658 |
$( '#preview-logo img' ).prop( 'src' , $( '#group-settings-form .logo img' ).prop('src') );
|
627 |
}
|
659 |
}
|
628 |
// Affichage du logo chargé
|
660 |
// Affichage du logo chargé
|
629 |
$( '#logo.input-file' ).change( function( event ) {
|
661 |
$( '#logo.input-file' ).change( function( event ) {
|
630 |
|
- |
|
631 |
if( !$.isEmptyObject( event.target.files[0] ) ) {
|
662 |
// Si le 'change' était pas une suppression
|
632 |
$( '#preview-logo img' ).prop( 'src' , URL.createObjectURL( event.target.files[0] ) );
|
663 |
if( $.isEmptyObject( event.target.files[0] ) ) {
|
633 |
} else {
|
- |
|
634 |
$( '#preview-logo img' ).prop( 'src' , '' );
|
664 |
$( '#preview-logo img' ).prop( 'src' , '' );
|
- |
|
665 |
// Si on a chargé un logo ou changé le fichier
|
- |
|
666 |
} else {
|
- |
|
667 |
$( '#preview-logo img' ).prop( 'src' , URL.createObjectURL( event.target.files[0] ) );
|
635 |
}
|
668 |
}
|
636 |
});
|
669 |
});
|
637 |
// Affichage de l'image de fond
|
670 |
// Affichage de l'image de fond
|
638 |
$('#fond.input-file').change( function ( event ) {
|
671 |
$('#fond.input-file').change( function ( event ) {
|
639 |
if( !$.isEmptyObject( event.target.files[0] ) ) {
|
672 |
if( !$.isEmptyObject( event.target.files[0] ) ) {
|
640 |
$( '.widget-renderer' ).css('background' ,'url(' + URL.createObjectURL( event.target.files[0] ) + ') no-repeat center');
|
673 |
$( '.widget-renderer' ).css('background' ,'url(' + URL.createObjectURL( event.target.files[0] ) + ') no-repeat center');
|
641 |
} else {
|
674 |
} else {
|
642 |
$( '.widget-renderer' )[0].style.removeProperty( 'background' );
|
675 |
$( '.widget-renderer' )[0].style.removeProperty( 'background' );
|
643 |
}
|
676 |
}
|
644 |
});
|
677 |
});
|
645 |
}
|
678 |
}
|
- |
|
679 |
|
- |
|
680 |
// Affichage des infos dès que disponibles
|
- |
|
681 |
// pour les champs classiques
|
- |
|
682 |
function renderFields( $source , $taget ) {
|
- |
|
683 |
if($source.val()) {
|
- |
|
684 |
$taget.text( $source.val() );
|
- |
|
685 |
}
|
- |
|
686 |
$source.change( function () {
|
- |
|
687 |
$taget.text( $( this ).val() );
|
- |
|
688 |
});
|
- |
|
689 |
}
|
646 |
|
690 |
|
647 |
|
691 |
|
648 |
// /*****************************************************
|
692 |
/*****************************************************
|
649 |
// * Fonction d'affichage des champs supplémentaires *
|
693 |
* Fonction d'affichage des champs supplémentaires *
|
650 |
// *****************************************************/
|
694 |
*****************************************************/
|
651 |
|
695 |
|
652 |
// Construction des éléments à visualiser
|
696 |
// Construction des éléments à visualiser
|
653 |
function onClickPreviewField( thisFieldset , index ) {
|
697 |
function onClickPreviewField( thisFieldset , index ) {
|
654 |
|
- |
|
- |
|
698 |
// Récupération des données
|
- |
|
699 |
// Tous les champs
|
655 |
var fieldLabel = $( '.field-name' , thisFieldset ).val(),
|
700 |
var fieldLabel = $( '.field-name' , thisFieldset ).val(),//nom
|
656 |
fieldKey = $( '.field-key' , thisFieldset ).val(),
|
701 |
fieldKey = $( '.field-key' , thisFieldset ).val(),//clé
|
657 |
fieldElement = $( '.field-element' , thisFieldset ).val(),
|
702 |
fieldElement = $( '.field-element' , thisFieldset ).val(),//élément
|
658 |
fieldIsMandatory = $( '.field-is_mandatory' , thisFieldset ).is( ':checked' ),
|
703 |
fieldIsMandatory = $( '.field-is_mandatory' , thisFieldset ).is( ':checked' ),//champ requis
|
659 |
fieldUnit = $( '.field-unit' , thisFieldset ).val(),
|
704 |
fieldUnit = $( '.field-unit' , thisFieldset ).val(),//unités
|
660 |
fieldTooltip = $( '.field-description' , thisFieldset ).val(),
|
705 |
fieldTooltip = $( '.field-description' , thisFieldset ).val(),//info-bulle
|
661 |
fieldHelp = $( '.file-return.help-doc-' + index ).text(),
|
706 |
fieldHelp = $( '.file-return.help-doc-' + index ).text(),//nom du fichier d'aide
|
662 |
fieldPlaceholder = $( '.aide-saisie' , thisFieldset ).val() || '',
|
707 |
fieldPlaceholder = $( '.aide-saisie' , thisFieldset ).val() || '',//placeholder
|
663 |
fieldDefaultNum = $( '.default' , thisFieldset ).val(),
|
708 |
// Champs à valeur numérique ou date
|
664 |
fieldStep = $( '.step' , thisFieldset ).val(),
|
709 |
fieldStep = $( '.step' , thisFieldset ).val(),
|
665 |
fieldMin = $( '.min' , thisFieldset ).val(),
|
710 |
fieldMin = $( '.min' , thisFieldset ).val(),
|
666 |
fieldMax = $( '.max' , thisFieldset ).val(),
|
711 |
fieldMax = $( '.max' , thisFieldset ).val(),
|
- |
|
712 |
// Champs "listes"
|
- |
|
713 |
fieldDefaultNum = $( '.default' , thisFieldset ).val(),//option pas default
|
667 |
fieldOtherValue = $( '.option-other-value' , thisFieldset ).is( ':checked' ),
|
714 |
fieldOtherValue = $( '.option-other-value' , thisFieldset ).is( ':checked' ),//option autre
|
668 |
fieldOptions = collectListOptions( thisFieldset );
|
715 |
fieldOptions = collectListOptions( thisFieldset );//Array: toutes les options
|
669 |
|
- |
|
670 |
|
- |
|
671 |
|
- |
|
672 |
var fieldHtmlObject = {},
|
716 |
// Variables d'affichage
|
673 |
fieldHtml = '',
|
717 |
var fieldHtml = '',//variable contenant tout le html à afficher
|
674 |
constHtml = {},
|
718 |
commonFieldsHtml = {},//Éléments simples ou chaînes communes aux "listes"
|
- |
|
719 |
listFieldsHtml = {},//chaînes & html pour les listes mais non spécifiques
|
675 |
listHtml = {},
|
720 |
listFieldsHtml = {},//chaînes & html spécifiques aux listes
|
676 |
count = fieldOptions.length,
|
721 |
count = fieldOptions.length;//nombre d'options, pour les boucles for
|
677 |
fieldHelpClass = '';
|
722 |
//valeurs initiales des chaînes de caractères
|
678 |
|
- |
|
679 |
// Pour les éléments simples
|
723 |
//Éléments simples ou chaînes communes aux "listes"
|
680 |
fieldHtmlObject = {
|
724 |
commonFieldsHtml = {
|
- |
|
725 |
dataIdAttr : ' data-id="' + index + '"',
|
681 |
fieldHelpButton : '',
|
726 |
helpButton : '',//bouton aide
|
- |
|
727 |
helpClass : '',//classe de l'élément associé au bouton aide
|
682 |
fieldTitleAttr : '',
|
728 |
titleAttr : '',//info-bulle
|
683 |
fieldLabel : {
|
729 |
fieldInput : {//attributs de l'élément
|
- |
|
730 |
typeAttr : ' type="' + fieldElement + '"',
|
684 |
labelForAttr :' for="' + fieldKey + '"',
|
731 |
nameAttr : ' name="' + fieldKey + '"',
|
- |
|
732 |
classAttr : ' class="' + fieldKey + '"',
|
685 |
labelClassAttr :'',
|
733 |
placeholderAttr : '',
|
686 |
labelOtherAttr : '',
|
734 |
mandatoryAttr : '',//required
|
687 |
labelContent : fieldLabel
|
735 |
otherAttr : ''
|
688 |
},
|
736 |
},
|
689 |
fieldInput : {
|
737 |
fieldLabel : {//attributs et contenu du label
|
690 |
inputTypeAttr : ' type="' + fieldElement + '"',
|
738 |
labelContent : fieldLabel,//label
|
691 |
inputNameAttr : ' name="' + fieldKey + '"',
|
739 |
forAttr : ' for="' + fieldKey + '"',//attribut for
|
692 |
inputDataIdAttr : ' data-id="' + index + '"',
|
- |
|
693 |
inputClassAttr : ' class="' + fieldKey + '"',
|
740 |
classAttr : '',//classe du label
|
694 |
inputPlaceholderAttr : '',
|
- |
|
695 |
inputOtherAttr : ''
|
741 |
otherAttr : ''//tous autres attributs
|
696 |
}
|
742 |
}
|
697 |
}
|
743 |
}
|
698 |
|
- |
|
699 |
// Pour les éléments de listes (select, checkbox, etc.)
|
744 |
// Pour les éléments de listes (select, checkbox, etc.)
|
700 |
constHtml = {
|
745 |
listFieldsHtml = {
|
701 |
fieldContainerContent : fieldLabel,
|
746 |
containerContent : fieldLabel,//les options peuvent avoir chacune un label
|
702 |
fieldDataIdAttr : ' data-id="' + index + '"',
|
747 |
containerClass : '',//une classe pour le conteneur
|
703 |
fieldTitleAttr : '',
|
- |
|
704 |
fieldMandatoryAttr : '',
|
- |
|
705 |
fieldContainerClass : ''
|
- |
|
706 |
};
|
- |
|
707 |
|
- |
|
708 |
listHtml = {
|
- |
|
709 |
optionLabel : {},
|
- |
|
710 |
optionInput : {
|
- |
|
711 |
inputTypeAttr : ' type="' + fieldElement + '"',
|
748 |
forAttr : '',//correspond à l'id d'une checkbox/radio/list-checkbox
|
712 |
inputNameAttr : ' name="' + fieldKey + '"',
|
749 |
optionIdAttr : '',//value-id
|
713 |
inputClassAttr : ' class="' + fieldKey + '"',
|
750 |
defaultAttr : ''//default
|
714 |
inputOptionIdAttr : ''
|
- |
|
715 |
}
|
- |
|
716 |
};
|
751 |
};
|
717 |
|
- |
|
718 |
// Changement d'un élément existant:
|
752 |
// Changement d'un élément existant:
|
719 |
// supprimer le précédent pour ajouter le nouveau
|
753 |
// supprimer le précédent pour ajouter le nouveau
|
720 |
if( 0 < $( '.preview-fields' , thisFieldset ).length ) {
|
754 |
if( 0 < $( '.preview-fields' , thisFieldset ).length ) {
|
721 |
$( '.preview-fields' , thisFieldset ).remove();
|
755 |
$( '.preview-fields' , thisFieldset ).remove();
|
722 |
}
|
756 |
}
|
723 |
|
- |
|
724 |
// Si l'élément est requis
|
757 |
// Élément requis
|
725 |
if( fieldIsMandatory ) {
|
758 |
if( fieldIsMandatory ) {
|
726 |
// Attribut required
|
759 |
// Attribut required pour le listes
|
727 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' required="required"';
|
760 |
commonFieldsHtml.fieldInput.mandatoryAttr = ' required="required"';
|
728 |
// Nom du champ (éléments listes)
|
761 |
// Nom du champ (éléments listes)
|
729 |
constHtml.fieldContainerContent += ' *';
|
762 |
listFieldsHtml.containerContent += ' *';
|
730 |
// Nom du champ (éléments simples)
|
763 |
// Nom du champ (éléments simples)
|
731 |
fieldHtmlObject.fieldLabel.labelContent += ' *';
|
764 |
commonFieldsHtml.fieldLabel.labelContent += ' *';
|
732 |
}
|
765 |
}
|
733 |
|
- |
|
734 |
// Si on a une infobulle
|
766 |
// Infobulle
|
735 |
if( '' !== fieldTooltip ) {
|
767 |
if( '' !== fieldTooltip ) {
|
736 |
fieldHtmlObject.fieldTitleAttr = ' title="' + fieldTooltip + '"';
|
768 |
commonFieldsHtml.titleAttr = ' title="' + fieldTooltip + '"';
|
737 |
}
|
769 |
}
|
738 |
|
- |
|
739 |
// Si on a un placeholder
|
770 |
// Placeholder
|
740 |
if( '' !== fieldPlaceholder ) {
|
771 |
if( '' !== fieldPlaceholder ) {
|
741 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr = ' placeholder="' + fieldPlaceholder + '"';
|
772 |
commonFieldsHtml.fieldInput.placeholderAttr = ' placeholder="' + fieldPlaceholder + '"';
|
742 |
console.log(fieldPlaceholder);
|
- |
|
743 |
}
|
773 |
}
|
744 |
|
- |
|
- |
|
774 |
// Fichier d'aide
|
745 |
if( '' !== fieldHelp ) {
|
775 |
if( '' !== fieldHelp ) {
|
- |
|
776 |
// Bouton 'aide'
|
746 |
fieldHtmlObject.fieldHelpButton = '<div class="button help-button"><i class="fas fa-info-circle"></i></div>';
|
777 |
commonFieldsHtml.helpButton = '<div class="button help-button"><i class="fas fa-info-circle"></i></div>';
|
- |
|
778 |
// classe 'aide'
|
747 |
fieldHelpClass = ' and-help';
|
779 |
commonFieldsHtml.helpClass = ' and-help';
|
748 |
}
|
780 |
}
|
749 |
|
- |
|
750 |
// html à ajouter en fonction de l'élément choisi
|
781 |
// html à ajouter en fonction de l'élément choisi
|
751 |
switch( fieldElement ) {
|
782 |
switch( fieldElement ) {
|
752 |
case 'checkbox' :
|
783 |
case 'checkbox' :
|
753 |
case 'radio' :
|
784 |
case 'radio' :
|
754 |
constHtml.fieldContainerClass = ' class="' + fieldElement +'"';
|
785 |
listFieldsHtml.containerClass = ' class="' + fieldElement +'"';
|
755 |
fieldHtml =
|
786 |
fieldHtml =
|
756 |
// Conteneur
|
787 |
// Conteneur
|
757 |
'<div' +
|
788 |
'<div' +
|
758 |
// Class="L'élément choisi"
|
789 |
// Class="L'élément choisi"
|
759 |
constHtml.fieldContainerClass +
|
790 |
listFieldsHtml.containerClass +
|
760 |
// DataId
|
791 |
// DataId
|
761 |
constHtml.fieldDataIdAttr +
|
792 |
commonFieldsHtml.dataIdAttr +
|
762 |
// Required
|
793 |
// Required
|
763 |
constHtml.fieldMandatoryAttr +
|
794 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
764 |
// Info bulle
|
795 |
// Info bulle
|
765 |
constHtml.fieldTitleAttr +
|
796 |
commonFieldsHtml.titleAttr +
|
766 |
' >'+
|
797 |
' >'+
|
767 |
// Nom du champ
|
798 |
// Nom du champ
|
- |
|
799 |
// Classe 'and-help'
|
768 |
'<div class="list-label' + fieldHelpClass + '">' +
|
800 |
'<div class="list-label' + commonFieldsHtml.helpClass + '">' +
|
- |
|
801 |
// Label
|
769 |
constHtml.fieldContainerContent +
|
802 |
listFieldsHtml.containerContent +
|
770 |
'</div>' +
|
803 |
'</div>' +
|
- |
|
804 |
// Bouton 'help'
|
771 |
fieldHtmlObject.fieldHelpButton;
|
805 |
commonFieldsHtml.helpButton;
|
772 |
// On déroule les différentes valeurs
|
806 |
// On déroule les différentes valeurs
|
773 |
for ( let i = 0; i < count; i++ ) {
|
807 |
for( let i = 0; i < count; i++ ) {
|
774 |
let fieldOption = fieldOptions[i];
|
808 |
let fieldOption = fieldOptions[i];
|
775 |
|
- |
|
776 |
listHtml.optionInput.inputDefaultAttr = '';
|
809 |
// L'id de input
|
777 |
listHtml.optionInput.inputIdAttr = ' id="' + fieldOption.optionValue + '"';
|
810 |
listFieldsHtml.inputIdAttr = ' id="' + fieldOption.optionValue + '"';
|
778 |
listHtml.optionLabel.labelForAttr = ' for="' + fieldOption.optionValue + '"';
|
811 |
listFieldsHtml.forAttr = ' for="' + fieldOption.optionValue + '"';
|
779 |
|
- |
|
- |
|
812 |
// Default
|
780 |
// Si c'est une/l'option par défaut
|
813 |
listFieldsHtml.defaultAttr = '';//réinitialisation
|
781 |
if( fieldOption.isDefault ) {
|
814 |
if( fieldOption.isDefault ) {//affectation
|
782 |
listHtml.optionInput.inputDefaultAttr = ' checked';
|
815 |
listFieldsHtml.defaultAttr = ' checked';
|
783 |
}
|
816 |
}
|
784 |
|
- |
|
785 |
// L'indice de chaque option
|
817 |
// L'indice de chaque option
|
786 |
// L'option "autre" n'en a pas
|
818 |
// L'option "autre" n'en a pas
|
787 |
if( '' !== fieldOption.optionIndex ) {
|
819 |
if( '' !== fieldOption.optionIndex ) {
|
788 |
listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
820 |
listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
789 |
}
|
821 |
}
|
790 |
|
822 |
|
791 |
fieldHtml +=
|
823 |
fieldHtml +=
|
792 |
'<label' +
|
824 |
'<label' +
|
793 |
// For
|
825 |
// For
|
794 |
listHtml.optionLabel.labelForAttr +
|
826 |
listFieldsHtml.forAttr +
|
795 |
// value-id
|
827 |
// value-id
|
796 |
listHtml.optionInput.inputOptionIdAttr +
|
828 |
listFieldsHtml.optionIdAttr +
|
797 |
// Class="nom du champ"
|
829 |
// Class="nom du champ"
|
798 |
listHtml.optionInput.inputClassAttr +
|
830 |
commonFieldsHtml.fieldInput.classAttr +
|
799 |
'>' +
|
831 |
'>' +
|
800 |
'<input' +
|
832 |
'<input' +
|
801 |
// Type
|
833 |
// Type
|
- |
|
834 |
commonFieldsHtml.fieldInput.typeAttr +
|
- |
|
835 |
// Id
|
802 |
listHtml.optionInput.inputTypeAttr +
|
836 |
listFieldsHtml.inputIdAttr +
|
803 |
// DataId
|
837 |
// DataId
|
804 |
constHtml.fieldDataIdAttr +
|
838 |
commonFieldsHtml.dataIdAttr +
|
805 |
// value-id
|
839 |
// value-id
|
806 |
listHtml.optionInput.inputOptionIdAttr +
|
840 |
listFieldsHtml.optionIdAttr +
|
807 |
// Name
|
841 |
// Name
|
808 |
listHtml.optionInput.inputNameAttr +
|
842 |
commonFieldsHtml.fieldInput.nameAttr +
|
809 |
// Value
|
843 |
// Value
|
810 |
' value="' + fieldOption.optionValue + '"' +
|
844 |
' value="' + fieldOption.optionValue + '"' +
|
811 |
// Checked
|
845 |
// Checked
|
812 |
listHtml.optionInput.inputDefaultAttr +
|
846 |
listFieldsHtml.defaultAttr +
|
813 |
// Class="nom du champ"
|
847 |
// Class="nom du champ"
|
814 |
listHtml.optionInput.inputClassAttr +
|
848 |
commonFieldsHtml.fieldInput.classAttr +
|
815 |
'>' +
|
849 |
'>' +
|
816 |
// Label de l'option
|
850 |
// Label de l'option
|
817 |
fieldOption.optionText +
|
851 |
fieldOption.optionText +
|
818 |
'</label>';
|
852 |
'</label>';
|
819 |
|
- |
|
820 |
// Si valeur "autre" est cochée
|
853 |
// Si valeur "autre" est cochée
|
821 |
if( fieldOtherValue ) {
|
854 |
if( fieldOtherValue ) {
|
822 |
fieldHtml +=
|
855 |
fieldHtml +=
|
823 |
'<label for="other"' +
|
856 |
'<label for="other"' +
|
824 |
constHtml.fieldDataIdAttr +
|
857 |
commonFieldsHtml.dataIdAttr +
|
825 |
'>' +
|
858 |
'>' +
|
826 |
'<input' +
|
859 |
'<input' +
|
827 |
listHtml.optionInput.inputTypeAttr +
|
860 |
commonFieldsHtml.fieldInput.typeAttr +
|
828 |
' id="other"' +
|
861 |
' id="other"' +
|
829 |
listHtml.optionInput.inputNameAttr +
|
862 |
commonFieldsHtml.fieldInput.nameAttr +
|
830 |
' value="other"' +
|
863 |
' value="other"' +
|
831 |
listHtml.optionInput.inputClassAttr +
|
864 |
commonFieldsHtml.fieldInput.classAttr +
|
832 |
constHtml.fieldDataIdAttr +
|
865 |
commonFieldsHtml.dataIdAttr +
|
833 |
'>' +
|
866 |
'>' +
|
834 |
'Autre</label>';
|
867 |
'Autre</label>';
|
835 |
}
|
868 |
}
|
836 |
}
|
869 |
}
|
837 |
// Fin du conteneur
|
870 |
// Fin du conteneur
|
838 |
fieldHtml += '</div>';
|
871 |
fieldHtml += '</div>';
|
839 |
|
- |
|
840 |
break;
|
872 |
break;
|
841 |
|
873 |
|
842 |
case 'list-checkbox':
|
874 |
case 'list-checkbox':
|
843 |
fieldHtml =
|
875 |
fieldHtml =
|
- |
|
876 |
// Classe 'and-help'
|
844 |
'<div class="multiselect ' + fieldElement + fieldHelpClass + '"' +
|
877 |
'<div class="multiselect ' + fieldElement + commonFieldsHtml.helpClass + '"' +
|
845 |
// DataId
|
878 |
// DataId
|
846 |
constHtml.fieldDataIdAttr +
|
879 |
commonFieldsHtml.dataIdAttr +
|
847 |
'>' +
|
880 |
'>' +
|
848 |
'<label>' +
|
881 |
'<label>' +
|
849 |
// Nom du champ
|
882 |
// Nom du champ
|
850 |
constHtml.fieldContainerContent +
|
883 |
listFieldsHtml.containerContent +
|
851 |
'</label>' +
|
884 |
'</label>' +
|
852 |
'<div class="selectBox"' +
|
885 |
'<div class="selectBox"' +
|
853 |
// DataId
|
886 |
// DataId
|
854 |
constHtml.fieldDataIdAttr +
|
887 |
commonFieldsHtml.dataIdAttr +
|
855 |
'>' +
|
888 |
'>' +
|
856 |
|
- |
|
857 |
'<select' +
|
889 |
'<select' +
|
858 |
// DataId
|
890 |
// DataId
|
859 |
constHtml.fieldDataIdAttr +
|
891 |
commonFieldsHtml.dataIdAttr +
|
860 |
// Required
|
892 |
// Required
|
861 |
constHtml.fieldMandatoryAttr +
|
893 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
862 |
// Info bulle
|
894 |
// Info bulle
|
863 |
constHtml.fieldTitleAttr +
|
895 |
commonFieldsHtml.titleAttr +
|
864 |
'>' +
|
896 |
'>' +
|
865 |
// Apparait dans la barre de sélection
|
897 |
// Apparait dans la barre de sélection
|
866 |
'<option>Plusieurs choix possibles</option>' +
|
898 |
'<option>Plusieurs choix possibles</option>' +
|
867 |
'</select>' +
|
899 |
'</select>' +
|
868 |
'<div class="overSelect"></div>' +
|
900 |
'<div class="overSelect"></div>' +
|
869 |
'</div>' +
|
901 |
'</div>' +
|
870 |
'<div class="checkboxes hidden"' +
|
902 |
'<div class="checkboxes hidden"' +
|
871 |
// DataId
|
903 |
// DataId
|
872 |
constHtml.fieldDataIdAttr +
|
904 |
commonFieldsHtml.dataIdAttr +
|
873 |
'>';
|
905 |
'>';
|
874 |
// On déroule les différentes valeurs
|
906 |
// On déroule les différentes valeurs
|
875 |
for ( let i = 0; i < count; i++ ) {
|
907 |
for( let i = 0; i < count; i++ ) {
|
876 |
let fieldOption = fieldOptions[i];
|
908 |
let fieldOption = fieldOptions[i];
|
877 |
|
- |
|
- |
|
909 |
// Type="checkbox"
|
878 |
listHtml.optionInput.inputTypeAttr = ' type="checkbox"';
|
910 |
commonFieldsHtml.fieldInput.typeAttr = ' type="checkbox"';
|
- |
|
911 |
// Id
|
879 |
listHtml.optionInput.inputIdAttr = ' id="' + fieldOption.optionValue.toLowerCase() + '"';
|
912 |
listFieldsHtml.inputIdAttr = ' id="' + fieldOption.optionValue.toLowerCase() + '"';
|
- |
|
913 |
// For
|
880 |
listHtml.optionLabel.labelForAttr = ' for="' + fieldOption.optionValue.toLowerCase() + '"';
|
914 |
listFieldsHtml.forAttr = ' for="' + fieldOption.optionValue.toLowerCase() + '"';
|
- |
|
915 |
// Default
|
881 |
listHtml.optionInput.inputDefaultAttr = '';
|
916 |
listFieldsHtml.defaultAttr = '';//réinitialisation
|
882 |
|
- |
|
883 |
if( fieldOption.isDefault ) {
|
917 |
if( fieldOption.isDefault ) {
|
884 |
listHtml.optionInput.inputDefaultAttr = ' checked';
|
918 |
listFieldsHtml.defaultAttr = ' checked';//affectation
|
885 |
}
|
919 |
}
|
886 |
|
- |
|
- |
|
920 |
// value-id
|
887 |
if( '' !== fieldOption.optionIndex ) {
|
921 |
if( '' !== fieldOption.optionIndex ) {
|
888 |
listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
922 |
listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
889 |
}
|
923 |
}
|
890 |
|
924 |
|
891 |
fieldHtml +=
|
925 |
fieldHtml +=
|
892 |
|
- |
|
893 |
'<label' +
|
926 |
'<label' +
|
- |
|
927 |
// For
|
894 |
listHtml.optionLabel.labelForAttr +
|
928 |
listFieldsHtml.forAttr +
|
895 |
// value-id
|
929 |
// value-id
|
896 |
listHtml.optionInput.inputOptionIdAttr +
|
930 |
listFieldsHtml.optionIdAttr +
|
897 |
'>' +
|
931 |
'>' +
|
898 |
|
- |
|
899 |
'<input type="checkbox"' +
|
932 |
'<input type="checkbox"' +
|
- |
|
933 |
// Id
|
- |
|
934 |
listFieldsHtml.inputIdAttr +
|
900 |
// value-id
|
935 |
// value-id
|
901 |
listHtml.optionInput.inputOptionIdAttr +
|
936 |
listFieldsHtml.optionIdAttr +
|
902 |
// Name
|
937 |
// Name
|
903 |
listHtml.optionInput.inputNameAttr +
|
938 |
commonFieldsHtml.fieldInput.nameAttr +
|
904 |
// Value
|
939 |
// Value
|
905 |
' value="' + fieldOption.optionValue + '"' +
|
940 |
' value="' + fieldOption.optionValue + '"' +
|
906 |
// Checked
|
941 |
// Checked
|
907 |
listHtml.optionInput.inputDefaultAttr +
|
942 |
listFieldsHtml.defaultAttr +
|
908 |
// Class="nom du champ"
|
943 |
// Class="nom du champ"
|
909 |
listHtml.optionInput.inputClassAttr +
|
944 |
commonFieldsHtml.fieldInput.classAttr +
|
910 |
// DataId
|
945 |
// DataId
|
911 |
constHtml.fieldDataIdAttr +
|
946 |
commonFieldsHtml.dataIdAttr +
|
912 |
'>' +
|
947 |
'>' +
|
913 |
// Label de l'option
|
948 |
// Label de l'option
|
914 |
fieldOption.optionText +
|
949 |
fieldOption.optionText +
|
915 |
'</label>';
|
950 |
'</label>';
|
916 |
}
|
951 |
}
|
917 |
|
- |
|
918 |
// Si valeur "autre" est cochée
|
952 |
// Si valeur "autre" est cochée
|
919 |
if( fieldOtherValue ) {
|
953 |
if( fieldOtherValue ) {
|
920 |
fieldHtml +=
|
954 |
fieldHtml +=
|
921 |
'<label for="other"' +
|
955 |
'<label for="other"' +
|
922 |
// DataId
|
956 |
// DataId
|
923 |
constHtml.fieldDataIdAttr +
|
957 |
commonFieldsHtml.dataIdAttr +
|
924 |
'>' +
|
958 |
'>' +
|
925 |
'<input type="checkbox"' +
|
959 |
'<input type="checkbox"' +
|
926 |
' id="other"' +
|
960 |
' id="other"' +
|
927 |
listHtml.optionInput.inputNameAttr +
|
961 |
commonFieldsHtml.fieldInput.nameAttr +
|
928 |
' value="other"' +
|
962 |
' value="other"' +
|
929 |
listHtml.optionInput.inputClassAttr +
|
963 |
commonFieldsHtml.fieldInput.classAttr +
|
930 |
// DataId
|
964 |
// DataId
|
931 |
constHtml.fieldDataIdAttr +
|
965 |
commonFieldsHtml.dataIdAttr +
|
932 |
'>' +
|
966 |
'>' +
|
933 |
'Autre</label>';
|
967 |
'Autre</label>';
|
934 |
}
|
968 |
}
|
935 |
|
- |
|
936 |
// Fermeture des conteneurs .multiselect .checkboxes
|
969 |
// Fermeture des conteneurs .multiselect .checkboxes
|
937 |
fieldHtml +=
|
970 |
fieldHtml +=
|
938 |
'</div>'+
|
971 |
'</div>'+
|
939 |
'</div>' +
|
972 |
'</div>' +
|
- |
|
973 |
// Bouton 'help'
|
940 |
fieldHtmlObject.fieldHelpButton;
|
974 |
commonFieldsHtml.helpButton;
|
941 |
|
- |
|
942 |
break;
|
975 |
break;
|
943 |
|
976 |
|
944 |
case 'select':
|
977 |
case 'select':
|
945 |
fieldHtml =
|
978 |
fieldHtml =
|
946 |
'<label' +
|
979 |
'<label' +
|
947 |
' for="' + fieldKey + '"' +
|
980 |
commonFieldsHtml.fieldLabel.forAttr +
|
948 |
// Info bulle
|
981 |
// Info bulle
|
949 |
constHtml.fieldTitleAttr +
|
982 |
commonFieldsHtml.titleAttr +
|
950 |
'>' +
|
983 |
'>' +
|
951 |
// Nom du champ
|
984 |
// Nom du champ
|
952 |
constHtml.fieldContainerContent +
|
985 |
listFieldsHtml.containerContent +
|
953 |
'</label>' +
|
986 |
'</label>' +
|
954 |
// Conteneur/Wrapper
|
987 |
// Conteneur/Wrapper
|
- |
|
988 |
// +Classe 'and-help'
|
955 |
'<div class="select-wrapper add-field-select ' + fieldElement + fieldHelpClass + '"' +
|
989 |
'<div class="select-wrapper add-field-select ' + fieldElement + commonFieldsHtml.helpClass + '"' +
|
- |
|
990 |
// DataID
|
956 |
constHtml.fieldDataIdAttr +
|
991 |
commonFieldsHtml.dataIdAttr +
|
957 |
'>' +
|
992 |
'>' +
|
958 |
'<select' +
|
993 |
'<select' +
|
959 |
' name="' + fieldKey + '"' +
|
994 |
commonFieldsHtml.fieldInput.nameAttr +
|
960 |
' id="' + fieldKey + '"' +
|
995 |
' id="' + fieldKey + '"' +
|
961 |
//Class
|
996 |
// Class
|
962 |
listHtml.optionInput.inputClassAttr +
|
997 |
commonFieldsHtml.fieldInput.classAttr +
|
963 |
// Required
|
998 |
// Required
|
964 |
constHtml.fieldMandatoryAttr +
|
999 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
965 |
// DataId
|
1000 |
// DataId
|
966 |
constHtml.fieldDataIdAttr +
|
1001 |
commonFieldsHtml.dataIdAttr +
|
967 |
'>';
|
1002 |
'>';
|
968 |
|
1003 |
|
969 |
// On déroule les différentes valeurs
|
1004 |
// On déroule les différentes valeurs
|
970 |
for ( let i = 0; i < count; i++ ) {
|
1005 |
for( let i = 0; i < count; i++ ) {
|
971 |
let fieldOption = fieldOptions[i];
|
1006 |
let fieldOption = fieldOptions[i];
|
972 |
|
- |
|
973 |
listHtml.optionInput.inputDefaultAttr = '';
|
1007 |
// Default
|
974 |
listHtml.optionInput.inputdisabledAttr = '';
|
1008 |
listFieldsHtml.defaultAttr = '';//réinitialisation
|
975 |
|
- |
|
976 |
if( fieldOption.isDefault ) {
|
1009 |
if( fieldOption.isDefault ) {//affectation
|
977 |
listHtml.optionInput.inputDefaultAttr = ' selected="selected"';
|
1010 |
listFieldsHtml.defaultAttr = ' selected="selected"';
|
978 |
}
|
1011 |
}
|
979 |
|
- |
|
- |
|
1012 |
// value-id
|
980 |
if( '' !== fieldOption.optionIndex ) {
|
1013 |
if( '' !== fieldOption.optionIndex ) {
|
981 |
listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
1014 |
listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
|
982 |
}
|
1015 |
}
|
983 |
|
1016 |
|
984 |
fieldHtml +=
|
1017 |
fieldHtml +=
|
985 |
'<option' +
|
1018 |
'<option' +
|
986 |
// Value
|
1019 |
// Value
|
987 |
' value="' + fieldOption.optionValue + '"' +
|
1020 |
' value="' + fieldOption.optionValue + '"' +
|
988 |
// Value-id
|
1021 |
// Value-id
|
989 |
listHtml.optionInput.inputOptionIdAttr +
|
1022 |
listFieldsHtml.optionIdAttr +
|
990 |
// Selected
|
1023 |
// Selected
|
991 |
listHtml.optionInput.inputDefaultAttr +
|
1024 |
listFieldsHtml.defaultAttr +
|
992 |
'>' +
|
1025 |
'>' +
|
993 |
// Option
|
1026 |
// Option
|
994 |
fieldOption.optionText +
|
1027 |
fieldOption.optionText +
|
995 |
'</option>';
|
1028 |
'</option>';
|
996 |
}
|
1029 |
}
|
997 |
|
- |
|
998 |
// Si valeur "autre" est cochée
|
1030 |
// Si valeur "autre" est cochée
|
999 |
if( fieldOtherValue ) {
|
1031 |
if( fieldOtherValue ) {
|
1000 |
fieldHtml +=
|
1032 |
fieldHtml +=
|
1001 |
'<option class="other" value="other"' + constHtml.fieldDataIdAttr + '>' +
|
1033 |
'<option class="other" value="other"' + commonFieldsHtml.dataIdAttr + '>' +
|
1002 |
'Autre' +
|
1034 |
'Autre' +
|
1003 |
'</option>';
|
1035 |
'</option>';
|
1004 |
}
|
1036 |
}
|
1005 |
|
- |
|
- |
|
1037 |
// Fermeture des conteneurs
|
1006 |
fieldHtml +=
|
1038 |
fieldHtml +=
|
1007 |
'</select>' +
|
1039 |
'</select>' +
|
1008 |
// Fin du conteneur/wrapper
|
1040 |
// Fin du conteneur/wrapper
|
1009 |
'</div>' +
|
1041 |
'</div>' +
|
1010 |
|
- |
|
- |
|
1042 |
// Bouton 'help'
|
1011 |
fieldHtmlObject.fieldHelpButton;
|
1043 |
commonFieldsHtml.helpButton;
|
1012 |
|
- |
|
1013 |
break;
|
1044 |
break;
|
1014 |
|
1045 |
|
1015 |
case 'file' :
|
1046 |
case 'file' :
|
- |
|
1047 |
// Ouvrir l'attribut class (suppression de '"')
|
1016 |
fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
|
1048 |
commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
|
1017 |
fieldHtmlObject.fieldInput.inputClassAttr += ' input-file"';
|
1049 |
commonFieldsHtml.fieldInput.classAttr += ' input-file"';
|
1018 |
|
- |
|
- |
|
1050 |
// Class du label
|
1019 |
fieldHtmlObject.fieldLabel.labelClassAttr = ' class="label-file"';
|
1051 |
commonFieldsHtml.fieldLabel.classAttr = ' class="label-file"';
|
1020 |
|
- |
|
- |
|
1052 |
// Type de fichiers acceptés
|
1021 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' accept="application/pdf, image/*, video/*"';
|
1053 |
commonFieldsHtml.fieldInput.otherAttr += ' accept="application/pdf, image/*, video/*"';
|
1022 |
|
1054 |
|
- |
|
1055 |
fieldHtml =
|
1023 |
fieldHtml =
|
1056 |
// Classe 'and-help'
|
1024 |
'<div class="input-file-container' + fieldHelpClass + '">' +
|
1057 |
'<div class="input-file-container' + commonFieldsHtml.helpClass + '">' +
|
1025 |
'<input' +
|
1058 |
'<input' +
|
1026 |
// Type
|
1059 |
// Type
|
1027 |
fieldHtmlObject.fieldInput.inputTypeAttr +
|
1060 |
commonFieldsHtml.fieldInput.typeAttr +
|
1028 |
// Name
|
1061 |
// Name
|
1029 |
fieldHtmlObject.fieldInput.inputNameAttr +
|
1062 |
commonFieldsHtml.fieldInput.nameAttr +
|
1030 |
// DataId
|
1063 |
// DataId
|
1031 |
fieldHtmlObject.fieldInput.inputDataIdAttr +
|
1064 |
commonFieldsHtml.dataIdAttr +
|
1032 |
// Class
|
1065 |
// Class
|
1033 |
fieldHtmlObject.fieldInput.inputClassAttr +
|
1066 |
commonFieldsHtml.fieldInput.classAttr +
|
1034 |
// Info-bulle
|
1067 |
// Info-bulle
|
1035 |
fieldHtmlObject.fieldTitleAttr +
|
1068 |
commonFieldsHtml.titleAttr +
|
1036 |
// Placeholder
|
1069 |
// Placeholder
|
- |
|
1070 |
commonFieldsHtml.fieldInput.placeholderAttr +
|
- |
|
1071 |
// Required
|
1037 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr +
|
1072 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
1038 |
// Autres attributs
|
1073 |
// Autres attributs
|
1039 |
fieldHtmlObject.fieldInput.inputOtherAttr +
|
1074 |
commonFieldsHtml.fieldInput.otherAttr +
|
1040 |
'>' +
|
- |
|
1041 |
|
1075 |
'>' +
|
1042 |
'<label' +
|
1076 |
'<label' +
|
1043 |
// For
|
1077 |
// For
|
1044 |
fieldHtmlObject.fieldLabel.labelForAttr +
|
1078 |
commonFieldsHtml.fieldLabel.forAttr +
|
1045 |
// Class
|
1079 |
// Class
|
1046 |
fieldHtmlObject.fieldLabel.labelClassAttr +
|
1080 |
commonFieldsHtml.fieldLabel.classAttr +
|
1047 |
// Info-bulle
|
1081 |
// Info-bulle
|
1048 |
fieldHtmlObject.fieldTitleAttr +
|
1082 |
commonFieldsHtml.titleAttr +
|
1049 |
'><i class="fas fa-download"></i> ' +
|
1083 |
'><i class="fas fa-download"></i> ' +
|
1050 |
// Nom du champ
|
1084 |
// Nom du champ
|
1051 |
fieldHtmlObject.fieldLabel.labelContent +
|
1085 |
commonFieldsHtml.fieldLabel.labelContent +
|
1052 |
'</label>' +
|
- |
|
1053 |
|
1086 |
'</label>' +
|
1054 |
'</div>' +
|
- |
|
- |
|
1087 |
'</div>' +
|
1055 |
|
1088 |
// Bouton supprimer le fichier
|
1056 |
'<div class="remove-file button" name="remove-file" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>' +
|
- |
|
- |
|
1089 |
'<div class="remove-file button" name="remove-file" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>' +
|
1057 |
|
1090 |
// Bouton 'help'
|
1058 |
fieldHtmlObject.fieldHelpButton;
|
- |
|
1059 |
|
1091 |
commonFieldsHtml.helpButton;
|
1060 |
break;
|
1092 |
break;
|
1061 |
|
1093 |
|
1062 |
case 'textarea':
|
1094 |
case 'textarea':
|
- |
|
1095 |
// Classe 'and-help'
|
1063 |
fieldHtmlObject.fieldLabel.labelClassAttr = ' class="' + fieldHelpClass + '"';
|
1096 |
commonFieldsHtml.fieldLabel.classAttr = ' class="' + commonFieldsHtml.helpClass + '"';
|
1064 |
// Autres attributs
|
1097 |
// Autres attributs
|
1065 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' id="' + fieldKey + '"';
|
1098 |
commonFieldsHtml.fieldInput.otherAttr += ' id="' + fieldKey + '"';
|
1066 |
|
1099 |
|
1067 |
fieldHtml =
|
1100 |
fieldHtml =
|
1068 |
'<label' +
|
1101 |
'<label' +
|
1069 |
// For
|
1102 |
// For
|
1070 |
fieldHtmlObject.fieldLabel.labelForAttr +
|
1103 |
commonFieldsHtml.fieldLabel.forAttr +
|
1071 |
// Class
|
1104 |
// Class
|
1072 |
fieldHtmlObject.fieldLabel.labelClassAttr +
|
1105 |
commonFieldsHtml.fieldLabel.classAttr +
|
1073 |
// Info-bulle
|
1106 |
// Info-bulle
|
1074 |
fieldHtmlObject.fieldTitleAttr +
|
1107 |
commonFieldsHtml.titleAttr +
|
1075 |
// Autres attributs
|
1108 |
// Autres attributs
|
1076 |
fieldHtmlObject.fieldLabel.labelOtherAttr +
|
1109 |
commonFieldsHtml.fieldLabel.otherAttr +
|
1077 |
'>' +
|
1110 |
'>' +
|
1078 |
// Nom du champ
|
1111 |
// Nom du champ
|
1079 |
fieldHtmlObject.fieldLabel.labelContent +
|
1112 |
commonFieldsHtml.fieldLabel.labelContent +
|
1080 |
'</label>' +
|
1113 |
'</label>' +
|
1081 |
|
- |
|
- |
|
1114 |
// Bouton 'help'
|
1082 |
fieldHtmlObject.fieldHelpButton +
|
1115 |
commonFieldsHtml.helpButton +
|
1083 |
|
- |
|
1084 |
'<textarea' +
|
1116 |
'<textarea' +
|
1085 |
// Name
|
1117 |
// Name
|
1086 |
fieldHtmlObject.fieldInput.inputNameAttr +
|
1118 |
commonFieldsHtml.fieldInput.nameAttr +
|
1087 |
// DataId
|
1119 |
// DataId
|
1088 |
fieldHtmlObject.fieldInput.inputDataIdAttr +
|
1120 |
commonFieldsHtml.dataIdAttr +
|
1089 |
// Class
|
1121 |
// Class
|
1090 |
fieldHtmlObject.fieldInput.inputClassAttr +
|
1122 |
commonFieldsHtml.fieldInput.classAttr +
|
1091 |
// Info-bulle
|
1123 |
// Info-bulle
|
1092 |
fieldHtmlObject.fieldTitleAttr +
|
1124 |
commonFieldsHtml.titleAttr +
|
1093 |
// Info-bulle
|
1125 |
// Info-bulle
|
1094 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr +
|
1126 |
commonFieldsHtml.fieldInput.placeholderAttr +
|
- |
|
1127 |
// Required
|
- |
|
1128 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
1095 |
// Autres attributs
|
1129 |
// Autres attributs
|
1096 |
fieldHtmlObject.fieldInput.inputOtherAttr +
|
1130 |
commonFieldsHtml.fieldInput.otherAttr +
|
1097 |
'></textarea>';
|
1131 |
'></textarea>';
|
1098 |
|
- |
|
1099 |
break;
|
1132 |
break;
|
1100 |
|
1133 |
|
1101 |
case 'range':
|
1134 |
case 'range':
|
- |
|
1135 |
// Classe 'and-help'
|
1102 |
fieldHtmlObject.fieldLabel.labelClassAttr = ' class="' + fieldHelpClass + '"';
|
1136 |
commonFieldsHtml.fieldLabel.classAttr = ' class="' + commonFieldsHtml.helpClass + '"';
|
1103 |
|
1137 |
// Step
|
1104 |
if( '' !== fieldStep ) {
|
1138 |
if( '' !== fieldStep ) {
|
1105 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' step="' + fieldStep + '"';
|
1139 |
commonFieldsHtml.fieldInput.otherAttr += ' step="' + fieldStep + '"';
|
1106 |
}
|
1140 |
}
|
1107 |
|
1141 |
// Min
|
1108 |
if( '' !== fieldMin ) {
|
1142 |
if( '' !== fieldMin ) {
|
1109 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' min="' + fieldMin + '"';
|
1143 |
commonFieldsHtml.fieldInput.otherAttr += ' min="' + fieldMin + '"';
|
1110 |
}
|
1144 |
}
|
1111 |
|
1145 |
//Max
|
1112 |
if( '' !== fieldMax ) {
|
1146 |
if( '' !== fieldMax ) {
|
1113 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' max="' + fieldMax + '"';
|
1147 |
commonFieldsHtml.fieldInput.otherAttr += ' max="' + fieldMax + '"';
|
1114 |
}
|
1148 |
}
|
1115 |
|
1149 |
|
1116 |
fieldHtml =
|
1150 |
fieldHtml =
|
1117 |
'<div class="number">' +
|
1151 |
'<div class="number">' +
|
1118 |
'<label' +
|
1152 |
'<label' +
|
1119 |
// For
|
1153 |
// For
|
1120 |
fieldHtmlObject.fieldLabel.labelForAttr +
|
1154 |
commonFieldsHtml.fieldLabel.forAttr +
|
1121 |
// Class
|
1155 |
// Class
|
1122 |
fieldHtmlObject.fieldLabel.labelClassAttr +
|
1156 |
commonFieldsHtml.fieldLabel.classAttr +
|
1123 |
// Info-bulle
|
1157 |
// Info-bulle
|
1124 |
fieldHtmlObject.fieldTitleAttr +
|
1158 |
commonFieldsHtml.titleAttr +
|
1125 |
// Autres attributs
|
1159 |
// Autres attributs
|
1126 |
fieldHtmlObject.fieldLabel.labelOtherAttr +
|
1160 |
commonFieldsHtml.fieldLabel.otherAttr +
|
1127 |
'>' +
|
1161 |
'>' +
|
1128 |
// Nom du champ
|
1162 |
// Nom du champ
|
1129 |
fieldHtmlObject.fieldLabel.labelContent +
|
1163 |
commonFieldsHtml.fieldLabel.labelContent +
|
1130 |
'</label>' +
|
1164 |
'</label>' +
|
1131 |
|
- |
|
- |
|
1165 |
// Bouton 'help'
|
1132 |
fieldHtmlObject.fieldHelpButton +
|
1166 |
commonFieldsHtml.helpButton +
|
1133 |
|
1167 |
|
1134 |
'<input' +
|
1168 |
'<input' +
|
1135 |
// Type
|
1169 |
// Type
|
1136 |
fieldHtmlObject.fieldInput.inputTypeAttr +
|
1170 |
commonFieldsHtml.fieldInput.typeAttr +
|
1137 |
// Name
|
1171 |
// Name
|
1138 |
fieldHtmlObject.fieldInput.inputNameAttr +
|
1172 |
commonFieldsHtml.fieldInput.nameAttr +
|
1139 |
// DataId
|
1173 |
// DataId
|
1140 |
fieldHtmlObject.fieldInput.inputDataIdAttr +
|
1174 |
commonFieldsHtml.dataIdAttr +
|
1141 |
// Class
|
1175 |
// Class
|
1142 |
fieldHtmlObject.fieldInput.inputClassAttr +
|
1176 |
commonFieldsHtml.fieldInput.classAttr +
|
1143 |
// Info-bulle
|
1177 |
// Info-bulle
|
1144 |
fieldHtmlObject.fieldTitleAttr +
|
1178 |
commonFieldsHtml.titleAttr +
|
1145 |
// Info-bulle
|
1179 |
// Info-bulle
|
1146 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr +
|
1180 |
commonFieldsHtml.fieldInput.placeholderAttr +
|
- |
|
1181 |
// Required
|
- |
|
1182 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
1147 |
// Autres attributs
|
1183 |
// Autres attributs
|
1148 |
fieldHtmlObject.fieldInput.inputOtherAttr +
|
1184 |
commonFieldsHtml.fieldInput.otherAttr +
|
1149 |
'>' +
|
1185 |
'>' +
|
1150 |
|
- |
|
1151 |
'</div>';
|
1186 |
'</div>';
|
1152 |
|
- |
|
1153 |
break;
|
1187 |
break;
|
1154 |
|
1188 |
|
1155 |
case 'date':
|
1189 |
case 'date':
|
1156 |
case 'number':
|
1190 |
case 'number':
|
- |
|
1191 |
// Ouvrir l'attribut class (suppression de '"')
|
1157 |
fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
|
1192 |
commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
|
- |
|
1193 |
// Classe 'and-help'
|
1158 |
fieldHtmlObject.fieldInput.inputClassAttr += fieldHelpClass + '"';
|
1194 |
commonFieldsHtml.fieldInput.classAttr += commonFieldsHtml.helpClass + '"';
|
1159 |
|
1195 |
// Step
|
1160 |
if( '' !== fieldStep ) {
|
1196 |
if( '' !== fieldStep ) {
|
1161 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' step="' + fieldStep + '"';
|
1197 |
commonFieldsHtml.fieldInput.otherAttr += ' step="' + fieldStep + '"';
|
1162 |
}
|
1198 |
}
|
1163 |
|
1199 |
// Min
|
1164 |
if( '' !== fieldMin ) {
|
1200 |
if( '' !== fieldMin ) {
|
1165 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' min="' + fieldMin + '"';
|
1201 |
commonFieldsHtml.fieldInput.otherAttr += ' min="' + fieldMin + '"';
|
1166 |
}
|
1202 |
}
|
1167 |
|
1203 |
// Max
|
1168 |
if( '' !== fieldMax ) {
|
1204 |
if( '' !== fieldMax ) {
|
1169 |
fieldHtmlObject.fieldInput.inputOtherAttr += ' max="' + fieldMax + '"';
|
1205 |
commonFieldsHtml.fieldInput.otherAttr += ' max="' + fieldMax + '"';
|
1170 |
}
|
1206 |
}
|
1171 |
|
- |
|
1172 |
fieldHtml =
|
1207 |
fieldHtml =
|
1173 |
'<div class="number">' +
|
1208 |
'<div class="number">' +
|
1174 |
'<label' +
|
1209 |
'<label' +
|
1175 |
// For
|
1210 |
// For
|
1176 |
fieldHtmlObject.fieldLabel.labelForAttr +
|
1211 |
commonFieldsHtml.fieldLabel.forAttr +
|
1177 |
// Class
|
1212 |
// Class
|
1178 |
fieldHtmlObject.fieldLabel.labelClassAttr +
|
1213 |
commonFieldsHtml.fieldLabel.classAttr +
|
1179 |
// Info-bulle
|
1214 |
// Info-bulle
|
1180 |
fieldHtmlObject.fieldTitleAttr +
|
1215 |
commonFieldsHtml.titleAttr +
|
1181 |
// Autres attributs
|
1216 |
// Autres attributs
|
1182 |
fieldHtmlObject.fieldLabel.labelOtherAttr +
|
1217 |
commonFieldsHtml.fieldLabel.otherAttr +
|
1183 |
'>' +
|
1218 |
'>' +
|
1184 |
// Nom du champ
|
1219 |
// Nom du champ
|
1185 |
fieldHtmlObject.fieldLabel.labelContent +
|
1220 |
commonFieldsHtml.fieldLabel.labelContent +
|
1186 |
'</label>' +
|
1221 |
'</label>' +
|
1187 |
|
- |
|
1188 |
'<input' +
|
1222 |
'<input' +
|
1189 |
// Type
|
1223 |
// Type
|
1190 |
fieldHtmlObject.fieldInput.inputTypeAttr +
|
1224 |
commonFieldsHtml.fieldInput.typeAttr +
|
1191 |
// Name
|
1225 |
// Name
|
1192 |
fieldHtmlObject.fieldInput.inputNameAttr +
|
1226 |
commonFieldsHtml.fieldInput.nameAttr +
|
1193 |
// DataId
|
1227 |
// DataId
|
1194 |
fieldHtmlObject.fieldInput.inputDataIdAttr +
|
1228 |
commonFieldsHtml.dataIdAttr +
|
1195 |
// Class
|
1229 |
// Class
|
1196 |
fieldHtmlObject.fieldInput.inputClassAttr +
|
1230 |
commonFieldsHtml.fieldInput.classAttr +
|
1197 |
// Info-bulle
|
1231 |
// Info-bulle
|
1198 |
fieldHtmlObject.fieldTitleAttr +
|
1232 |
commonFieldsHtml.titleAttr +
|
1199 |
// Info-bulle
|
1233 |
// Info-bulle
|
1200 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr +
|
1234 |
commonFieldsHtml.fieldInput.placeholderAttr +
|
- |
|
1235 |
// Required
|
- |
|
1236 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
1201 |
// Autres attributs
|
1237 |
// Autres attributs
|
1202 |
fieldHtmlObject.fieldInput.inputOtherAttr +
|
1238 |
commonFieldsHtml.fieldInput.otherAttr +
|
1203 |
'>' +
|
1239 |
'>' +
|
1204 |
|
- |
|
- |
|
1240 |
// Bouton 'help'
|
1205 |
fieldHtmlObject.fieldHelpButton +
|
1241 |
commonFieldsHtml.helpButton +
|
1206 |
|
- |
|
1207 |
'</div>';
|
1242 |
'</div>';
|
1208 |
|
- |
|
1209 |
break;
|
1243 |
break;
|
1210 |
|
1244 |
|
1211 |
case 'text' :
|
1245 |
case 'text' :
|
1212 |
case 'email':
|
1246 |
case 'email':
|
1213 |
default:
|
1247 |
default:
|
- |
|
1248 |
// Ouvrir l'attribut class (suppression de '"')
|
1214 |
fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
|
1249 |
commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
|
- |
|
1250 |
// Classe 'and-help'
|
1215 |
fieldHtmlObject.fieldInput.inputClassAttr += fieldHelpClass + '"';
|
1251 |
commonFieldsHtml.fieldInput.classAttr += commonFieldsHtml.helpClass + '"';
|
1216 |
|
1252 |
|
1217 |
fieldHtml =
|
1253 |
fieldHtml =
|
1218 |
'<label' +
|
1254 |
'<label' +
|
1219 |
// For
|
1255 |
// For
|
1220 |
fieldHtmlObject.fieldLabel.labelForAttr +
|
1256 |
commonFieldsHtml.fieldLabel.forAttr +
|
1221 |
// Class
|
1257 |
// Class
|
1222 |
fieldHtmlObject.fieldLabel.labelClassAttr +
|
1258 |
commonFieldsHtml.fieldLabel.classAttr +
|
1223 |
// Info-bulle
|
1259 |
// Info-bulle
|
1224 |
fieldHtmlObject.fieldTitleAttr +
|
1260 |
commonFieldsHtml.titleAttr +
|
1225 |
// Autres attributs
|
1261 |
// Autres attributs
|
1226 |
fieldHtmlObject.fieldLabel.labelOtherAttr +
|
1262 |
commonFieldsHtml.fieldLabel.otherAttr +
|
1227 |
'>' +
|
1263 |
'>' +
|
1228 |
// Nom du champ
|
1264 |
// Nom du champ
|
1229 |
fieldHtmlObject.fieldLabel.labelContent +
|
1265 |
commonFieldsHtml.fieldLabel.labelContent +
|
1230 |
'</label>' +
|
1266 |
'</label>' +
|
1231 |
|
- |
|
1232 |
'<input' +
|
1267 |
'<input' +
|
1233 |
// Type
|
1268 |
// Type
|
1234 |
fieldHtmlObject.fieldInput.inputTypeAttr +
|
1269 |
commonFieldsHtml.fieldInput.typeAttr +
|
1235 |
// Name
|
1270 |
// Name
|
1236 |
fieldHtmlObject.fieldInput.inputNameAttr +
|
1271 |
commonFieldsHtml.fieldInput.nameAttr +
|
1237 |
// DataId
|
1272 |
// DataId
|
1238 |
fieldHtmlObject.fieldInput.inputDataIdAttr +
|
1273 |
commonFieldsHtml.dataIdAttr +
|
1239 |
// Class
|
1274 |
// Class
|
1240 |
fieldHtmlObject.fieldInput.inputClassAttr +
|
1275 |
commonFieldsHtml.fieldInput.classAttr +
|
1241 |
// Info-bulle
|
1276 |
// Info-bulle
|
1242 |
fieldHtmlObject.fieldTitleAttr +
|
1277 |
commonFieldsHtml.titleAttr +
|
1243 |
// Info-bulle
|
1278 |
// Info-bulle
|
1244 |
fieldHtmlObject.fieldInput.inputPlaceholderAttr +
|
1279 |
commonFieldsHtml.fieldInput.placeholderAttr +
|
- |
|
1280 |
// Required
|
- |
|
1281 |
commonFieldsHtml.fieldInput.mandatoryAttr +
|
1245 |
// Autres attributs
|
1282 |
// Autres attributs
|
1246 |
fieldHtmlObject.fieldInput.inputOtherAttr +
|
1283 |
commonFieldsHtml.fieldInput.otherAttr +
|
1247 |
'>' +
|
1284 |
'>' +
|
1248 |
|
- |
|
- |
|
1285 |
// Bouton 'help'
|
1249 |
fieldHtmlObject.fieldHelpButton;
|
1286 |
commonFieldsHtml.helpButton;
|
1250 |
|
- |
|
1251 |
break;
|
1287 |
break;
|
1252 |
}
|
1288 |
}
|
1253 |
|
- |
|
1254 |
return fieldHtml;
|
1289 |
return fieldHtml;
|
1255 |
}
|
1290 |
}
|
1256 |
|
1291 |
|
1257 |
// Construire un tableau des options pour chaque élément de listes
|
1292 |
// Construire un tableau des options pour chaque élément de listes
|
1258 |
function collectListOptions( thisFieldset ) {
|
1293 |
function collectListOptions( thisFieldset ) {
|
1259 |
var $details = $( '.field-details' , thisFieldset ),
|
1294 |
var $details = $( '.field-details' , thisFieldset ),
|
1260 |
options = [];
|
1295 |
options = [];
|
1261 |
|
1296 |
|
1262 |
$details.find( '.new-value' ).each( function() {
|
1297 |
$details.find( '.new-value' ).each( function() {
|
1263 |
|
- |
|
1264 |
options.push({
|
1298 |
options.push({
|
1265 |
// Valeur transmise (value)
|
1299 |
// Valeur transmise (value)
|
1266 |
optionValue : $( this ).find('.list-value').val().toLowerCase(),
|
1300 |
optionValue : $( this ).find('.list-value').val().toLowerCase(),
|
1267 |
// Valeur Visible
|
1301 |
// Valeur Visible
|
1268 |
optionText : capitalize( $( this ).find('.list-value').val() ),
|
1302 |
optionText : capitalize( $( this ).find('.list-value').val() ),
|
1269 |
// Booléen "default"
|
1303 |
// Booléen "default"
|
1270 |
isDefault : $( this ).find( '.is-defaut-value').is( ':checked' ),
|
1304 |
isDefault : $( this ).find( '.is-defaut-value').is( ':checked' ),
|
1271 |
// Indice de l'option
|
1305 |
// Indice de l'option
|
1272 |
optionIndex : $( this ).attr('data-list-value-id')
|
1306 |
optionIndex : $( this ).attr('data-list-value-id')
|
1273 |
});
|
1307 |
});
|
1274 |
|
- |
|
1275 |
});
|
1308 |
});
|
1276 |
return options;
|
1309 |
return options;
|
1277 |
}
|
1310 |
}
|
1278 |
|
1311 |
|
1279 |
// Faire apparaitre un champ text "Autre"
|
1312 |
// Faire apparaitre un champ text "Autre"
|
1280 |
function onOtherOption( thisFieldset , index ) {
|
1313 |
function onOtherOption( thisFieldset , index ) {
|
- |
|
1314 |
// Ce champ (dans la prévisualisation)
|
- |
|
1315 |
var thisPreviewFieldset = $( '.preview-fields[data-id="' + index + '"]'),
|
1281 |
//L'élément choisi
|
1316 |
//L'élément choisi
|
1282 |
var element = $('.field-element' , thisFieldset ).val(),
|
1317 |
element = $('.field-element' , thisFieldset ).val(),
|
1283 |
// Où insérer le champ "Autre"
|
1318 |
// Où insérer le champ "Autre"
|
1284 |
$element = $( '.' + element , thisFieldset ),
|
1319 |
$element = $( '.' + element , thisPreviewFieldset ),
|
1285 |
// html du champ "Autre"
|
1320 |
// html du champ "Autre"
|
1286 |
collectOther =
|
1321 |
collectOther =
|
1287 |
'<label data-id="' + index + '" for="collect-other">Autre option :</label>' +
|
1322 |
'<label data-id="' + index + '" for="collect-other">Autre option :</label>' +
|
1288 |
'<input type="text" name="collect-other" data-id="' + index + '" class="collect-other" >';
|
1323 |
'<input type="text" name="collect-other" data-id="' + index + '" class="collect-other" >';
|
1289 |
|
- |
|
1290 |
// Pouvoir supprimer le champ "Autre"
|
1324 |
// Pouvoir supprimer le champ "Autre"
|
1291 |
function optionRemove( thisFieldset ) {
|
1325 |
function optionRemove( thisPreviewFieldset ) {
|
1292 |
$( 'label[for="collect-other"]' , thisFieldset ).remove();
|
1326 |
$( 'label[for="collect-other"]' , thisPreviewFieldset ).remove();
|
1293 |
$( 'input.collect-other' , thisFieldset ).remove();
|
1327 |
$( 'input.collect-other' , thisPreviewFieldset ).remove();
|
1294 |
}
|
1328 |
}
|
1295 |
|
1329 |
|
1296 |
switch( element ) {
|
1330 |
switch( element ) {
|
1297 |
case 'radio' :
|
1331 |
case 'radio' :
|
1298 |
// Lorsqu'un nouveau bouton est coché
|
1332 |
// Lorsqu'un nouveau bouton est coché
|
1299 |
$( 'input' , thisFieldset ).on( 'change' , function () {
|
1333 |
$( 'input' , thisPreviewFieldset ).on( 'change' , function () {
|
- |
|
1334 |
console.log($( this ));
|
1300 |
if( 'other' === $( this ).val() ) {
|
1335 |
if( 'other' === $( this ).val() ) {
|
1301 |
// Insertion du champ "Autre" après les boutons
|
1336 |
// Insertion du champ "Autre" après les boutons
|
1302 |
$element.after( collectOther );
|
1337 |
$element.after( collectOther );
|
1303 |
} else {
|
1338 |
} else {
|
1304 |
// Suppression du champ autre
|
1339 |
// Suppression du champ autre
|
1305 |
optionRemove( thisFieldset );
|
1340 |
optionRemove( thisPreviewFieldset );
|
1306 |
}
|
1341 |
}
|
1307 |
});
|
1342 |
});
|
1308 |
|
- |
|
1309 |
break;
|
1343 |
break;
|
1310 |
|
1344 |
|
1311 |
case 'select' :
|
1345 |
case 'select' :
|
1312 |
// Lorsque l'option "Autre" est selectionnée
|
1346 |
// Lorsque l'option "Autre" est selectionnée
|
1313 |
$( 'select' , thisFieldset ).on( 'change' , function () {
|
1347 |
$( 'select' , thisPreviewFieldset ).on( 'change' , function () {
|
1314 |
if( 'other' === $( this).val() ) {
|
1348 |
if( 'other' === $( this).val() ) {
|
1315 |
// Insertion du champ "Autre" après les boutons
|
1349 |
// Insertion du champ "Autre" après les boutons
|
1316 |
$element.after( collectOther );
|
1350 |
$element.after( collectOther );
|
1317 |
// Suppression du champ autre
|
1351 |
// Suppression du champ autre
|
1318 |
} else {
|
1352 |
} else {
|
1319 |
optionRemove( thisFieldset );
|
1353 |
optionRemove( thisPreviewFieldset );
|
1320 |
}
|
1354 |
}
|
1321 |
});
|
1355 |
});
|
1322 |
|
- |
|
1323 |
break;
|
1356 |
break;
|
1324 |
|
1357 |
|
1325 |
case 'checkbox' :
|
1358 |
case 'checkbox' :
|
1326 |
case 'list-checkbox' :
|
1359 |
case 'list-checkbox' :
|
1327 |
// Lorsque "Autre" est coché
|
1360 |
// Lorsque "Autre" est coché
|
1328 |
$( 'input#other' , thisFieldset ).on( 'click' , function () {
|
1361 |
$( 'input#other' , thisPreviewFieldset ).on( 'click' , function () {
|
1329 |
// Insertion du champ "Autre" après les boutons
|
1362 |
// Insertion du champ "Autre" après les boutons
|
1330 |
if( $( this ).is( ':checked' ) ) {
|
1363 |
if( $( this ).is( ':checked' ) ) {
|
1331 |
$element.after( collectOther );
|
1364 |
$element.after( collectOther );
|
1332 |
} else {
|
1365 |
} else {
|
1333 |
// Suppression du champ autre
|
1366 |
// Suppression du champ autre
|
1334 |
optionRemove( thisFieldset );
|
1367 |
optionRemove( thisPreviewFieldset );
|
1335 |
}
|
1368 |
}
|
1336 |
});
|
1369 |
});
|
1337 |
|
- |
|
1338 |
break;
|
1370 |
break;
|
1339 |
|
1371 |
|
1340 |
default :
|
1372 |
default :
|
1341 |
break;
|
1373 |
break;
|
1342 |
}
|
1374 |
}
|
1343 |
}
|
1375 |
}
|
1344 |
|
1376 |
|
1345 |
// Prévisualisation des nouveaux champs
|
1377 |
// Prévisualisation des nouveaux champs
|
1346 |
function newFieldsPreview() {
|
1378 |
function newFieldsPreview() {
|
1347 |
var count = $( 'fieldset' ).last().attr('data-id');
|
1379 |
var count = $( 'fieldset' ).last().attr('data-id');
|
1348 |
// Si on a déjà prévisualisé on efface tout pour recommencer
|
1380 |
// Si on a déjà prévisualisé on efface tout pour recommencer
|
1349 |
if( 0 < $( '.preview-fields' ).length ) {
|
1381 |
if( 0 < $( '.preview-fields' ).length ) {
|
1350 |
$( '.preview-fields' ).each( function () {
|
1382 |
$( '.preview-fields' ).each( function () {
|
1351 |
$( this ).remove();
|
1383 |
$( this ).remove();
|
1352 |
});
|
1384 |
});
|
1353 |
}
|
1385 |
}
|
1354 |
// Au premier ajout d'un champ dans la prévisualisation on ajoute un titre et un message
|
1386 |
// Au premier ajout d'un champ dans la prévisualisation on ajoute un titre et un message
|
1355 |
if( true === firstClick ) {
|
1387 |
if( true === firstClick ) {
|
1356 |
$( '#zone-supp' ).prepend(
|
1388 |
$( '#zone-supp' ).prepend(
|
1357 |
'<h2>Informations spécifiques au projet</h2>' +
|
1389 |
'<h2>Informations spécifiques au projet</h2>' +
|
1358 |
'<div class="message">Ceci n\'est qu\'un aperçu.<br>Il vous permet simplement de visualiser les contenus pour vérifier d\'évenutelles erreurs</div>'
|
1390 |
'<div class="message">Ceci n\'est qu\'un aperçu.<br>Il vous permet simplement de visualiser les contenus pour vérifier d\'évenutelles erreurs</div>'
|
1359 |
);
|
1391 |
);
|
1360 |
}
|
1392 |
}
|
1361 |
// Parcourir tous les blocs d'infos de champs supplémentaires
|
1393 |
// Parcourir tous les blocs d'infos de champs supplémentaires
|
1362 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
1394 |
for( var index = $( 'fieldset' ).first().attr('data-id') ; index <= count ; index++ ) {
|
1363 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
1395 |
var thisFieldset = $( 'fieldset[data-id="' + index + '"]');
|
1364 |
// Certains indices peuvent correspondre à un champ supprimé
|
1396 |
// Certains indices peuvent correspondre à un champ supprimé
|
1365 |
if( 0 < $( thisFieldset ).length ) {
|
1397 |
if( 0 < $( thisFieldset ).length ) {
|
1366 |
// Prévisualisation d'un champ
|
1398 |
// Prévisualisation d'un champ
|
1367 |
$( '#zone-supp .preview-container' ).append(
|
1399 |
$( '#zone-supp .preview-container' ).append(
|
1368 |
'<div class="preview-fields" data-id="' + index + '">'+
|
1400 |
'<div class="preview-fields" data-id="' + index + '">'+
|
1369 |
onClickPreviewField( thisFieldset , index ) +
|
1401 |
onClickPreviewField( thisFieldset , index ) +
|
1370 |
'</div>'
|
1402 |
'</div>'
|
1371 |
);
|
1403 |
);
|
1372 |
|
- |
|
1373 |
// Ajout/suppression d'un champ texte "Autre"
|
1404 |
// Ajout/suppression d'un champ texte "Autre"
|
1374 |
if( $( '.option-other-value' , thisFieldset ).is( ':checked' ) ) {
|
1405 |
if( $( '.option-other-value' , thisFieldset ).is( ':checked' ) ) {
|
1375 |
onOtherOption( thisFieldset , index);
|
1406 |
onOtherOption( thisFieldset , index);
|
1376 |
}
|
1407 |
}
|
1377 |
}
|
1408 |
}
|
1378 |
}
|
1409 |
}
|
1379 |
// Le titre + message de la section prévisualisation ne sont ajoutés qu'une fois
|
1410 |
// Le titre + message de la section prévisualisation ne sont ajoutés qu'une fois
|
1380 |
firstClick = false;
|
1411 |
firstClick = false;
|
1381 |
}
|
1412 |
}
|
- |
|
1413 |
|
- |
|
1414 |
// Activation/Desactivation et contenu de la modale Bootstrap
|
1382 |
|
1415 |
// https://getbootstrap.com/docs/3.3/javascript/#modals
|
1383 |
function previewFieldHelpModal() {
|
1416 |
function previewFieldHelpModal() {
|
1384 |
$( '#zone-supp' ).on( 'click' , '.help-button' , function ( event ) {
|
1417 |
$( '#zone-supp' ).on( 'click' , '.help-button' , function ( event ) {
|
1385 |
var index = $( this ).closest( '.preview-fields' ).attr( 'data-id' ),
|
1418 |
var index = $( this ).closest( '.preview-fields' ).attr( 'data-id' ),
|
1386 |
thisFieldset = $( '.new-field[data-id="' + index + '"]' ),
|
1419 |
thisFieldset = $( '.new-field[data-id="' + index + '"]' ),
|
1387 |
file = $( '.field-help' , thisFieldset )[0].files[0],
|
1420 |
file = $( '.field-help' , thisFieldset )[0].files[0],
|
1388 |
tmppath = URL.createObjectURL( file ),
|
1421 |
tmppath = URL.createObjectURL( file );
|
1389 |
helpModalHtml = '';
|
1422 |
// Titre
|
1390 |
|
- |
|
1391 |
$( '#help-modal-label' ).text( 'Aide pour : ' + $( '.field-name' , thisFieldset ).val() );
|
1423 |
$( '#help-modal-label' ).text( 'Aide pour : ' + $( '.field-name' , thisFieldset ).val() );
|
1392 |
|
1424 |
// Contenu
|
1393 |
if( file.type.match( 'image' ) ) {
|
1425 |
if( file.type.match( 'image' ) ) {
|
1394 |
$( '#print_content' ).append( '<img src="' + tmppath + '" style="max-width:100%">' );
|
1426 |
$( '#print_content' ).append( '<img src="' + tmppath + '" style="max-width:100%">' );
|
1395 |
} else if( file.type.match( 'pdf' ) ) {
|
1427 |
} else if( file.type.match( 'pdf' ) ) {
|
1396 |
$( '#print_content' ).append( '<iframe src="' + tmppath + '" width="100%" height="650" align="middle" scrolling="no" frameborder="0"></iframe>' );
|
1428 |
$( '#print_content' ).append( '<iframe src="' + tmppath + '" width="100%" height="650" align="middle" scrolling="no" frameborder="0"></iframe>' );
|
1397 |
}
|
1429 |
}
|
1398 |
|
- |
|
- |
|
1430 |
// Sortie avec la touche escape
|
1399 |
$( '#help-modal' ).modal( { keyboard : true } );
|
1431 |
$( '#help-modal' ).modal( { keyboard : true } );
|
- |
|
1432 |
// Affichage
|
1400 |
$( '#help-modal' ).modal( 'show' );
|
1433 |
$( '#help-modal' ).modal( 'show' );
|
1401 |
|
- |
|
- |
|
1434 |
// Remplacer l'autofocus qui ne fonctionne plus en HTML5
|
- |
|
1435 |
// Message dans la doc de bootstrap :
|
- |
|
1436 |
// Due to how HTML5 defines its semantics,
|
- |
|
1437 |
// the autofocus HTML attribute has no effect in Bootstrap modals.
|
- |
|
1438 |
// To achieve the same effect, use some custom JavaScript
|
1402 |
$( '#help-modal' ).on( 'shown.bs.modal' , function () {
|
1439 |
$( '#help-modal' ).on( 'shown.bs.modal' , function () {
|
1403 |
$( '#myInput' ).trigger( 'focus' );
|
1440 |
$( '#myInput' ).trigger( 'focus' );
|
1404 |
})
|
1441 |
})
|
1405 |
|
- |
|
- |
|
1442 |
// Réinitialisation
|
1406 |
$( '#help-modal' ).on( 'hidden.bs.modal' , function () {
|
1443 |
$( '#help-modal' ).on( 'hidden.bs.modal' , function () {
|
1407 |
$( '#help-modal-label' ).text();
|
1444 |
$( '#help-modal-label' ).text();
|
1408 |
$( '#print_content' ).empty();
|
1445 |
$( '#print_content' ).empty();
|
1409 |
})
|
1446 |
})
|
1410 |
});
|
1447 |
});
|
1411 |
}
|
1448 |
}
|
1412 |
|
1449 |
|
1413 |
|
- |
|
1414 |
|
1450 |
|
1415 |
/***************************
|
1451 |
/***************************
|
1416 |
* Lancement des scripts *
|
1452 |
* Lancement des scripts *
|
1417 |
***************************/
|
1453 |
***************************/
|
1418 |
|
1454 |
|
1419 |
// Tableau d'envoi des données
|
1455 |
// Tableau d'envoi des données
|
1420 |
var datasToSubmit = new Array();
|
1456 |
var datasToSubmit = new Array();
|
1421 |
var firstClick = true;
|
1457 |
var firstClick = true;
|
1422 |
|
1458 |
|
1423 |
jQuery( document ).ready( function() {
|
- |
|
1424 |
// console.log($(location).attr('search'));
|
- |
|
1425 |
// console.log($(location).attr('search').search('='));
|
- |
|
1426 |
// console.log($(location).attr('search').charAt(6));
|
1459 |
jQuery( document ).ready( function() {
|
1427 |
// Identifiant de champ
|
1460 |
// Identifiant de champ
|
1428 |
var fieldIndex = 0;
|
1461 |
var fieldIndex = 0;
|
1429 |
// Ajout de nouveaux champs
|
1462 |
// Ajout de nouveaux champs
|
1430 |
onClickAddNewFields( fieldIndex );
|
1463 |
onClickAddNewFields( fieldIndex );
|
1431 |
// Activation/Desactivation des boutons valider et prévisualiser
|
1464 |
// Activation/Desactivation des boutons valider et prévisualiser
|
1432 |
activatePreviewAndValidateButtons();
|
1465 |
activatePreviewAndValidateButtons();
|
1433 |
|
- |
|
1434 |
// Prévisualisation des champs classiques
|
1466 |
// Prévisualisation des champs classiques
|
1435 |
DisplayClassicFields()
|
1467 |
DisplayClassicFields();
|
1436 |
|
- |
|
1437 |
|
- |
|
1438 |
// Affichage des images ou nom des documents importés
|
1468 |
// Affichage des images ou nom des documents importés
|
1439 |
inputFile();
|
1469 |
inputFile();
|
1440 |
// Affichage des List-checkbox
|
1470 |
// Affichage des List-checkbox
|
1441 |
inputListCheckbox();
|
1471 |
inputListCheckbox();
|
1442 |
|
- |
|
- |
|
1472 |
// Modale "aide"
|
1443 |
previewFieldHelpModal();
|
1473 |
previewFieldHelpModal();
|
1444 |
|
- |
|
1445 |
});
|
1474 |
});
|