diff -r 000000000000 -r d970ebf37754 enmi12/glossaire/js/form.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/enmi12/glossaire/js/form.js Wed Nov 06 03:21:17 2013 +0000 @@ -0,0 +1,77 @@ +$('.commentSection form').click(function(event){ + event.stopPropagation(); + +}); + +$('.commentSection input').focus(function(event){ + + event.stopPropagation(); + console.log($(this).val() + ' ' + values[returnOldValue($(this).attr('name'))]); + if($(this).val() == values[returnOldValue($(this).attr('name'))]){ + $(this).val(($(this).attr('name') == 'twitter') ?'@':''); + $(this).css('color', '#000'); + } +}); + +$('.commentInput').focus(function(event){ + + event.stopPropagation(); + + if($(this).val() == values[returnOldValue($(this).attr('name'))]){ + $(this).val(''); + $(this).css('color', '#000'); + } +}); + +var pseudo = 'nom/pseudo'; +var mail = 'mail'; +var twitter = 'twitter'; +var comment = 'votre commentaire'; +var values = [pseudo, mail, twitter, comment]; + +$('.commentSection input').focusout(function(event){ + event.stopPropagation(); + if($(this).val().length == 0 || $(this).val() == '@'){ + $(this).val(values[returnOldValue($(this).attr('name'))]); + $(this).css('color', '#b7b7b7'); + } +}); + +$('.commentInput').focusout(function(event){ + event.stopPropagation(); + console.log(isThisEqual($(this).val().length, 0)); + if($(this).val().length == 0 || $(this).val().length == '@'){ + $(this).val(values[returnOldValue($(this).attr('name'))]); + $(this).css('color', '#b7b7b7'); + } +}); + +function isThisEqual(un, deux){ + console.log(un + '//' + deux); + if(un == deux){ + return true; + } + return false; +} + +function returnOldValue(attribut) +{ + switch(attribut) + { + case 'pseudo': + return 0 + break; + + case 'mail' : + return 1 + break; + + case 'twitter' : + return 2 + break; + + case 'comment' : + return 3 + break; + } +} \ No newline at end of file