Subversion Repositories DevTools

Rev

Rev 5751 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<!-- // Hide
2
 
3
// *** TIPSTER ***
4
 
5
var isDOM=document.getElementById?1:0;
6
var isIE=document.all?1:0;
7
var isNS4=(navigator.appName=='Netscape'&&!isDOM)?1:0;
8
var isWin=(navigator.platform.indexOf('Win')!=-1)?1:0;
9
var isDyn=(isDOM||isIE||isNS4);
10
 
11
function getRef(id, par)
12
{
13
 par = !par ? document : (par.navigator?par.document:par);
14
 return (isIE ? par.all[id] :
15
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
16
  par.layers[id]));
17
}
18
 
19
function getSty(id, par)
20
{
21
 return (isNS4 ? getRef(id, par) : getRef(id, par).style)
22
}
23
 
24
if (!window.LayerObj) var LayerObj = new Function('id', 'par',
25
 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
26
function getLyr(id, par) { return new LayerObj(id, par) }
27
 
28
function LyrFn(fn, fc)
29
{
30
 LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0]; with (this) { '+fc+' }');
31
}
5114 dpurdie 32
LyrFn('x','if (!isNaN(a[0])) sty.left=p + "px"; else return parseInt(sty.left)');
33
LyrFn('y','if (!isNaN(a[0])) sty.top=p + "px"; else return parseInt(sty.top)');
119 ghuddy 34
LyrFn('vis','sty.visibility=p');
35
LyrFn('write','if (isNS4) with (ref.document) {write(p);close()} else ref.innerHTML=p');
36
LyrFn('alpha','var f=ref.filters; if (f) {' +
37
 'if (sty.filter.indexOf("alpha")==-1) sty.filter+="alpha()"; ' +
38
 'if (f.length&&f.alpha) f.alpha.opacity=p } else if (isDOM) sty.MozOpacity=(p/100)');
39
 
40
 
41
if (!window.page) var page = { win: window, minW: 0, minH: 0, MS: isIE&&!window.opera }
42
 
43
page.winW=function()
44
 { with (this) return Math.max(minW, MS?win.document.body.clientWidth:win.innerWidth) }
45
page.winH=function()
46
 { with (this) return Math.max(minH, MS?win.document.body.clientHeight:win.innerHeight) }
47
 
48
page.scrollX=function()
49
 { with (this) return MS?win.document.body.scrollLeft:win.pageXOffset }
50
page.scrollY=function()
51
 { with (this) return MS?win.document.body.scrollTop:win.pageYOffset }
52
 
53
 
54
// *** TIP FUNCTIONS AND OBJECT ***
55
 
56
function tipTrack(evt) { with (this)
57
{
7457 dpurdie 58
 // If we've set tip tracking, call the position function.
59
 if (actTip && tipStick == 1) {
60
     // Figure out where the mouse is and call the position function.
61
     // Also set sX and sY as the scroll position of the document.
62
     sX = page.scrollX();
63
     sY = page.scrollY();
64
     mX = (isIE ? event.clientX + sX : evt.pageX);
65
     mY = (isIE ? event.clientY + sY : evt.pageY);
119 ghuddy 66
 
7457 dpurdie 67
     position();
68
 }
119 ghuddy 69
}}
70
 
