Salome HOME
Porting GUI documentation on Doxygen tool.
[modules/smesh.git] / doc / salome / gui / SMESH / whghost.js
1 //      WebHelp 5.10.004
2 var gbXML=false;
3 var gaDef=new Array();
4 var gsBgColor="#ffffff";
5 var gsBgImage="";
6 var goFont=null;
7 var goHoverFont=null;
8 var gsMargin="2pt";
9 var gsIndent="2pt";
10 var gsActiveBgColor="#cccccc";
11 var gbWhGHost=false;
12 var gbShowDef=true;
13 var gsGloId="Glo_"
14
15 function setBackground(sBgImage)
16 {
17         gsBgImage=sBgImage;
18 }
19
20 function setBackgroundcolor(sBgColor)
21 {
22         gsBgColor=sBgColor;
23 }
24
25 function setFont(sType,sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration)
26 {
27         var vFont=new whFont(sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration);
28         if(sType=="Normal")
29                 goFont=vFont;
30         else if(sType=="Hover")
31                 goHoverFont=vFont;
32 }
33
34 function setActiveBgColor(sBgColor)
35 {
36         gsActiveBgColor=sBgColor;
37 }
38
39 function setMargin(sMargin)
40 {
41         gsMargin=sMargin;
42 }
43
44 function setIndent(sIndent)
45 {
46         gsIndent=sIndent;
47 }
48
49 function insertDef(sKName,sDef)
50 {
51         var nLength=gaDef.length
52         var oGlo=new nameDefPair(sKName,sDef);
53         gaDef[nLength]=oGlo;
54         return nLength;
55 }
56
57 function showDef(nDef)
58 {
59         if(nDef<gaDef.length)
60         {       
61                 HighLight(nDef);
62                 var oParam=gaDef[nDef];
63                 var oMsg=new whMessage(WH_MSG_SHOWGLODEF,this,1,oParam);
64                 SendMessage(oMsg);
65         }
66 }
67
68 function nameDefPair(sName,sDef)
69 {
70         this.sName=sName;
71         this.sDef=sDef;
72 }
73
74 function mergeItems(oHTML,bDown,aDataCon,aCurIdxSet,nLength,aPos,nLevel)
75 {
76         var sHTML="";
77         var nIdxSet=aCurIdxSet[0];
78         var nIIdx=aPos[nIdxSet];
79         var sRawKName = getItemName(aDataCon,nIdxSet,nIIdx);
80         var sKName=_textToHtml(sRawKName);
81         var sDText=_textToHtml_nonbsp(getDef(aDataCon,nIdxSet,nIIdx));
82         var sDef=sDText;
83         for(var i=1;i<nLength;i++)
84         {
85                 var nIdxSeti=aCurIdxSet[i];
86                 var nIIdxi=aPos[nIdxSeti];
87                 var sRawKNamei = getItemName(aDataCon,nIdxSeti,nIIdxi);
88                 var sKNamei=_textToHtml(sRawKNamei);
89                 var sDTexti=_textToHtml_nonbsp(getDef(aDataCon,nIdxSeti,nIIdxi));
90                 if (compare(sKNamei,sKName)==0)
91                 {
92                         if (sDText!=sDTexti)
93                                 sDef+="<br>"+sDTexti;
94                 }
95         }
96         var nIndex=insertDef(sKName,sDef);
97         if(nLevel==1)
98         {
99                 sHTML+="<p><nobr id=\""+getGloId(nIndex)+"\">";
100                 sHTML+="<a alt=\""+sKName+"\" href=\"javascript:void(0);\" onfocus=\"HighLight("+nIndex+");\" onclick=\"showDef("+nIndex+");return false;\">"+sKName+"</a></nobr></p>";
101                 oHTML.addHTML(sHTML,nLength,bDown,true,sRawKName);
102                 if(gbShowDef)
103                 {
104                         setTimeout("showDef(0);",100);
105                         gbShowDef = false;
106                 }
107         }
108 }
109
110 function HighLight(nIndex)
111 {
112         var oObj=getElement(getGloId(nIndex));
113         if(oObj)
114                 HighLightElement(oObj,gsActiveBgColor,"transparent");
115 }
116
117 function getGloId(nIndex)
118 {
119         return gsGloId+nIndex;
120 }
121
122 function adjustPosition(bDown,aDataCon,aCurIdxSet,nLength,aPos)
123 {
124         if(bDown)
125         {
126                 for(var i=0;i<nLength;i++)
127                         aPos[aCurIdxSet[i]]++;
128         }
129         else{
130                 for(var i=0;i<nLength;i++)
131                         aPos[aCurIdxSet[i]]--;
132         }
133 }
134
135 function getDef(aDataCon,nIdxSet,nIIdx)
136 {
137         if(nIdxSet<aDataCon.length&&aDataCon[nIdxSet].aKs.length>nIIdx)
138                 return aDataCon[nIdxSet].aKs[nIIdx].sDef;
139         else
140                 return null;
141 }
142
143 function getItemName(aDataCon,nIdxSet,nIIdx)
144 {
145         if(nIdxSet<aDataCon.length&&aDataCon[nIdxSet].aKs.length>nIIdx)
146                 return aDataCon[nIdxSet].aKs[nIIdx].sName;
147         else
148                 return null;
149 }
150
151 function window_OnLoad()
152 {
153         if(gsBgImage&&gsBgImage.length>0)
154                 document.body.background=gsBgImage;
155         if(gsBgColor&&gsBgColor.length>0)
156                 document.body.bgColor=gsBgColor;
157         document.body.insertAdjacentHTML("beforeEnd",writeLoadingDiv());
158         loadGlo();
159         var oMsg=new whMessage(WH_MSG_SHOWGLO,this,1,null)
160         SendMessage(oMsg);
161 }
162
163 function loadGlo()
164 {
165         if(!gbReady)
166         {
167                 var oResMsg=new whMessage(WH_MSG_GETPROJINFO,this,1,null);
168                 if(SendMessage(oResMsg)&&oResMsg.oParam)
169                 {
170                         gbReady=true;
171                         var oProj=oResMsg.oParam;
172                         var aProj=oProj.aProj;
173                         gbXML=oProj.bXML;
174                         if(aProj.length>0)
175                         {
176                                 var sLangId=aProj[0].sLangId;
177                                 for(var i=0;i<aProj.length;i++)
178                                 {
179                                         if(aProj[i].sGlo&&aProj[i].sLangId==sLangId)
180                                                 addProjInfo(aProj[i].sPPath,aProj[i].sDPath,aProj[i].sGlo);
181                                 }
182                         }
183                         writeDataIFrame();
184                         enEvt();
185                 }               
186         }
187 }
188
189 function findCKInDom()
190 {
191         return true;
192 }
193
194 function GloWriteClassStyle()
195 {
196         var sStyle="<STYLE TYPE='text/css'>\n";
197         if (gsBgImage)
198                 sStyle+="body {border-top:"+gsBgColor+" 1px solid;}\n";
199         else
200                 sStyle+="body {border-top:black 1px solid;}\n";
201         sStyle+="P {"+getFontStyle(goFont)+"margin-top:"+gsMargin+";margin-bottom:"+gsMargin+";margin-left:"+gsIndent+";}\n";
202         sStyle+="A:link {"+getFontStyle(goFont)+"}\n";
203         sStyle+="A:visited {"+getFontStyle(goFont)+"}\n";
204         sStyle+="A:active {background-color:"+gsActiveBgColor+";}\n";
205         sStyle+="A:hover {"+getFontStyle(goHoverFont)+"}\n";
206         sStyle+="</STYLE>";     
207         document.write(sStyle);
208 }
209
210 function window_Unload()
211 {
212         UnRegisterListener2(this,WH_MSG_PROJECTREADY);
213         UnRegisterListener2(this,WH_MSG_SHOWGLO);
214 }
215
216 function onSendMessage(oMsg)
217 {
218         if(oMsg)
219         {
220                 var nMsgId=oMsg.nMessageId;
221                 if(nMsgId==WH_MSG_SHOWGLO)
222                 {
223                         if(!gbNav6)
224                                 document.body.focus();
225                 }
226                 else if(nMsgId==WH_MSG_PROJECTREADY)
227                 {
228                         loadGlo();
229                 }
230         }
231         return true;
232 }
233
234 if (window.gbWhUtil&&window.gbWhProxy&&window.gbWhVer&&window.gbWhLang&&window.gbWhMsg&&window.gbWhHost)
235 {
236         RegisterListener2(this,WH_MSG_PROJECTREADY);
237         RegisterListener2(this,WH_MSG_SHOWGLO);
238         goFont=new whFont("Verdana","8pt","#000000","normal","normal","none");
239         goHoverFont=new whFont("Verdana","8pt","#007f00","normal","normal","underline");
240         window.onload=window_OnLoad;
241         window.onbeforeunload=window_BUnload;
242         window.onunload=window_Unload;
243         gbWhGHost=true;
244 }
245 else
246         document.location.reload();
247