enmi12/glossaire/js/form.js
changeset 0 d970ebf37754
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 $('.commentSection form').click(function(event){
       
     2 	event.stopPropagation();
       
     3 
       
     4 });
       
     5 
       
     6 $('.commentSection input').focus(function(event){
       
     7 
       
     8 	event.stopPropagation();
       
     9 	console.log($(this).val() + '   ' + values[returnOldValue($(this).attr('name'))]);
       
    10 	if($(this).val() == values[returnOldValue($(this).attr('name'))]){
       
    11 		$(this).val(($(this).attr('name') == 'twitter') ?'@':'');
       
    12 		$(this).css('color', '#000');
       
    13 	}
       
    14 });
       
    15 
       
    16 $('.commentInput').focus(function(event){
       
    17 
       
    18 	event.stopPropagation();
       
    19 	
       
    20 	if($(this).val() == values[returnOldValue($(this).attr('name'))]){
       
    21 		$(this).val('');
       
    22 		$(this).css('color', '#000');
       
    23 	}
       
    24 });
       
    25 
       
    26 var pseudo = 'nom/pseudo';
       
    27 var mail = 'mail';
       
    28 var twitter = 'twitter';
       
    29 var comment = 'votre commentaire';
       
    30 var values = [pseudo, mail, twitter, comment];
       
    31 
       
    32 $('.commentSection input').focusout(function(event){
       
    33 	event.stopPropagation();
       
    34 	if($(this).val().length	== 0 || $(this).val() == '@'){
       
    35 		$(this).val(values[returnOldValue($(this).attr('name'))]);
       
    36 		$(this).css('color', '#b7b7b7');
       
    37 	}
       
    38 });
       
    39 
       
    40 $('.commentInput').focusout(function(event){
       
    41 	event.stopPropagation();
       
    42 	console.log(isThisEqual($(this).val().length, 0));
       
    43 	if($(this).val().length == 0 || $(this).val().length == '@'){
       
    44 		$(this).val(values[returnOldValue($(this).attr('name'))]);
       
    45 		$(this).css('color', '#b7b7b7');
       
    46 	}
       
    47 });
       
    48 
       
    49 function isThisEqual(un, deux){
       
    50 	console.log(un + '//' + deux);
       
    51 	if(un == deux){
       
    52 		return true;
       
    53 	}
       
    54 	return false;
       
    55 }
       
    56 
       
    57 function returnOldValue(attribut)
       
    58 {
       
    59 	switch(attribut)
       
    60 	{
       
    61 		case 'pseudo':
       
    62 		return 0
       
    63 		break;
       
    64 		
       
    65 		case 'mail' :
       
    66 		return 1
       
    67 		break;
       
    68 		
       
    69 		case 'twitter' :
       
    70 		return 2
       
    71 		break;
       
    72 		
       
    73 		case 'comment' :
       
    74 		return 3
       
    75 		break;
       
    76 	}
       
    77 }