erikblomqvist

Untitled

Jan 17th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.         var vibrateBool = false;
  3.         var vibrateInterval = null;
  4.         var vibrateIntervalTimerMs = 500;
  5.         var vibrate = function() {
  6.                 if(vibrateBool) navigator.notification.vibrate();
  7.         }
  8.  
  9.         $('h2.on').on('click', function() {
  10.                 $(this).removeClass('on').addClass('off');
  11.                 $(this).toggleClass('heart');
  12.                 vibrateBool = true;
  13.                 vibrateInterval = setInterval("vibrate()",vibrateIntervalTimerMs);
  14.         });
  15.        
  16.         // Beroende på hur gammal jquery du har får du kanske
  17.         // Byta ut till .click igen, men använd alltid .on()
  18.         $('h2.off').on('click', function() {
  19.                 $(this).removeClass('off').addClass('on');
  20.                 $(this).toggleClass('heart');
  21.  
  22.                 clearInterval(vibrateInterval);
  23.                 vibrateInterval = null;
  24.         });
  25. });
Advertisement
Add Comment
Please, Sign In to add comment