Mercurial > hg > digilib-old
comparison xul/menu.js @ 97:041340d1b00e
Initial revision
author | engler |
---|---|
date | Mon, 05 May 2003 18:42:58 +0200 |
parents | |
children | ecee3ff2f4d0 |
comparison
equal
deleted
inserted
replaced
96:b5debb2b2404 | 97:041340d1b00e |
---|---|
1 /* | |
2 Copyright (C) 2003 WTWG, Uni Bern | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
17 | |
18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 | |
19 */ | |
20 function rotate() { | |
21 value = prompt("Enter absolute rotation angle in degrees (clockwise orientation) :"); | |
22 | |
23 if (value) { | |
24 window.content.rotation(value); | |
25 } | |
26 } | |
27 | |
28 function color_add() { | |
29 | |
30 value = prompt("Enter the values you like to add to the red, green and blue color channel.\n\nFormat is R/G/B, where R,G,B are floating numbers between -255 and +255."); | |
31 | |
32 if (value) { | |
33 | |
34 values = value.split("/"); | |
35 | |
36 if (values.length != 3) alert("Illegal format"); | |
37 else if ((values[0] < -255) || (values[0] > 255)) alert("Illegal value for red"); | |
38 else if ((values[1] < -255) || (values[1] > 255)) alert("Illegal value for green"); | |
39 else if ((values[2] < -255) || (values[2] > 255)) alert("Illegal value for blue"); | |
40 | |
41 else window.content.rgba(value); | |
42 | |
43 } | |
44 } | |
45 | |
46 function color_multiply() { | |
47 | |
48 value = prompt("Enter the values you like to multiply with the different color channels.\n\nFormat is R/G/B, where R,G,B are floating numbers bigger than 0."); | |
49 | |
50 if (value) { | |
51 | |
52 values = value.split("/"); | |
53 | |
54 if (values.length != 3) alert("Illegal format"); | |
55 else if (values[0] < 0) alert("Illegal value for red"); | |
56 else if (values[1] < 0) alert("Illegal value for green"); | |
57 else if (values[2] < 0) alert("Illegal value for blue"); | |
58 | |
59 else window.content.rgbm(value); | |
60 | |
61 } | |
62 } | |
63 | |
64 function showMetadata(myurl){ | |
65 var arrUrl=myurl.split("?"); | |
66 var strDigilib=arrUrl[0]; | |
67 var strParams=arrUrl[1]; | |
68 var strArguments=strParams.split("&"); | |
69 var strDocDir=""; | |
70 for (i=0;i<strArguments.length;i++){ | |
71 var strArg=strArguments[i]; | |
72 var intPos=strArg.indexOf("fn="); | |
73 if (intPos>=0){ | |
74 strDocDir=strArg.substr(intPos+3); | |
75 } | |
76 } | |
77 if (strDocDir == ""){ | |
78 alert("no metadata available"); | |
79 }else{ | |
80 window.open("showMetadata.jsp?docdir="+strDocDir,"Metadata "+strDocDir,"menubar=no scrollbars=yes height=400 width=600"); | |
81 } | |
82 } | |
83 | |
84 | |
85 function checkBrowser() { | |
86 | |
87 this.ua = navigator.userAgent; | |
88 this.ver = navigator.appVersion; | |
89 this.dom = ( document.getElementById ); | |
90 this.opera = ( this.dom ) && ( this.ua.toLowerCase().indexOf("opera") > -1 ); | |
91 this.ie4 = ( document.all ) && ( !this.dom ); | |
92 this.ie5 = ( this.ver.indexOf("MSIE 5") > -1 ) && ( this.dom ); | |
93 this.ie6 = ( this.ver.indexOf("MSIE 6") > -1 ) && ( this.dom ); | |
94 this.ns4 = ( document.layers ) && ( !this.dom ); | |
95 this.ns6 = ( this.dom ) && ( parseInt(this.ver) >= 5 ) && ( !this.opera ); | |
96 this.ns = this.ns4 || this.ns6; | |
97 this.ie = this.ie4 || this.ie5 || this.ie6; | |
98 | |
99 return this; | |
100 } | |
101 | |
102 browser = new checkBrowser(); | |
103 | |
104 function overButton(n) { | |
105 if (showHelp) contextHelp(n); | |
106 } | |
107 | |
108 | |
109 // just to be sure, that no buffer overflow can arrive | |
110 var semaphor = true; | |
111 | |
112 function contextHelp(n) { | |
113 | |
114 if (helpWindow.closed) { | |
115 changeHelp(); | |
116 return; | |
117 } | |
118 | |
119 if ((navigator.appVersion.indexOf("Macintosh") < 0) && semaphor) { | |
120 semaphor = false; | |
121 | |
122 var tmpHelp = helpText[n]; | |
123 tmpHelp = tmpHelp.replace(/\(br\)/,"<br>"); | |
124 var help = tmpHelp.split("|"); | |
125 | |
126 helpWindow.focus(); | |
127 helpWindow.document.open(); | |
128 helpWindow.document.write('<html><head><title>Context Help</title>'); | |
129 helpWindow.document.write('<style type="text/css">'); | |
130 helpWindow.document.write('.title {font-family: Verdana, sans-serif, Arial; font-size: 12px; font-weight: bold; color: #FFFFFF}'); | |
131 helpWindow.document.write('.text {font-family: Verdana, sans-serif, Arial; font-size: 10px; color: #000000}'); | |
132 helpWindow.document.write('</style></head><body bgcolor="#CCCCCC" leftmargin="7" topmargin="7" marginwidth="7" marginheight="7" onload="opener.semaphor = true;">'); | |
133 helpWindow.document.write('<table width="99%" border="0" cellspacing="0" cellpadding="3"><tr><td bgcolor="#666666" class="title">'); | |
134 helpWindow.document.write(help[0] + '</tr><tr><td class="text">'); | |
135 helpWindow.document.write(help[1] + '</tr></td></table></body></html>'); | |
136 helpWindow.document.close(); | |
137 | |
138 | |
139 // stupid workaround because of netscape 6, that doesen't know the opener property | |
140 // this workaround is still ok because netscape 6 has eventbuffer checks so no overflow | |
141 if (browser.ns6) { | |
142 semaphor = true; | |
143 } | |
144 | |
145 // next stupid workaround because of opera 6, that somehow don't start the 'onLoad'- | |
146 // attribute in the body tag (the helpwindow does not finish loading) | |
147 if (browser.opera) { | |
148 setTimeout("semaphor = true;", 50); | |
149 } | |
150 | |
151 } | |
152 | |
153 } | |
154 | |
155 function openContextHelp() { | |
156 if (navigator.appVersion.indexOf("Macintosh") > -1) { | |
157 openContextHelpMac(); | |
158 return; | |
159 } | |
160 | |
161 semaphor = false; | |
162 | |
163 var winWidth = 270; | |
164 var winHeight = 130; | |
165 | |
166 var xScreen = 0.9*(screen.width-winWidth); | |
167 var yScreen = 0.8*(screen.height-winHeight); | |
168 | |
169 helpWindow = window.open("", "ContextHelp", "width=" + winWidth + ",height=" + winHeight + ",screenX=" + xScreen + ",screenY=" + yScreen + ",left=" + xScreen + ",top=" + yScreen); | |
170 | |
171 helpWindow.focus(); | |
172 helpWindow.document.open(); | |
173 helpWindow.document.write('<html><head><title>Context Help</title>'); | |
174 helpWindow.document.write('<style type="text/css">'); | |
175 helpWindow.document.write('.title {font-family: Verdana, sans-serif, Arial; font-size: 12px; font-weight: bold; color: #FFFFFF}'); | |
176 helpWindow.document.write('.text {font-family: Verdana, sans-serif, Arial; font-size: 10px; color: #000000}'); | |
177 helpWindow.document.write('</style></head><body bgcolor="#CCCCCC" leftmargin="7" topmargin="7" marginwidth="7" marginheight="7">'); | |
178 helpWindow.document.write('<table width="99%" border="0" cellspacing="0" cellpadding="3"><tr><td bgcolor="#666666" class="title">'); | |
179 helpWindow.document.write('Context Help</tr><tr><td class="text">'); | |
180 helpWindow.document.write('Move over any button to get some more information about its function</tr></td></table></body></html>'); | |
181 helpWindow.document.close(); | |
182 | |
183 // for some safety reason help-requests have to be blocked while opening the window | |
184 setTimeout("semaphor = true;", 200); | |
185 } | |
186 | |
187 // because macs have a strange window focus behaviour we have to go a special | |
188 | |
189 // way for them - just opening a window that contains all button-descriptions | |
190 | |
191 function openContextHelpMac() { | |
192 | |
193 var winWidth = 270; | |
194 var winHeight = 600; | |
195 | |
196 var xScreen = 0.9*(screen.width-winWidth); | |
197 var yScreen = 0.8*(screen.height-winHeight); | |
198 | |
199 helpWindow = window.open("", "ContextHelp", "width=" + winWidth + ",height=" + winHeight + ",screenX=" + xScreen + ",screenY=" + yScreen + ",left=" + xScreen + ",top=" + yScreen + ",scrollbars"); | |
200 | |
201 helpWindow.focus(); | |
202 helpWindow.document.open(); | |
203 helpWindow.document.write('<html><head><title>Context Help Macintosh</title>'); | |
204 helpWindow.document.write('<style type="text/css">'); | |
205 helpWindow.document.write('.title {font-family: Verdana, sans-serif, Arial; font-size: 12px; font-weight: bold; color: #FFFFFF}'); | |
206 helpWindow.document.write('.text {font-family: Verdana, sans-serif, Arial; font-size: 10px; color: #000000}'); | |
207 helpWindow.document.write('</style></head><body bgcolor="#CCCCCC" leftmargin="7" topmargin="7" marginwidth="7" marginheight="7">'); | |
208 helpWindow.document.write('<table width="99%" border="0" cellspacing="0" cellpadding="3">'); | |
209 | |
210 for (n = 0; n < helpText.length; n++) { | |
211 | |
212 help = helpText[n].split("|"); | |
213 helpWindow.document.write('<tr><td bgcolor="#666666" class="title">'); | |
214 helpWindow.document.write(help[0] + '</tr><tr><td class="text">'); | |
215 helpWindow.document.write('<p>' + help[1] + '<br> </p></tr></td>'); | |
216 } | |
217 | |
218 helpWindow.document.write('</table></body></html>'); | |
219 helpWindow.document.close(); | |
220 } | |
221 | |
222 function closeContextHelp() { | |
223 if (helpWindow != '' && !helpWindow.closed) { | |
224 helpWindow.close(); | |
225 } | |
226 | |
227 helpWindow = ''; | |
228 | |
229 } | |
230 | |
231 function changeHelp() { | |
232 showHelp = !showHelp; | |
233 showHelp ? openContextHelp() : closeContextHelp(); | |
234 } | |
235 | |
236 | |
237 // variable containing the contextwindow | |
238 | |
239 var helpWindow = ''; |