Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
/* This notice must be untouched at all times.
2
 
3
wz_tooltip.js    v. 3.31
4
 
5
The latest version is available at
6
http://www.walterzorn.com
7
or http://www.devira.com
8
or http://www.walterzorn.de
9
 
10
Copyright (c) 2002-2004 Walter Zorn. All rights reserved.
11
Created 1. 12. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
12
Last modified: 22. 6. 2005
13
 
14
Cross-browser tooltips working even in Opera 5 and 6,
15
as well as in NN 4, Gecko-Browsers, IE4+, Opera 7 and Konqueror.
16
No onmouseouts required.
17
Appearance of tooltips can be individually configured
18
via commands within the onmouseovers.
19
 
20
LICENSE: LGPL
21
 
22
This library is free software; you can redistribute it and/or
23
modify it under the terms of the GNU Lesser General Public
24
License (LGPL) as published by the Free Software Foundation; either
25
version 2.1 of the License, or (at your option) any later version.
26
 
27
This library is distributed in the hope that it will be useful,
28
but WITHOUT ANY WARRANTY; without even the implied warranty of
29
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30
 
31
For more details on the GNU Lesser General Public License,
32
see http://www.gnu.org/copyleft/lesser.html
33
*/
34
 
35
 
36
 
37
////////////////  GLOBAL TOOPTIP CONFIGURATION  /////////////////////
38
 
39
var ttBgColor      = "#FFFFE7";
40
var ttBgImg        = ""; //images/help.gif";           // path to background image;
41
var ttBorderColor  = "#000000";
42
var ttBorderWidth  = 1;
43
var ttDelay        = 250;          // time span until tooltip shows up [milliseconds]
44
var ttFontColor    = "#000000";
45
var ttFontFace     = "verdana,arial,helvetica,sans-serif";
46
var ttFontSize     = "12px";
47
var ttFontWeight   = "normal";     // alternative is "bold";
48
var ttOffsetX      = 12;            // horizontal offset of left-top corner from mousepointer
49
var ttOffsetY      = 15;           // vertical offset                   "
50
var ttOpacity      = 100;          // opacity of tooltip in percent (must be integer between 0 and 100)
51
var ttPadding      = 3;            // spacing between border and content
52
var ttShadowColor  = "#808080";
53
var ttShadowWidth  = 3;
54
var ttTemp         = 0;            // time span after which the tooltip disappears; 0 (zero) means "infinite timespan"
55
var ttTextAlign    = "left";
56
var ttTitleColor   = "#ffffff";    // color of caption text
57
var ttWidth        = 350;
58
////////////////////  END OF TOOLTIP CONFIG  ////////////////////////
59
 
60
 
61
 
62
//////////////  TAGS WITH TOOLTIP FUNCTIONALITY  ////////////////////
63
// List may be extended or shortened:
64
var tt_tags = new Array("a","area","b","big","caption","center","code","dd","div","dl","dt","em","h1","h2","h3","h4","h5","h6","i","img","input","li","map","ol","p","pre","s","small","span","strike","strong","sub","sup","table","td","th","tr","tt","u","var","ul","layer");
65
/////////////////////////////////////////////////////////////////////
66
 
67
 
68
 
69
///////// DON'T CHANGE ANYTHING BELOW THIS LINE /////////////////////
70
var tt_obj,                // current tooltip
71
tt_ifrm,                   // iframe to cover windowed controls in IE
72
tt_objW = 0, tt_objH = 0,  // width and height of tt_obj
73
tt_objX = 0, tt_objY = 0,
74
tt_offX = 0, tt_offY = 0,
75
xlim = 0, ylim = 0,        // right and bottom borders of visible client area
76
tt_sup = false,            // true if T_ABOVE cmd
77
tt_sticky = false,         // tt_obj sticky?
78
tt_wait = false,
79
tt_act = false,            // tooltip visibility flag
80
tt_sub = false,            // true while tooltip below mousepointer
81
tt_u = "undefined",
82
tt_mf,                     // stores previous mousemove evthandler
83
// Opera: disable href when hovering <a>
84
tt_tag = null;             // stores hovered dom node, href and previous statusbar txt
85
 
