Guest User

Untitled

a guest
May 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.     var IdleTime = 0;
  3.     var timeout;
  4.  
  5.     // initially fade in upon page load
  6.     $('#header-wrapper').delay(100).fadeIn(1600);
  7.  
  8.     // They may be idle from this point onwards
  9.     // We do a check to find out
  10.     timeout = setTimeout("checkIdle()", 5000); // 5 seconds
  11.  
  12.     $(document).bind('mousemove', function() {
  13.         // check if #header-wrapper is not visible
  14.         if (!$('#header-wrapper').is(':visible'))
  15.         {
  16.             // Header is invisible, so fade in
  17.             $('#header-wrapper').fadeIn(1600);
  18.  
  19.             // They may be idle from this point onwards
  20.             // We do a check to find out
  21.             timeout = setTimeout("checkIdle()", 5000); // 5 seconds
  22.         }
  23.     });
  24.    
  25.     function checkIdle()
  26.     {
  27.         clearTimeout(timeout);
  28.  
  29.         IdleTime += 5; // 5 seconds
  30.  
  31.         if (IdleTime >= 180) // 180 seconds = 3 minutes
  32.         {
  33.             // Reset idle time
  34.             IdleTime = 0;
  35.  
  36.             // if header is visible
  37.             if ($('#header-wrapper').is(':visible'))
  38.             {
  39.                 // Header is visible, so fade out
  40.                 $('#header-wrapper').fadeOut(1600);
  41.             }          
  42.         }
  43.         else
  44.         {
  45.             // If the user is idle, why bother doing checks?
  46.             // User is not idle to this point, so we check again
  47.             timeout = setTimeout("checkIdle()", 5000); // 5 seconds
  48.         }
  49.     }
  50. });
Add Comment
Please, Sign In to add comment