Salome HOME
Porting GUI documentation on Doxygen tool.
[modules/smesh.git] / doc / salome / gui / SMESH / whform.js
1 //      WebHelp 5.10.001
2 var gfunLookUp;
3 var gbInputEnable;
4 var gfunInit;
5 var gstrFormName= "";
6 var gbWithButton = false;
7 var gsTitle="";
8 var gsOverImage = "";
9 var gsOutImage = "";
10 var gsClickImage = "";
11 var gsText = "";
12 var gsBgColor = "#c0c0c0";
13 var gsBgImage = "";
14 var gbInImage = 0;
15 var gbInputEnable = 0;
16
17 var goTitleFont=null;
18 var goInputFont=null;
19 var goNormalFont=null;
20 var goHoverFont=null;
21 var gnType=-1;
22 var gbWhForm=false;
23
24 function setBackground(sBgImage)
25 {
26         if (sBgImage != null && sBgImage.length > 0)
27                 gsBgImage = sBgImage;
28
29         if  (gsBgImage  && gsBgImage .length > 0)
30         {
31                 document.body.background = gsBgImage ;
32         }
33 }
34
35 function setBackgroundcolor(sBgColor)
36 {
37         if (sBgColor != null && sBgColor.length > 0)
38                 gsBgColor = sBgColor;
39
40         if (gsBgColor&& gsBgColor.length > 0)
41         {
42                 document.body.bgColor = gsBgColor;
43         }
44 }
45
46 function setBtnType(sType)
47 {
48         if (sType == "image")
49         {
50                 gnType = 0;
51         }
52         else if (sType == "text")
53         {
54                 gnType = 1;
55         }
56 }
57
58 function setGoImage1(sImage1)
59 {
60         gsOutImage = sImage1;
61         if (gsOutImage && gsOutImage.length > 0)
62                 gbWithButton = true;
63 }
64
65 function setGoImage2(sImage2)
66 {
67         gsOverImage = sImage2;
68         if (gsOverImage && gsOverImage.length > 0)
69                 gbWithButton = true;
70 }
71
72 function setGoImage3(sImage3)
73 {
74         gsClickImage = sImage3;
75         if (gsClickImage && gsClickImage.length > 0)
76                 gbWithButton = true;
77 }
78
79 function setGoText(sText)
80 {
81         gsText = sText;
82         if (gsText.length > 0)
83                 gbWithButton = true;
84 }
85
86 function setFont(sType, sFontName, sFontSize, sFontColor, sFontStyle, sFontWeight, sFontDecoration)
87 {
88         var vFont = new whFont(sFontName, sFontSize, sFontColor, sFontStyle, sFontWeight, sFontDecoration);
89         if (sType == "Title")
90         {
91                 goTitleFont = vFont;
92                 var vFont1 = new whFont(sFontName, sFontSize, "black", sFontStyle, sFontWeight, sFontDecoration);
93                 goInputFont=vFont1;             
94         }
95         else if (sType == "Normal")
96                 goNormalFont = vFont;
97         else if (sType == "Hover")
98                 goHoverFont = vFont;
99 }
100
101 function writeFormStyle()
102 {
103         var sStyle = "<style type='text/css'>";
104         sStyle += "p.title {" + getFontStyle(goTitleFont) + "margin-top:0;margin-bottom:0}\n";
105         sStyle += ".inputfield {" + getFontStyle(goInputFont) +"width:100%; }\n";
106         sStyle+="A:link {"+getFontStyle(goNormalFont)+"}\n";
107         sStyle+="A:visited {"+getFontStyle(goNormalFont)+"}\n";
108         sStyle +="A:hover {"+getFontStyle(goHoverFont)+"}\n";
109         sStyle+=".clsFormBackground{\n";
110         if (gsBgImage)
111                 sStyle+="border-top:"+gsBgColor+" 1px solid;}\n";
112         else
113                 sStyle+="border-top:black 1px solid;}\n";
114
115         sStyle += "</style>";
116         document.write(sStyle);
117 }
118
119 function lookupKeyDown()
120 {
121         if (gbInputEnable)
122         {
123                 if (gbIE4)
124                 {
125                         if (event.keyCode == 13)        //Enter key
126                                 gfunLookUp(true);
127                         else
128                                 gfunLookUp(false);
129                 }                       
130                 else
131                         gfunLookUp(false);
132         }
133 }
134
135 function init()
136 {
137         if (gfunInit)
138                 gfunInit();
139         if (!window.Array)  return;
140                 document.onkeyup = lookupKeyDown;
141 }
142
143 function inputSubmit()
144 {
145         if ((gbInputEnable && !gbIE4)|| gbInImage)
146                 gfunLookUp(true);
147 }
148
149 function inputEnable(bEnable)
150 {
151         gbInputEnable = bEnable;
152 }
153
154 function inImage(bImage)
155 {
156         gbInImage = bImage;
157 }
158
159 function getFormHTML()
160 {
161         var sForm = "";
162         sForm += "<table class=\"clsFormBackground\" width=\"100%\" cellspacing=\"0\" cellpadding=\"5\" border=\"0\">";
163         sForm += "<form name=\"" + gstrFormName + "\" method=\"POST\" action=\"javascript:inputSubmit()\" style=\"width:100%\">";
164         sForm += "<tr>";
165         sForm += "<td>";
166         sForm += "<p class=title><nobr>" + gsTitle + "</nobr><br><table width=\"100%\"><tr valign=\"middle\"><td width=\"100%\"><input class=\"inputfield\" type=\"text\" name=\"keywordField\" onfocus=\"inputEnable(1);\" onblur=\"inputEnable(0);\"></td>";
167         if (gbWithButton && gnType >= 0)
168         {
169                 sForm += "<td><a title=\"submit button\" href=\"javascript:void(0);\" onclick=\"" + gstrFormName + ".submit(); return false;\" onfocus=\"inImage(1);\" onblur=\"inImage(0);\" onmouseup=\"onMouseUp();\" onmousedown=\"onMouseDown();\" onmouseover=\"onMouseOver();\" onmouseout=\"onMouseOut();\">"
170                 if (gnType == 0)
171                 {
172                         if (!gsText)
173                                 gsText="Go";
174                         sForm += "<img alt=\""+gsText+"\" id=\"go\" border=\"0\" src=\"" + gsOutImage + "\">";
175                 }
176                 else
177                         sForm += gsText ;
178                 sForm += "</a></td>";
179         }
180         sForm += "</tr></table></p></td></tr></form></table>";
181         return sForm;
182 }
183
184 function onMouseOver()
185 {
186         if (getElement("go") && gsOverImage)
187                 getElement("go").src = gsOverImage;
188 }
189
190 function onMouseDown()
191 {
192         if (getElement("go") && gsClickImage)
193                 getElement("go").src = gsClickImage;
194 }
195
196 function onMouseUp()
197 {
198         if (getElement("go") && gsOutImage)
199                 getElement("go").src = gsOutImage;
200 }
201
202 function onMouseOut()
203 {
204         if (getElement("go") && gsOutImage)
205                 getElement("go").src = gsOutImage;
206 }
207
208 if (window.gbWhUtil&&window.gbWhVer&&window.gbWhProxy&&window.gbWhMsg)
209 {
210         goTitleFont=new whFont("Arial", "9pt", "#000000", "normal", "normal", "none");
211         goNormalFont=new whFont("Arial", "9pt", "#000000", "normal", "normal", "none");
212         goHoverFont=new whFont("Arial", "9pt", "#000000", "normal", "normal", "underline");
213         gbWhForm=true;
214 }
215 else
216         document.location.reload();