86
 
87
var tt_db = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null,
88
tt_n = navigator.userAgent.toLowerCase(),
89
tt_nv = navigator.appVersion;
90
// Browser flags
91
var tt_op = !!(window.opera && document.getElementById),
92
tt_op6 = tt_op && !document.defaultView,
93
tt_op7 = tt_op && !tt_op6,
94
tt_ie = tt_n.indexOf("msie") != -1 && document.all && tt_db && !tt_op,
95
tt_ie6 = tt_ie && parseFloat(tt_nv.substring(tt_nv.indexOf("MSIE")+5)) >= 5.5;
96
tt_n4 = (document.layers && typeof document.classes != tt_u),
97
tt_n6 = (!tt_op && document.defaultView && typeof document.defaultView.getComputedStyle != tt_u),
98
tt_w3c = !tt_ie && !tt_n6 && !tt_op && document.getElementById;
99
 
100
function tt_Int(t_x)
101
{
102
    var t_y;
103
    return isNaN(t_y = parseInt(t_x))? 0 : t_y;
104
}
105
function wzReplace(t_x, t_y)
106
{
107
    var t_ret = "",
108
    t_str = this,
109
    t_xI;
110
    while((t_xI = t_str.indexOf(t_x)) != -1)
111
    {
112
        t_ret += t_str.substring(0, t_xI) + t_y;
113
        t_str = t_str.substring(t_xI + t_x.length);
114
    }
115
    return t_ret+t_str;
116
}
117
String.prototype.wzReplace = wzReplace;
118
function tt_N4Tags(tagtyp, t_d, t_y)
119
{
120
    t_d = t_d || document;
121
    t_y = t_y || new Array();
122
    var t_x = (tagtyp=="a")? t_d.links : t_d.layers;
123
    for(var z = t_x.length; z--;) t_y[t_y.length] = t_x[z];
124
    for(z = t_d.layers.length; z--;) t_y = tt_N4Tags(tagtyp, t_d.layers[z].document, t_y);
125
    return t_y;
126
}
127
function tt_Htm(tt, t_id, txt)
128
{
129
    var t_bgc = (typeof tt.T_BGCOLOR != tt_u)? tt.T_BGCOLOR : ttBgColor,
130
    t_bgimg   = (typeof tt.T_BGIMG != tt_u)? tt.T_BGIMG : ttBgImg,
131
    t_bc      = (typeof tt.T_BORDERCOLOR != tt_u)? tt.T_BORDERCOLOR : ttBorderColor,
132
    t_bw      = (typeof tt.T_BORDERWIDTH != tt_u)? tt.T_BORDERWIDTH : ttBorderWidth,
133
    t_ff      = (typeof tt.T_FONTFACE != tt_u)? tt.T_FONTFACE : ttFontFace,
134
    t_fc      = (typeof tt.T_FONTCOLOR != tt_u)? tt.T_FONTCOLOR : ttFontColor,
135
    t_fsz     = (typeof tt.T_FONTSIZE != tt_u)? tt.T_FONTSIZE : ttFontSize,
136
    t_fwght   = (typeof tt.T_FONTWEIGHT != tt_u)? tt.T_FONTWEIGHT : ttFontWeight,
137
    t_opa     = (typeof tt.T_OPACITY != tt_u)? tt.T_OPACITY : ttOpacity,
138
    t_padd    = (typeof tt.T_PADDING != tt_u)? tt.T_PADDING : ttPadding,
139
    t_shc     = (typeof tt.T_SHADOWCOLOR != tt_u)? tt.T_SHADOWCOLOR : (ttShadowColor || 0),
140
    t_shw     = (typeof tt.T_SHADOWWIDTH != tt_u)? tt.T_SHADOWWIDTH : (ttShadowWidth || 0),
141
    t_algn    = (typeof tt.T_TEXTALIGN != tt_u)? tt.T_TEXTALIGN : ttTextAlign,
142
    t_tit     = (typeof tt.T_TITLE != tt_u)? tt.T_TITLE : "",
143
    t_titc    = (typeof tt.T_TITLECOLOR != tt_u)? tt.T_TITLECOLOR : ttTitleColor,
144
    t_w       = (typeof tt.T_WIDTH != tt_u)? tt.T_WIDTH  : ttWidth;
145
    if (t_shc || t_shw)
146
    {
147
        t_shc = t_shc || "#cccccc";
148
        t_shw = t_shw || 5;
149
    }
150
    if (tt_n4 && (t_fsz == "10px" || t_fsz == "11px")) t_fsz = "12px";
151
 
152
    var t_optx = (tt_n4? '' : tt_n6? ('-moz-opacity:'+(t_opa/100.0)) : tt_ie? ('filter:Alpha(opacity='+t_opa+')') : ('opacity:'+(t_opa/100.0))) + ';';
153
    var t_y = '<div id="'+t_id+'" style="position:absolute;z-index:1010;';
154
    t_y += 'left:0px;top:0px;width:'+(t_w+t_shw)+'px;visibility:'+(tt_n4? 'hide' : 'hidden')+';'+t_optx+'">' +
155
        '<table border="0" cellpadding="0" cellspacing="0"'+(t_bc? (' bgcolor="'+t_bc+'"') : '')+' width="'+t_w+'">';
156
    if (t_tit)
157
    {
158
        t_y += '<tr><td style="padding-left:3px;padding-right:3px;" align="'+t_algn+'"><font color="'+t_titc+'" face="'+t_ff+'" ' +
159
            'style="color:'+t_titc+';font-family:'+t_ff+';font-size:'+t_fsz+';"><b>' +
160
            (tt_n4? '&nbsp;' : '')+t_tit+'<\/b><\/font><\/td><\/tr>';
161
    }
162
    t_y += '<tr><td><table border="0" cellpadding="'+t_padd+'" cellspacing="'+t_bw+'" width="100%">' +
163
    // added padding-left:30px;
164
        '<tr><td'+(t_bgc? (' bgcolor="'+t_bgc+'"') : '')+(t_bgimg? ' background="'+t_bgimg+'"' : '')+' style="padding-left:15px;text-align:'+t_algn+';';
165
    // if (tt_n6) t_y += 'padding:'+t_padd+'px;';
166
    t_y += '" align="'+t_algn+'"><font color="'+t_fc+'" face="'+t_ff+'"' +
167
        ' style="color:'+t_fc+';font-family:'+t_ff+';font-size:'+t_fsz+';font-weight:'+t_fwght+';">';
168
    if (t_fwght == 'bold') t_y += '<b>';
169
    t_y += txt;
170
    if (t_fwght == 'bold') t_y += '<\/b>';
171
    t_y += '<\/font><\/td><\/tr><\/table><\/td><\/tr><\/table>';
172
    if (t_shw)
173
    {
174
        var t_spct = Math.round(t_shw*1.3);
175
        if (tt_n4)
176
        {
177
            t_y += '<layer bgcolor="'+t_shc+'" left="'+t_w+'" top="'+t_spct+'" width="'+t_shw+'" height="0"><\/layer>' +
178
                '<layer bgcolor="'+t_shc+'" left="'+t_spct+'" align="bottom" width="'+(t_w-t_spct)+'" height="'+t_shw+'"><\/layer>';
179
        }
180
        else
181
        {
182
            t_optx = tt_n6? '-moz-opacity:0.85;' : tt_ie? 'filter:Alpha(opacity=85);' : 'opacity:0.85;';
183
            t_y += '<div id="'+t_id+'R" style="position:absolute;background:'+t_shc+';left:'+t_w+'px;top:'+t_spct+'px;width:'+t_shw+'px;height:1px;overflow:hidden;'+t_optx+'"><\/div>' +
184
                '<div style="position:relative;background:'+t_shc+';left:'+t_spct+'px;top:0px;width:'+(t_w-t_spct)+'px;height:'+t_shw+'px;overflow:hidden;'+t_optx+'"><\/div>';
185
        }
186
    }
187
    return(t_y+'<\/div>' +
188
        (tt_ie ? '<iframe id="TTiEiFrM" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"><\/iframe>' : ''));
189
}
190
function tt_EvX(t_e)
191
{
192
    var t_y = tt_Int(t_e.pageX || t_e.clientX || 0) +
193
        tt_Int(tt_ie? tt_db.scrollLeft : 0) +
194
        tt_offX;
195
    if (t_y > xlim) t_y = xlim;
196
    var t_scr = tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0);
