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