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
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script src="script.js"></script>
- </head>
- <body>
- <script type="text/javascript">
- notificatie({
- type: "error"
- });
- </script>
- </body>
- </html>
style.css
- /* notificatie */
- #not{
- width: 500px;
- height: 56px;
- margin: auto;
- border-radius: 6px;
- padding: 12px;
- }
- #not > .left {
- float: left;
- }
- #not > .right {
- float: right;
- }
- .error_not{
- background: #ffd2d3;
- border: 1px solid #f4cbcb;
- }
- .succes_not{
- background: #d4ffcd;
- border: 1px solid #cff4c9;
- }
- .info_not{
- background: #dbecff;
- border: 1px solid #d2e6fc;
- }
- .waarschuwing_not{
- background: #fefccb;
- border: 1px solid #f6f2b5;
- }
- #not p {
- text-align: center;
- font-size: 21px;
- margin-top: -4px;
- font-family: Helvetica, Arial;
- }
- #not span {
- text-align: center;
- font-size: 16px;
- color: #FFF;
- margin-top: -8px;
- display: block;
- font-family: Helvetica, Arial;
- }
- .error_not p {
- color: #c27171;
- }
- .succes_not p{
- color: #7bc26f;
- }
- .info_not p{
- color: #84a0e1;
- }
- .waarschuwing_not p{
- color: #c1be6e;
- }
script.js
- function notificatie(para){
- //de opties
- var opties = {
- 'duur': 2, //Duur van de notificatie
- 'na': 1, //Sluiten na x seconden
- 'autoclose': false, //Het automatisch sluiten van de notificatie
- 'type': 'error', //Het type error: succes/error/info/waarschuwing
- 'bericht': 'Notificatie error!', //Bericht wat mee komt
- 'sub': 'Er is iets mis met het notificatie systeem.' //Sub bericht
- };
- // opties aan de notificatie functie voegen
- $.extend(true,opties,para);
- // design toepassen aan verscheidene classes
- var not_class = 'error_not';
- if(opties['type'] == 'succes'){
- not_class = 'succes_not';
- }else if(opties['type'] == 'info'){
- not_class = 'info_not';
- }else if(opties['type'] == 'waarschuwing'){
- not_class = 'waarschuwing_not';
- }
- //Container waarin de notificatie verschijnt
- var container = '<div id="not" class="'+not_class+'">';
- container += '<div class="left"><img src="images/'+opties['type']+'.png" /></div><p>';
- container += opties['bericht'];
- container += '</p><span>'+opties['sub']+'</span></div>';
-
- $noti = $(container);
- //notificatie toevoegen na de body tag
- $('body').append($noti);
- //animatie bij het showen
- var divHeight = $('#not').height();
- // see CSS top to minus of div height
- $('#not').css({
- top : '-'+divHeight+'px'
- });
-
- //het showen van de notificatie
- $('#not').show();
- slideDownNotificatie(opties['duur'], opties['na'], opties['autoclose']);
- }
- function slideDownNotificatie(duur, na, autoclose){
- setTimeout(function(){
- $('#not').animate({
- top: 0
- });
- }, parseInt(na * 1000));
- }
I hope someone can help me!