Subversion Repositories eFlore/Applications.cel

Rev

Rev 3165 | Rev 3167 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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