71
function tipPosition() { with (this)
72
{
73
 if (actTip)
74
 {
75
  // Pull the window sizes from the page object.
76
  // In NS4 we size down the window a little as it includes scrollbars.
77
  var wW = page.winW()-(isIE?0:15), wH = page.winH()-(isIE?0:15);
78
 
79
  // Pull the compulsory information out of the tip array.
80
  var t=tips[actTip], tipX=eval(t[0]), tipY=eval(t[1]), tipW=t[2], tipH=t[3], adjY = 1;
81
 
82
  // Add mouse position onto relatively positioned tips.
83
  if (typeof(t[0])=='number') tipX += mX;
84
  if (typeof(t[1])=='number') tipY += mY;
85
 
86
  // Check the tip is not within 5px of the screen boundaries.
87
  if (tipX + tipW + 5 > sX + wW) { tipX = sX + wW - tipW - 5; adjY = 2 }
88
  if (tipY + tipH + 5 > sY + wH) tipY = sY + wH - (adjY*tipH) - 5;
89
  if (tipX < sX+ 5) tipX = sX + 5;
90
  if (tipY < sY + 5) tipY = sY + 5;
91
 
92
 
93
  // If the tip is currently invisible, show at the calculated position.
94
  if (!showTip && (doFades ? !alpha : true))
95
  {
96
   xPos = tipX;
97
   yPos = tipY;
98
  }
99
 
100
  // Move the actual position towards the calculated by the stickiness factor.
101
  // Low stickinesses will result in slower catchup times.
102
  xPos += (tipX - xPos) * tipStick;
103
  yPos += (tipY - yPos) * tipStick;
104
 
105
  div.x(xPos);
106
  div.y(yPos);
107
 }
108
}}
109
 
110
function tipShow(tipN) { with (this)
111
{
112
 if (!isDyn) return;
113
 
5751 dpurdie 114
 // Create tip div on the fly
115
 // No need for HTML to define the tip layer. Use it if its present
116
 if (!div){
117
	 newdiv = document.getElementById(myName + 'Layer');
118
	 if (!newdiv)
119
	 {
120
		 newdiv = document.createElement('div');
121
		 newdiv.style.cssText = 'position: absolute; z-index: 1000; visibility: hidden; left:0; top: 0; width: 10';
122
		 newdiv.id = myName + 'Layer';
123
		 document.body.appendChild(newdiv);
124
	 }
125
 
126
	 div = getLyr(myName + 'Layer');
127
 }
128
 
119 ghuddy 129
 // My layer object we use.
5751 dpurdie 130
 //if (!div || !div.ref) div = getLyr(myName + 'Layer');
119 ghuddy 131
 if (!div.ref) return;
132
 
133
 // If we're mousing over a different or new tip...
134
 if (actTip != tipN)
135
 {
136
  // Remember this tip number as active, for the other functions.
137
  actTip = tipN;
138
 
139
  // Set tip's onmouseover and onmouseout handlers.
140
  if (isNS4) div.ref.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
141
  div.ref.onmouseover = new Function(myName + '.show("' + tipN + '")');
142
  div.ref.onmouseout = new Function(myName + '.hide()');
143
 
144
  // Stick it somewhere onscreen.
145
  position();
146
 
147
  // Go through and replace %0% with the array's 0 index, %1% with tips[tipN][1] etc...
148
  var str = template;
149
  for (var i=0; i<tips[tipN].length; i++) str = str.replace('%'+i+'%', tips[tipN][i]);
150
  // Write the proper content... the last <br> strangely helps IE5/Mac...?
151
  div.write(str + ((document.all && !isWin) ? '<small><br></small>' : ''));
152
 }
153
 
154
 // For non-integer stickiness values, we need to use setInterval to animate the tip,
155
 // if it's 0 or 1 we can just use onmousemove to position it.
156
 clearInterval(trackTimer);
157
 if (tipStick != parseInt(tipStick)) trackTimer = setInterval(myName+'.position()', 50);
158
 
159
 // Set the showTip flag, as a signal for the fade/position routines.
160
 showTip = true;
161
 
162
 // Finally either fade in immediately or after a very short delay.
163
 // The delay is for NS4 to allow it to execute a 'hide' event after this, from a
164
 // previous mouseout when two tip triggers overlap, because it's a weird browser.
165
 // So, this show call can cancel a (slightly later) hide. Look, it works, OK? ;).
166
 clearTimeout(fadeTimer);
167
 if (isNS4) setTimeout(myName + '.fade()', 1);
168
 else fade();
169
}}
170
 
171
function tipHide() { with (this)
172
{
173
 if (!isDyn) return;
174
 
175
 // Fade out in 100ms, a larger delay so another mouseover can cancel this fade.
176
 // This allows the user to mouseover a static tip before its hides.
177
 clearTimeout(fadeTimer);
178
 fadeTimer = setTimeout('with (' + myName + ') { showTip=false; fade() }', 200);
179
}}
180
 
