source: extensions/LLGBO2/js/sweettitlesn_comment.js @ 12114

Last change on this file since 12114 was 4713, checked in by EXFTB, 14 years ago

Avoid problems with Gally

  • Property svn:eol-style set to LF
File size: 3.7 KB
Line 
1/*
2Sweet Titles (c) Creative Commons 2005
3http://creativecommons.org/licenses/by-sa/2.5/
4Author: Dustin Diaz | http://www.dustindiaz.com
5Revision:ex-ftb 2006*/
6var sweetTitles = { 
7        xCord : 0,                                                             
8        yCord : 0,                                                             
9        tipElements : ['a','img','span','area'],                       
10        obj : Object,                                                   
11        x : Object,                                                     
12        init : function() {
13                if ( !document.getElementById ||
14                        !document.createElement ||
15                        !document.getElementsByTagName ) {return;       }
16                var i,j,Over;
17                this.x = document.createElement('div'); 
18                this.x.id = 'toolTip';
19                document.getElementsByTagName('body')[0].appendChild(this.x);
20                this.x.style.top = '0';
21                this.x.style.visibility = 'hidden';
22                var tipLen = this.tipElements.length;
23                for ( i=0; i<tipLen; i++ ) {
24                        var Elms = document.getElementsByTagName(this.tipElements[i]);
25                        var curLen = Elms.length;
26                        for ( j=0; j<curLen; j++ ) {
27                                var el= Elms[j];
28                                   if (el.className  != 'navThumb') // pas de tooltip sur nav thumb
29                                        { var tv = el.getAttribute('title')
30                                                if ( tv != null && tv != "null" && tv !="")  //chrome
31                                                 {addEvent(el,'mouseover',this.tipOver);
32                                                        addEvent(el,'mousemove',this.tipMouseMove);
33                                                        addEvent(el,'mouseout',this.tipOut);
34                                                        var sv = el.getAttribute('swttips');
35                                                        el.setAttribute('tiptitle', tv);
36                                                        el.setAttribute('tipswt', sv );
37                                                        el.removeAttribute('title'); 
38                                                        el.removeAttribute('swttips');}
39                                                el.removeAttribute('alt');}
40                                        }
41                }
42        },
43
44        updateXY : function(e) {
45                if ( document.captureEvents ) {
46                        sweetTitles.xCord = e.pageX;
47                        sweetTitles.yCord = e.pageY;
48                } else if ( window.event.clientX ) {
49                        sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft;
50                        sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop;}
51        },
52        tipOut: function() {
53                if ( window.tID ) {
54                        clearTimeout(tID);              }
55                if ( window.opacityID ) {
56                        clearTimeout(opacityID);}
57                sweetTitles.x.style.visibility = 'hidden';},
58        checkNode : function() {
59                var trueObj = this.obj;
60                if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
61                        return trueObj;
62                } else {return trueObj.parentNode;}
63        },
64        tipOver : function(e) {sweetTitles.obj = this;
65        tID = window.setTimeout("sweetTitles.tipShow()",100);
66         sweetTitles.updateXY(e);},
67       
68        tipMouseMove : function(e) {sweetTitles.updateXY(e); sweetTitles.tipMove();},
69       
70        tipShow : function() {                 
71                var anch = this.checkNode();
72                this.x.innerHTML ="";
73         this.x.innerHTML = "<p class='title'> <span> "+anch.getAttribute('tiptitle')+"</span></p>";
74                sv = anch.getAttribute('tipswt');
75                if (( sv != "null" )&& (sv !="")) // for chrome
76                {this.x.innerHTML= this.x.innerHTML + "<p>" + anch.getAttribute('tipswt') + "</p>"; }
77                sweetTitles.Move;
78                var T = this.x.style;
79                T.visibility = 'visible';
80                T.opacity = '.1';
81                this.tipFade(10);       },
82       
83        tipMove: function()
84        { var scrX = Number(this.xCord);
85                var scrY = Number(this.yCord);
86                var tp = parseInt(scrY+8);
87                var lt = parseInt(scrX+8);
88                var D = document.documentElement;
89                var T = this.x.style;
90                if ( parseInt(D.clientWidth+D.scrollLeft) < parseInt(this.x.offsetWidth+lt) ) {
91                        T.left = parseInt(lt-(this.x.offsetWidth+3))+'px';
92                } else {
93                        T.left = lt+'px';               }
94                if ( parseInt(D.clientHeight+D.scrollTop) < parseInt(this.x.offsetHeight+tp) ) {
95                        T.top = parseInt(tp-(this.x.offsetHeight+3))+'px';
96                } else {T.top = tp+'px';                }
97        },
98        tipFade: function(opac) {
99                var passed = parseInt(opac);
100                var newOpac = parseInt(passed+10);
101                 T = this.x.style;
102                if ( newOpac < 92 ) {
103                        T.opacity = '.'+newOpac;
104                        T.filter = "alpha(opacity:"+newOpac+")";
105                        opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",20);}
106                else { T.opacity = '.92';
107                        T.filter = "alpha(opacity:92)";         }
108        }
109};
110function pageLoader() { sweetTitles.init();}
111addEvent2(window,'load',pageLoader);
Note: See TracBrowser for help on using the repository browser.