Notification

Notification

Dear forum users,

I made a jquery notification system and it works! BUT... I want to make it like fade in when it shows. But it don't work! I don't know why. Could someone help me out? The script.js is down on this page!!!

index.php

  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  4. <script src="script.js"></script>
  5. </head>
  6. <body>
  7.  <script type="text/javascript">
  8.   notificatie({
  9.                                     type: "error"
  10.                                 });
  11.                     </script>
  12. </body>
  13. </html>
style.css
  1. /* notificatie */
  2. #not{
  3. width: 500px;
  4. height: 56px;
  5. margin: auto;
  6. border-radius: 6px;
  7. padding: 12px;
  8. }
  9. #not > .left {
  10. float: left;
  11. }
  12. #not > .right {
  13. float: right;
  14. }
  15. .error_not{
  16. background: #ffd2d3;
  17. border: 1px solid #f4cbcb;
  18. }
  19. .succes_not{
  20. background: #d4ffcd;
  21. border: 1px solid #cff4c9;
  22. }
  23. .info_not{
  24. background: #dbecff;
  25. border: 1px solid #d2e6fc;
  26. }
  27. .waarschuwing_not{
  28. background: #fefccb;
  29. border: 1px solid #f6f2b5;
  30. }
  31. #not p {
  32. text-align: center;
  33. font-size: 21px;
  34. margin-top: -4px;
  35. font-family: Helvetica, Arial;
  36. }
  37. #not span {
  38. text-align: center;
  39. font-size: 16px;
  40. color: #FFF;
  41. margin-top: -8px;
  42. display: block;
  43. font-family: Helvetica, Arial;
  44. }
  45. .error_not p {
  46. color: #c27171;
  47. }
  48. .succes_not p{
  49. color: #7bc26f;
  50. }
  51. .info_not p{
  52. color: #84a0e1;
  53. }
  54. .waarschuwing_not p{
  55. color: #c1be6e;
  56. }
script.js
  1. function notificatie(para){

  2. //de opties
  3. var opties = {
  4. 'duur': 2, //Duur van de notificatie
  5. 'na': 1, //Sluiten na x seconden
  6. 'autoclose': false, //Het automatisch sluiten van de notificatie
  7. 'type': 'error', //Het type error: succes/error/info/waarschuwing
  8. 'bericht': 'Notificatie error!', //Bericht wat mee komt
  9. 'sub': 'Er is iets mis met het notificatie systeem.' //Sub bericht
  10. };

  11. // opties aan de notificatie functie voegen
  12. $.extend(true,opties,para);

  13. // design toepassen aan verscheidene classes
  14. var not_class = 'error_not';
  15. if(opties['type'] == 'succes'){
  16. not_class = 'succes_not';
  17. }else if(opties['type'] == 'info'){
  18. not_class = 'info_not';
  19. }else if(opties['type'] == 'waarschuwing'){
  20. not_class = 'waarschuwing_not';
  21. }

  22. //Container waarin de notificatie verschijnt
  23. var container = '<div id="not" class="'+not_class+'">';
  24. container += '<div class="left"><img src="images/'+opties['type']+'.png" /></div><p>';
  25. container += opties['bericht'];
  26. container += '</p><span>'+opties['sub']+'</span></div>';
  27. $noti = $(container);

  28. //notificatie toevoegen na de body tag
  29. $('body').append($noti);

  30. //animatie bij het showen
  31.     var divHeight = $('#not').height();
  32.     // see CSS top to minus of div height
  33.     $('#not').css({
  34.         top : '-'+divHeight+'px'
  35.     });
  36. //het showen van de notificatie
  37. $('#not').show();

  38. slideDownNotificatie(opties['duur'], opties['na'], opties['autoclose']);
  39. }


  40. function slideDownNotificatie(duur, na, autoclose){    
  41.     setTimeout(function(){
  42.         $('#not').animate({
  43.             top: 0
  44.         }); 
  45.     }, parseInt(na * 1000));    
  46. }
I hope someone can help me!