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