Subversion Repositories DevTools

Rev

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