adding some strings
[moodle-linuxchix.git] / mod / hotpot / template / v6 / hp6card.js_
blobe9eb06e49f0302e84f55d854eded66d50d33e30c
2 function Card(ID, OverlapTolerance){
3         this.elm=document.getElementById(ID);
4         this.name=ID;
5         this.css=this.elm.style;
6         this.elm.style.left = 0 +'px';
7         this.elm.style.top = 0 +'px';
8         this.HomeL = 0;
9         this.HomeT = 0;
10         this.tag=-1;
11         this.index=-1;
12         this.OverlapTolerance = OverlapTolerance;
15 function CardGetL(){return parseInt(this.css.left)}
16 Card.prototype.GetL=CardGetL;
18 function CardGetT(){return parseInt(this.css.top)}
19 Card.prototype.GetT=CardGetT;
21 function CardGetW(){return parseInt(this.elm.offsetWidth)}
22 Card.prototype.GetW=CardGetW;
24 function CardGetH(){return parseInt(this.elm.offsetHeight)}
25 Card.prototype.GetH=CardGetH;
27 function CardGetB(){return this.GetT()+this.GetH()}
28 Card.prototype.GetB=CardGetB;
30 function CardGetR(){return this.GetL()+this.GetW()}
31 Card.prototype.GetR=CardGetR;
33 function CardSetL(NewL){this.css.left = NewL+'px'}
34 Card.prototype.SetL=CardSetL;
36 function CardSetT(NewT){this.css.top = NewT+'px'}
37 Card.prototype.SetT=CardSetT;
39 function CardSetW(NewW){this.css.width = NewW+'px'}
40 Card.prototype.SetW=CardSetW;
42 function CardSetH(NewH){this.css.height = NewH+'px'}
43 Card.prototype.SetH=CardSetH;
45 function CardInside(X,Y){
46         var Result=false;
47         if(X>=this.GetL()){if(X<=this.GetR()){if(Y>=this.GetT()){if(Y<=this.GetB()){Result=true;}}}}
48         return Result;
50 Card.prototype.Inside=CardInside;
52 function CardSwapColours(){
53         var c=this.css.backgroundColor;
54         this.css.backgroundColor=this.css.color;
55         this.css.color=c;
57 Card.prototype.SwapColours=CardSwapColours;
59 function CardHighlight(){
60         this.css.backgroundColor='[strTextColor]';
61         this.css.color='[strExBGColor]';
63 Card.prototype.Highlight=CardHighlight;
65 function CardUnhighlight(){
66         this.css.backgroundColor='[strExBGColor]';
67         this.css.color='[strTextColor]';
69 Card.prototype.Unhighlight=CardUnhighlight;
71 function CardOverlap(OtherCard){
72         var smR=(this.GetR()<(OtherCard.GetR()+this.OverlapTolerance))? this.GetR(): (OtherCard.GetR()+this.OverlapTolerance);
73         var lgL=(this.GetL()>OtherCard.GetL())? this.GetL(): OtherCard.GetL();
74         var HDim=smR-lgL;
75         if (HDim<1){return 0;}
76         var smB=(this.GetB()<OtherCard.GetB())? this.GetB(): OtherCard.GetB();
77         var lgT=(this.GetT()>OtherCard.GetT())? this.GetT(): OtherCard.GetT();
78         var VDim=smB-lgT;
79         if (VDim<1){return 0;}
80         return (HDim*VDim);     
82 Card.prototype.Overlap=CardOverlap;
84 function CardDockToR(OtherCard){
85         this.SetL(OtherCard.GetR() + 5);
86         this.SetT(OtherCard.GetT());
89 Card.prototype.DockToR=CardDockToR;
91 function CardSetHome(){
92         this.HomeL=this.GetL();
93         this.HomeT=this.GetT();
95 Card.prototype.SetHome=CardSetHome;
97 function CardGoHome(){
98         this.SetL(this.HomeL);
99         this.SetT(this.HomeT);
102 Card.prototype.GoHome=CardGoHome;
105 function doDrag(e) {
106         if (CurrDrag == -1) {return};
107         if (C.ie){var Ev = window.event}else{var Ev = e}
108         var difX = Ev.clientX-window.lastX; 
109         var difY = Ev.clientY-window.lastY; 
110         var newX = DC[CurrDrag].GetL()+difX; 
111         var newY = DC[CurrDrag].GetT()+difY; 
112         DC[CurrDrag].SetL(newX); 
113         DC[CurrDrag].SetT(newY);
114         window.lastX = Ev.clientX; 
115         window.lastY = Ev.clientY; 
116         return false;
119 function beginDrag(e, DragNum) { 
120         CurrDrag = DragNum;
121         if (C.ie){
122                 var Ev = window.event;
123                 document.onmousemove=doDrag;
124                 document.onmouseup=endDrag;
125         }
126         else{
127                 var Ev = e;
128                 window.onmousemove=doDrag; 
129                 window.onmouseup=endDrag;
130         } 
131         DC[CurrDrag].Highlight();
132         topZ++;
133         DC[CurrDrag].css.zIndex = topZ;
134         window.lastX=Ev.clientX; 
135         window.lastY=Ev.clientY;
136         return false;  
139 function endDrag(e) { 
140         if (CurrDrag == -1) {return};
141         DC[CurrDrag].Unhighlight();
142         if (C.ie){document.onmousemove=null}else{window.onmousemove=null;}
143         onEndDrag();    
144         CurrDrag = -1;
145 //Need a bugfix for Opera focus problem here
146         if (C.opera){FocusAButton();}
147         return true;
150 var CurrDrag = -1;
151 var topZ = 100;