| 3165 |
idir |
1 |
function nouveauChamps(html){
|
|
|
2 |
var html =
|
|
|
3 |
'<div>'+
|
|
|
4 |
'<label for="nom_champs">Nom du champ</label>'+
|
|
|
5 |
'<input type="text" value="Nom du Champs" id="nom_champs">'+
|
|
|
6 |
|
|
|
7 |
'<label for="type_champ">Type de champ</label>'+
|
|
|
8 |
'<select name="type_champ" id="type_champ">'+
|
|
|
9 |
'<option value="text">Champ texte</option>'+
|
|
|
10 |
'<option value="textarea">Champ rédaction</option>'+
|
|
|
11 |
'<option value="select">Menu déroulant</option>'+
|
|
|
12 |
'<option value="checkbox">Cases à cocher</option>'+
|
|
|
13 |
'<option value="radio">Boutons radio</option>'+
|
|
|
14 |
'<option value="date">Calendrier</option>'+
|
|
|
15 |
'<option value="file">Téléchargement</option>'+
|
|
|
16 |
'<option value="hidden">Caché</option>'+
|
|
|
17 |
'<option value="button">Bouton</option>'+
|
|
|
18 |
'</select>'+
|
|
|
19 |
'<div>';
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
$('#profile-details-fields-section').append(html);
|
|
|
23 |
}
|
|
|
24 |
|
| 3166 |
idir |
25 |
function enregistrerNouveauChamps() {
|
|
|
26 |
var $typeChamp = $('#type_champ'),
|
|
|
27 |
$valeurNouveauChamp = [];
|
|
|
28 |
$type_champ.change(function() {
|
|
|
29 |
$valeurNouveauChamp = $(this).val();
|
|
|
30 |
console.log($valeurNouveauChamp);
|
|
|
31 |
});
|
|
|
32 |
}
|
| 3165 |
idir |
33 |
|
| 3166 |
idir |
34 |
|
|
|
35 |
function inputFile() {
|
|
|
36 |
|
| 3165 |
idir |
37 |
// ajout de la classe JS à HTML
|
|
|
38 |
$('html').addClass('js');
|
|
|
39 |
|
|
|
40 |
// initialisation des variables
|
|
|
41 |
var $fileInput = $( ".input-file" ),
|
| 3166 |
idir |
42 |
$button = $( ".label-file" );
|
| 3165 |
idir |
43 |
|
|
|
44 |
// action lorsque la "barre d'espace" ou "Entrée" est pressée
|
|
|
45 |
$button.on( 'keydown', function( event ) {
|
|
|
46 |
if ( event.keyCode == 13 || event.keyCode == 32 ) {
|
|
|
47 |
$fileInput.focus();
|
|
|
48 |
}
|
|
|
49 |
});
|
|
|
50 |
|
|
|
51 |
// action lorsque le label est cliqué
|
| 3166 |
idir |
52 |
$button.click(function() {
|
|
|
53 |
$fileInput.focus();
|
|
|
54 |
return false;
|
| 3165 |
idir |
55 |
});
|
|
|
56 |
|
|
|
57 |
// affiche un retour visuel dès que input:file change
|
| 3166 |
idir |
58 |
$fileInput.change( function(event) {
|
|
|
59 |
var file = event.target.files[0]
|
|
|
60 |
var $theReturn = $('.' + $(this).attr('id'));
|
|
|
61 |
|
|
|
62 |
$theReturn.text(file.name);
|
|
|
63 |
|
|
|
64 |
if(file.type.match('image')) {
|
|
|
65 |
var tmppath = URL.createObjectURL(file);
|
|
|
66 |
$theReturn.append('<img src="' + tmppath + '" width="50%">');
|
|
|
67 |
}
|
|
|
68 |
});
|
| 3165 |
idir |
69 |
}
|
|
|
70 |
|
|
|
71 |
jQuery(document).ready(function() {
|
|
|
72 |
|
| 3166 |
idir |
73 |
inputFile()
|
| 3165 |
idir |
74 |
|
|
|
75 |
// var $projet = $('#projet');
|
|
|
76 |
|
|
|
77 |
// $projet.on('change', function( event ) {
|
|
|
78 |
// console.log($projet.val());
|
|
|
79 |
// $.ajax({
|
|
|
80 |
// url : 'http://localhost/widget:cel:manager',
|
|
|
81 |
// type : 'post',
|
|
|
82 |
// datatype : 'mode=creation&projet='+ $projet.val()
|
|
|
83 |
// });
|
|
|
84 |
// });
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
$('#add_fields').on("click", function(){
|
|
|
88 |
nouveauChamps();
|
|
|
89 |
});
|
|
|
90 |
|
|
|
91 |
});
|