197
    if (t_y < t_scr) t_y = t_scr;
198
    return t_y;
199
}
200
function tt_EvY(t_e)
201
{
202
    var t_y = tt_Int(t_e.pageY || t_e.clientY || 0) +
203
        tt_Int(tt_ie? tt_db.scrollTop : 0);
204
    if (tt_sup) t_y -= (tt_objH + tt_offY - 15);
205
    else if (t_y > ylim || !tt_sub && t_y > ylim-24)
206
    {
207
        t_y -= (tt_objH + 5);
208
        tt_sub = false;
209
    }
210
    else
211
    {
212
        t_y += tt_offY;
213
        tt_sub = true;
214
    }
215
    return t_y;
216
}
217
function tt_ReleasMov()
218
{
219
    if (document.onmousemove == tt_Move)
220
    {
221
        if (!tt_mf && document.releaseEvents) document.releaseEvents(Event.MOUSEMOVE);
222
        document.onmousemove = tt_mf;
223
    }
224
}
225
function tt_ShowIfrm(t_x)
226
{
227
    if (!tt_ie6 || !tt_obj) return;
228
    tt_ifrm = document.getElementById("TTiEiFrM");
229
    //tt_obj.style.display = t_x? "block" : "none";
230
    if (t_x)
231
    {
232
        tt_ifrm.style.width = tt_objW+'px';
233
        tt_ifrm.style.height = tt_objH+'px';
234
        tt_ifrm.style.zIndex = tt_obj.style.zIndex - 1;
235
        tt_ifrm.style.display = "block";
236
    }
237
    else tt_ifrm.style.display = "none";
238
}
239
function tt_GetDiv(t_id)
240
{
241
    return(
242
        tt_n4? (document.layers[t_id] || null)
243
        : tt_ie? (document.all[t_id] || null)
244
        : (document.getElementById(t_id) || null)
245
    );
246
}
247
function tt_GetDivW()
248
{
249
    return tt_Int(
250
        tt_n4? tt_obj.clip.width
251
        : (tt_obj.style.pixelWidth || tt_obj.offsetWidth)
252
    );
253
}
254
function tt_GetDivH()
255
{
256
    return tt_Int(
257
        tt_n4? tt_obj.clip.height
258
        : (tt_obj.style.pixelHeight || tt_obj.offsetHeight)
259
    );
260
}
261
 
