/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to js/tooltip.js

  • Committer: Suren A. Chilingaryan
  • Date: 2011-03-15 02:47:05 UTC
  • mfrom: (210.1.3 adei)
  • Revision ID: csa@dside.dyndns.org-20110315024705-qljn30gwin8yrkne
Integration of work of students with fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function TOOLTIP(divid)
 
2
 
3
  this.isInit = false;
 
4
  this.div;
 
5
  this.divWidth;
 
6
  this.divHeight;
 
7
  this.xincr=10,yincr=10;
 
8
  this.animateToolTip = false;
 
9
  this.isAnimated = false/*true*/; 
 
10
  this.aniSpeed = 10;    
 
11
  this.Init(divid);  
 
12
  this.visible = false;
 
13
  
 
14
}  
 
15
    
 
16
  TOOLTIP.prototype.SetHTML = function(strHTML){
 
17
    html = strHTML;
 
18
    this.div.innerHTML=html;
 
19
  }
 
20
 
 
21
  TOOLTIP.prototype.Hide = function(){
 
22
    this.div.style.display='none';   
 
23
    this.div.style.height= "0px";
 
24
    this.div.style.width= "0px";
 
25
    this.visible = false;   
 
26
    if(this.det)this.SetHTML("Loading...");
 
27
  }
 
28
  
 
29
  TOOLTIP.prototype.Show = function(e,dl_id,det){
 
30
    this.det = det;
 
31
    e = e ? e : event;    
 
32
    if(this.visible != false) {
 
33
      this.Hide();      
 
34
      return;  
 
35
    }
 
36
    if(this.isInit != true) return;    
 
37
 
 
38
    var height,width,newPosx,newPosy, coordX, coordY;
 
39
    if(typeof( document.documentElement.clientWidth ) == 'number' ){
 
40
      width = document.body.clientWidth;
 
41
      height = document.body.clientHeight;
 
42
    }else{
 
43
      width = parseInt(window.innerWidth);
 
44
      height = parseInt(window.innerHeight);
 
45
    }
 
46
 
 
47
    var positions = getPosition(e);
 
48
     
 
49
    coordX=positions.x;
 
50
    coordY=positions.y;   
 
51
    
 
52
    if((coordX > this.divWidth+20) )
 
53
      newPosx = coordX-this.divWidth-20;
 
54
    else
 
55
      newPosx = coordX-this.divWidth+60;      
 
56
    
 
57
    if(this.divHeight + 40 < coordY)
 
58
      newPosy= coordY-this.divHeight-40;
 
59
    else
 
60
      newPosy = coordY+40;
 
61
    
 
62
 
 
63
    this.div.style.display='block';
 
64
    this.div.style.top= newPosy + "px";
 
65
    this.div.style.left= newPosx + "px"
 
66
    this.div.style.height= this.divHeight + "px";
 
67
    this.div.style.width= this.divWidth + "px";
 
68
    if(!this.det)this.div.style.backgroundImage = "url(tmp/downloads/images/"+dl_id+".png)";    
 
69
    this.div.focus(); 
 
70
    if(this.det)adei.UpdateDIV(this.div, "services/download.php?target=dlmanager_details&dl_id="+dl_id, "downloaddetails", false);      
 
71
    if(this.animateToolTip) {
 
72
      this.div.style.height= "0px";
 
73
      this.div.style.width= "0px";
 
74
      tooltipAnimate(this.div.id,this.divHeight,this.divWidth); 
 
75
    }
 
76
    this.visible = true;
 
77
  }
 
78
 
 
79
  function getPosition(e) {
 
80
    e = e || window.event;
 
81
    var positions = {x:0, y:0};
 
82
    if (e.pageX || e.pageY) {
 
83
        positions.x = e.pageX;
 
84
        positions.y = e.pageY;
 
85
    } 
 
86
    else {
 
87
        var de = document.documentElement;
 
88
        var b = document.body;
 
89
        positions.x = e.clientX + 
 
90
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
 
91
        positions.y = e.clientY + 
 
92
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
 
93
    }
 
94
    return positions;
 
95
  }
 
96
 
 
97
  TOOLTIP.prototype.Init = function(id){
 
98
   this.div = document.getElementById(id);
 
99
   if(this.div==null) return;
 
100
   
 
101
   if((this.div.style.width=="" || this.div.style.height=="")){
 
102
     alert("Error: Downloadmanager graph div needs width and height");
 
103
     return;
 
104
    }
 
105
     
 
106
   this.divWidth = parseInt(this.div.style.width);
 
107
   this.divHeight= parseInt(this.div.style.height);
 
108
   if(this.div.style.visibility!="visible")this.div.style.visibility="visible";
 
109
   if(this.div.style.display!="none")this.div.style.display="none";
 
110
   if(this.div.style.position!="absolute")this.div.style.position="absolute";
 
111
   
 
112
   if(this.isAnimated && this.aniSpeed > 0){
 
113
    xincr = parseInt(divWidth/this.aniSpeed);
 
114
    yincr = parseInt(divHeight/this.aniSpeed);    
 
115
    this.animateToolTip = true;
 
116
   }
 
117
        
 
118
   this.isInit = true; 
 
119
   
 
120
  } 
 
121
 
 
122
  /*  
 
123
  function tooltipAnimate(a,aheight,awidth){ 
 
124
    a = document.getElementById(a);         
 
125
    var tw = parseInt(a.style.width)+xincr ;
 
126
    var th = parseInt(a.style.height)+yincr; 
 
127
    
 
128
    if(tw <= awidth){
 
129
      a.style.width = tw+"px";
 
130
    }
 
131
    else{
 
132
      a.style.width = awidth+"px";
 
133
    }
 
134
    
 
135
    if(th <= aheight){
 
136
      a.style.height = th+"px";
 
137
    }
 
138
    else{
 
139
      a.style.height = aheight+"px";
 
140
    }
 
141
    
 
142
    if(!((tw > awidth) && (th > aheight)))      
 
143
    setTimeout( "tooltipAnimate('"+a.id+"',"+aheight+","+awidth+")",1);
 
144
  }
 
145
   */