home *** CD-ROM | disk | FTP | other *** search
/ MacFormat UK 179 / MF_UK_179_1.iso / DiscContents / In the mag / Widgets / SurveyGizmo Widget 1.0 / SurveyGizmo Widget / SurveyGizmo.wdgt / scripts / AppleFuncs.js next >
Encoding:
JavaScript  |  2006-08-24  |  2.7 KB  |  97 lines

  1.  
  2. // everything below here handles showing and flipping to the prefs on the back and back again...
  3. function showPrefs() {
  4.     var front = document.getElementById("front");
  5.     var back = document.getElementById("back");
  6.  
  7.     if (window.widget)
  8.         widget.prepareForTransition("ToBack");
  9.  
  10.     front.style.display="none";
  11.     back.style.display="block";
  12. //    document.getElementById("donePrefsButton").display = "block";
  13.  
  14.     if (window.widget)
  15.         setTimeout ('widget.performTransition();', 0);
  16.     document.getElementById("inpUserKey").focus();
  17. }
  18.  
  19. function hidePrefs() {
  20.     var front = document.getElementById("front");
  21.     var back = document.getElementById("back");
  22.  
  23.     if (window.widget)
  24.         widget.prepareForTransition("ToFront");
  25.  
  26.     back.style.display="none";
  27. //    document.getElementById("donePrefsButton").display = "none";
  28.     front.style.display="block";
  29.  
  30.     if (window.widget)
  31.         setTimeout ('widget.performTransition();', 0);
  32. }
  33.  
  34. function enterflip(event) { document.getElementById('fliprollie').style.display = 'block'; }
  35. function exitflip(event) { document.getElementById('fliprollie').style.display = 'none'; }
  36. var flipShown = false;
  37. var animation = { duration:0, starttime:0, to:1.0, now:0.0, from:0.0, firstElement:null, timer:null };
  38. function mousemove (event) {
  39.     if (!flipShown) {
  40.         if (animation.timer != null) {
  41.             clearInterval (animation.timer);
  42.             animation.timer    = null;
  43.         }
  44.  
  45.         var starttime = (new Date).getTime() - 13;
  46.  
  47.         animation.duration = 500;
  48.         animation.starttime = starttime;
  49.         animation.firstElement = document.getElementById ('flip');
  50.         animation.timer = setInterval ("animate();", 13);
  51.         animation.from = animation.now;
  52.         animation.to = 1.0;
  53.         animate();
  54.         flipShown = true;
  55.     }
  56. }
  57. function mouseexit (event) {
  58.     if (flipShown) {
  59.         // fade in the info button
  60.         if (animation.timer != null) {
  61.             clearInterval (animation.timer);
  62.             animation.timer    = null;
  63.         }
  64.  
  65.         var starttime = (new Date).getTime() - 13;
  66.  
  67.         animation.duration = 500;
  68.         animation.starttime = starttime;
  69.         animation.firstElement = document.getElementById ('flip');
  70.         animation.timer = setInterval ("animate();", 13);
  71.         animation.from = animation.now;
  72.         animation.to = 0.0;
  73.         animate();
  74.         flipShown = false;
  75.     }
  76. }
  77. function animate() {
  78.     var T;
  79.     var ease;
  80.     var time = (new Date).getTime();
  81.  
  82.  
  83.     T = limit_3(time-animation.starttime, 0, animation.duration);
  84.  
  85.     if (T >= animation.duration) {
  86.         clearInterval (animation.timer);
  87.         animation.timer = null;
  88.         animation.now = animation.to;
  89.     } else {
  90.         ease = 0.5 - (0.5 * Math.cos(Math.PI * T / animation.duration));
  91.         animation.now = computeNextFloat (animation.from, animation.to, ease);
  92.     }
  93.  
  94.     animation.firstElement.style.opacity = animation.now;
  95. }
  96. function limit_3 (a, b, c) { return a < b ? b : (a > c ? c : a); }
  97. function computeNextFloat (from, to, ease) { return from + (to - from) * ease; }