262
// Compat with DragDrop Lib: Ensure that z-index of tooltip is lifted beyond toplevel dragdrop element
263
function tt_SetDivZ()
264
{
265
    var t_i = tt_obj.style || tt_obj;
266
    if (window.dd && dd.z)
267
        t_i.zIndex = Math.max(dd.z+1, t_i.zIndex);
268
}
269
function tt_SetDivPos(t_x, t_y)
270
{
271
    var t_i = tt_obj.style || tt_obj;
272
    var t_px = (tt_op6 || tt_n4)? '' : 'px';
273
    t_i.left = (tt_objX = t_x) + t_px;
274
    t_i.top = (tt_objY = t_y) + t_px;
275
    if (tt_ifrm)
276
    {
277
        tt_ifrm.style.left = t_i.left;
278
        tt_ifrm.style.top = t_i.top;
279
    }
280
}
281
function tt_ShowDiv(t_x)
282
{
283
    if (tt_n4) tt_obj.visibility = t_x? 'show' : 'hide';
284
    else tt_obj.style.visibility = t_x? 'visible' : 'hidden';
285
    tt_act = t_x;
286
    tt_ShowIfrm(t_x);
287
}
288
function tt_OpDeHref(t_e)
289
{
290
    if (t_e && t_e.target.hasAttribute("href"))
291
    {
292
        tt_tag = t_e.target;
293
        tt_tag.t_href = tt_tag.getAttribute("href");
294
        tt_tag.removeAttribute("href");
295
        tt_tag.style.cursor = "hand";
296
        tt_tag.onmousedown = tt_OpReHref;
297
        tt_tag.stats = window.status;
298
        window.status = tt_tag.t_href;
299
    }
300
}
301
function tt_OpReHref()
302
{
303
    if (tt_tag)
304
    {
305
        tt_tag.setAttribute("href", tt_tag.t_href);
306
        window.status = tt_tag.stats;
307
        tt_tag = null;
308
    }
309
}
310
function tt_Show(t_e, t_id, t_sup, t_delay, t_fix, t_left, t_offx, t_offy, t_static, t_sticky, t_temp)
311
{
312
    if (tt_obj) tt_Hide();
313
    tt_mf = document.onmousemove || null;
314
    if (window.dd && (window.DRAG && tt_mf == DRAG || window.RESIZE && tt_mf == RESIZE)) return;
315
    var t_uf = document.onmouseup || null, t_sh, t_h;
316
    if (tt_mf && t_uf) t_uf(t_e);
317
 
318
    tt_obj = tt_GetDiv(t_id);
319
    if (tt_obj)
320
    {
321
        t_e = t_e || window.event;
322
        tt_sub = !(tt_sup = t_sup);
323
        tt_sticky = t_sticky;
324
        tt_objW = tt_GetDivW();
325
        tt_objH = tt_GetDivH();
326
        tt_offX = t_left? -(tt_objW+t_offx) : t_offx;
327
        tt_offY = t_offy;
328
        if (tt_op7) tt_OpDeHref(t_e);
329
        if (tt_n4)
330
        {
331
            if (tt_obj.document.layers.length)
332
            {
333
                t_sh = tt_obj.document.layers[0];
334
                t_sh.clip.height = tt_objH - Math.round(t_sh.clip.width*1.3);
335
            }
336
        }
337
        else
338
        {
339
            t_sh = tt_GetDiv(t_id+'R');
340
            if (t_sh)
341
            {
342
                t_h = tt_objH - tt_Int(t_sh.style.pixelTop || t_sh.style.top || 0);
343
                if (typeof t_sh.style.pixelHeight != tt_u) t_sh.style.pixelHeight = t_h;
344
                else t_sh.style.height = t_h+'px';
345
            }
346
        }
347
 
348
        xlim = tt_Int((tt_db && tt_db.clientWidth)? tt_db.clientWidth : window.innerWidth) +
349
            tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0) -
350
            tt_objW -
351
            (tt_n4? 21 : 0);
352
        ylim = tt_Int(window.innerHeight || tt_db.clientHeight) +
353
            tt_Int(window.pageYOffset || (tt_db? tt_db.scrollTop : 0) || 0) -
354
            tt_objH - tt_offY;
355
 
356
        tt_SetDivZ();
357
        if (t_fix) tt_SetDivPos(tt_Int((t_fix = t_fix.split(','))[0]), tt_Int(t_fix[1]));
358
        else tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
359
 
360
        var t_txt = 'tt_ShowDiv(\'true\');';
361
        if (t_sticky) t_txt += '{'+
362
                'tt_ReleasMov();'+
363
                'window.tt_upFunc = document.onmouseup || null;'+
364
                'if (document.captureEvents) document.captureEvents(Event.MOUSEUP);'+
365
                'document.onmouseup = new Function("window.setTimeout(\'tt_Hide();\', 10);");'+
366
            '}';
367
        else if (t_static) t_txt += 'tt_ReleasMov();';
368
        if (t_temp > 0) t_txt += 'window.tt_rtm = window.setTimeout(\'tt_sticky = false; tt_Hide();\','+t_temp+');';
369
        window.tt_rdl = window.setTimeout(t_txt, t_delay);
370
 
371
        if (!t_fix)
372
        {
373
            if (document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
374
            document.onmousemove = tt_Move;
375
        }
376
    }
377
}
378
var tt_area = false;
379
function tt_Move(t_ev)
380
{
381
    if (!tt_obj) return;
382
    if (tt_n6 || tt_w3c)
383
    {
384
        if (tt_wait) return;
385
        tt_wait = true;
386
        setTimeout('tt_wait = false;', 5);
387
    }
388
    var t_e = t_ev || window.event;
389
    tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
390
    if (tt_op6)
391
    {
392
        if (tt_area && t_e.target.tagName != 'AREA') tt_Hide();
393
        else if (t_e.target.tagName == 'AREA') tt_area = true;
394
    }
395
}
396
function tt_Hide()
397
{
398
    if (window.tt_obj)
399
    {
400
        if (window.tt_rdl) window.clearTimeout(tt_rdl);
401
        if (!tt_sticky || !tt_act)
402
        {
403
            if (window.tt_rtm) window.clearTimeout(tt_rtm);
404
            tt_ShowDiv(false);
405
            tt_SetDivPos(-tt_objW, -tt_objH);
406
            tt_obj = null;
407
            if (typeof window.tt_upFunc != tt_u) document.onmouseup = window.tt_upFunc;
408
        }
409
        tt_sticky = false;
410
        if (tt_op6 && tt_area) tt_area = false;
411
        tt_ReleasMov();
412
        if (tt_op7) tt_OpReHref();
413
    }
414
}
415
function tt_Init()
416
{
417
    if (!(tt_op || tt_n4 || tt_n6 || tt_ie || tt_w3c)) return;
418
 
419
    var htm = tt_n4? '<div style="position:absolute;"><\/div>' : '',
420
    tags,
421
    t_tj,
422
    over,
423
    esc = 'return escape(';
424
    var i = tt_tags.length; while(i--)
425
    {
426
        tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
427
            : document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
428
            : (!tt_n4 && tt_tags[i]=="a")? document.links
429
            : 1;
430
        if (tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")) tags = tt_N4Tags(tt_tags[i]);
431
        var j = tags.length; while(j--)
432
        {
433
            if (typeof (t_tj = tags[j]).onmouseover == "function" && t_tj.onmouseover.toString().indexOf(esc) != -1 && !tt_n6 || tt_n6 && (over = t_tj.getAttribute("onmouseover")) && over.indexOf(esc) != -1)
434
            {
435
                if (over) t_tj.onmouseover = new Function(over);
436
                var txt = unescape(t_tj.onmouseover());
437
                htm += tt_Htm(
438
                    t_tj,
439
                    "tOoLtIp"+i+""+j,
440
                    txt.wzReplace("& ","&")
441
                );
442
 
443
                t_tj.onmouseover = new Function('e',
444
                    'tt_Show(e,'+
445
                    '"tOoLtIp' +i+''+j+ '",'+
446
                    (typeof t_tj.T_ABOVE != tt_u)+','+
447
                    ((typeof t_tj.T_DELAY != tt_u)? t_tj.T_DELAY : ttDelay)+','+
448
                    ((typeof t_tj.T_FIX != tt_u)? '"'+t_tj.T_FIX+'"' : '""')+','+
449
                    (typeof t_tj.T_LEFT != tt_u)+','+
450
                    ((typeof t_tj.T_OFFSETX != tt_u)? t_tj.T_OFFSETX : ttOffsetX)+','+
451
                    ((typeof t_tj.T_OFFSETY != tt_u)? t_tj.T_OFFSETY : ttOffsetY)+','+
452
                    (typeof t_tj.T_STATIC != tt_u)+','+
453
                    (typeof t_tj.T_STICKY != tt_u)+','+
454
                    ((typeof t_tj.T_TEMP != tt_u)? t_tj.T_TEMP : ttTemp)+
455
                    ');'
456
                );
457
                t_tj.onmouseout = tt_Hide;
458
                if (t_tj.alt) t_tj.alt = "";
459
                if (t_tj.title) t_tj.title = "";
460
            }
461
        }
462
    }
463
    document.write(htm);
464
}