181
function tipFade() { with (this)
182
{
183
 // Clear to stop existing fades.
184
 clearTimeout(fadeTimer);
185
 
186
 // Show it and optionally increment alpha from 0 to 100.
187
 if (showTip)
188
 {
189
  div.vis('visible');
190
  if (doFades)
191
  {
192
   alpha += fadeSpeed;
193
   if (alpha > 100) alpha = 100;
194
   div.alpha(alpha);
195
   // Call this function again shortly, fading tip in further.
196
   if (alpha < 100) fadeTimer = setTimeout(myName + '.fade()', 50);
197
   return;
198
  }
199
 }
200
 
201
 else
202
 {
203
  // Similar to before but counting down and hiding at the end.
204
  if (doFades && alpha > 0)
205
  {
206
   alpha -= fadeSpeed;
207
   if (alpha < 0) alpha = 0;
208
   div.alpha(alpha);
209
   fadeTimer = setTimeout(myName + '.fade()', 50);
210
   return;
211
  }
212
  div.vis('hidden');
213
  // Clear the active tip flag so it is repositioned next time.
214
  actTip = '';
215
  // Stop any sticky-tip tracking if it's invisible.
216
  clearInterval(trackTimer);
217
 }
218
}}
219
 
220
function TipObj(myName)
221
{
222
 // Holds the properties the functions above use.
223
 this.myName = myName;
224
 this.tips = new Array();
225
 this.template = '';
226
 this.actTip = '';
227
 this.showTip = false;
228
 this.tipStick = 1;
229
 this.xPos = this.yPos = this.sX = this.sY = this.mX = this.mY = 0;
230
 
231
 this.track = tipTrack;
232
 this.position = tipPosition;
233
 this.show = tipShow;
234
 this.hide = tipHide;
235
 this.fade = tipFade;
236
 
237
 this.div = null;
238
 this.trackTimer = 0;
239
 this.fadeTimer = 0;
240
 this.alpha = 0;
241
 this.doFades = false;
242
 this.fadeSpeed = 20;
4230 dpurdie 243
 this.template = '<table bgcolor="#000000" cellpadding="1" cellspacing="0" width="%2%" border="0">' +
244
                 '<tr><td><table bgcolor="#FFFFCC" cellpadding="2" cellspacing="0" width="100%" border="0">' +
245
                 '<tr><td height="%3%" class="tipClass">%4%</td></tr></table></td></tr></table>';
119 ghuddy 246
}
4230 dpurdie 247
var formTips = new TipObj('formTips');
119 ghuddy 248
 
4230 dpurdie 249
// Functions to assist in creating tips
250
// stdTip: width, Title, Body
251
function stdTip( w,t,b) {
252
    return newTip(10,0,w,10,t,b);
253
}
254
// newTip( x,y,width,height, title, body)
255
function newTip(x,y,w,h,t,b) {
256
    var tip = new Array(x,y,w,h,10);
5114 dpurdie 257
    tip[4] = '<img src="images/i_help.gif" width="12px" height="12px" hspace="2" align="absmiddle">' +
4230 dpurdie 258
    t + '<hr size="1" noshade>' + b;
259
    return tip;
260
} 
119 ghuddy 261
 
262
// Capture the onmousemove event so tips can follow the mouse. Add in all your tip objects here
263
// and also any functions from other scripts that need this event (e.g. my DHTML Scroller) too.
264
if (isNS4) document.captureEvents(Event.MOUSEMOVE);
265
document.onmousemove = function(evt)
266
{
267
 formTips.track(evt);
268
 if (isNS4) return document.routeEvent(evt);
269
}
270
 
271
 
272
// A small function that refreshes NS4 on horizontal resize.
273
var nsWinW = window.innerWidth, nsWinH = window.innerHeight;
274
function ns4BugCheck()
275
{
276
 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload()
277
}
278
 
279
window.onresize = function()
280
{
281
 ns4BugCheck();
282
}
283
 
4230 dpurdie 284
// End Hide -->