muzich.js 758B

123456789101112131415161718192021222324252627282930
  1. // Messages flashs
  2. var myMessages = ['info','warning','error','success']; // define the messages types
  3. function hideAllMessages()
  4. {
  5. var messagesHeights = new Array(); // this array will store height for each
  6. for (i=0; i<myMessages.length; i++)
  7. {
  8. messagesHeights[i] = $('.' + myMessages[i]).outerHeight();
  9. $('.' + myMessages[i]).css('top', -messagesHeights[i]); //move element outside viewport
  10. }
  11. }
  12. $(document).ready(function(){
  13. // Initially, hide them all
  14. hideAllMessages();
  15. $('.message').animate({top:"0"}, 500);
  16. // When message is clicked, hide it
  17. $('.message a.message-close').click(function(){
  18. $(this).parent('.message').animate({top: -$(this).outerHeight()-50}, 700);
  19. return false;
  20. });
  21. });