Widget info button now positioned correctly
[rgbconverter.git] / RGB_Converter / RGB_Converter.wdgt / Widget.js
1 /*=====================================================================*\
2 || ################################################################### ||
3 || # RGB Converter Widget [#]version[#]
4 || # --------------------------------------------------------------- # ||
5 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
6 || # This file may not be reproduced in any way without permission. # ||
7 || # --------------------------------------------------------------- # ||
8 || # User License Agreement at http://www.iris-studios.com/license/ # ||
9 || ################################################################### ||
10 \*=====================================================================*/
11
12 // ###################################################################
13 // flip data
14
15 function show_back()
16 {
17 var front = document.getElementById("front");
18 var back = document.getElementById("back");
19
20 if (window.widget)
21 {
22 widget.prepareForTransition("ToBack");
23 }
24
25 front.style.display = "none";
26 back.style.display = "block";
27
28 if (window.widget)
29 {
30 setTimeout("widget.performTransition();", 0);
31 }
32
33 document.getElementById("fliprollie").style.display = "none";
34 }
35
36 function hide_back()
37 {
38 var front = document.getElementById("front");
39 var back = document.getElementById("back");
40
41 if (window.widget)
42 {
43 widget.prepareForTransition("ToFront");
44 }
45
46 back.style.display = "none";
47 front.style.display = "block";
48
49 if (window.widget)
50 {
51 setTimeout("widget.performTransition();", 0);
52 }
53 }
54
55 var flipShown = false;
56
57 var animation = {
58 duration : 0,
59 starttime : 0,
60 to : 1.0,
61 now : 0.0,
62 from : 0.0,
63 firstElement : null,
64 timer : null
65 };
66
67 function mousemove(event)
68 {
69 if (!flipShown)
70 {
71 if (animation.timer != null)
72 {
73 clearInterval(animation.timer);
74 animation.timer = null;
75 }
76
77 var starttime = (new Date).getTime() - 13;
78
79 animation.duration = 500;
80 animation.starttime = starttime;
81 animation.firstElement = document.getElementById("flip");
82 animation.timer = setInterval("animate();", 13);
83 animation.from = animation.now;
84 animation.to = 1.0;
85 animate();
86 flipShown = true;
87 }
88 }
89
90 function mouseexit(event)
91 {
92 if (flipShown)
93 {
94 // fade in the flip widget
95 if (animation.timer != null)
96 {
97 clearInterval (animation.timer);
98 animation.timer = null;
99 }
100
101 var starttime = (new Date).getTime() - 13;
102
103 animation.duration = 500;
104 animation.starttime = starttime;
105 animation.firstElement = document.getElementById("flip");
106 animation.timer = setInterval("animate();", 13);
107 animation.from = animation.now;
108 animation.to = 0.0;
109 animate();
110 flipShown = false;
111 }
112 }
113
114
115 function animate()
116 {
117 var T;
118 var ease;
119 var time = (new Date).getTime();
120
121 T = limit_3(time - animation.starttime, 0, animation.duration);
122
123 if (T >= animation.duration)
124 {
125 clearInterval(animation.timer);
126 animation.timer = null;
127 animation.now = animation.to;
128 }
129 else
130 {
131 ease = 0.5 - (0.5 * Math.cos(Math.PI * T / animation.duration));
132 animation.now = compute_next_float(animation.from, animation.to, ease);
133 }
134
135 animation.firstElement.style.opacity = animation.now;
136 }
137
138 function limit_3 (a, b, c)
139 {
140 return a < b ? b : (a > c ? c : a);
141 }
142
143 function compute_next_float(from, to, ease)
144 {
145 return from + (to - from) * ease;
146 }
147
148 function enterflip(event)
149 {
150 document.getElementById("fliprollie").style.display = "block";
151 }
152
153 function exitflip(event)
154 {
155 document.getElementById("fliprollie").style.display = "none";
156 }
157
158 /*=====================================================================*\
159 || ###################################################################
160 || # $HeadURL$
161 || # $Id$
162 || ###################################################################
163 \*=====================================================================*/